# HG changeset patch # User Jaroslav Tulach # Date 1452161248 -3600 # Node ID 1f7fe9f4207a560a24697726ebafb0e89724c240 # Parent abb919421c2a59643c76084df86cbc2dd6e80161 Putting the reflection back to allow the test to run when Accessor and the test are loaded by different classloaders diff -r abb919421c2a -r 1f7fe9f4207a truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/impl/AccessorTest.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/impl/AccessorTest.java Tue Jan 05 13:06:57 2016 +0100 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/impl/AccessorTest.java Thu Jan 07 11:07:28 2016 +0100 @@ -22,10 +22,6 @@ */ package com.oracle.truffle.api.impl; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import java.lang.reflect.Field; import java.util.concurrent.Executors; import org.junit.BeforeClass; @@ -35,15 +31,17 @@ import com.oracle.truffle.api.vm.ImplicitExplicitExportTest.ExportImportLanguage1; import static com.oracle.truffle.api.vm.ImplicitExplicitExportTest.L1; import com.oracle.truffle.api.vm.PolyglotEngine; +import java.lang.reflect.Method; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; public class AccessorTest { - public static Accessor API; + public static Method find; @BeforeClass public static void initAccessors() throws Exception { - Field f = Accessor.class.getDeclaredField("API"); - f.setAccessible(true); - API = (Accessor) f.get(null); + find = Accessor.class.getDeclaredMethod("findLanguageByClass", Object.class, Class.class); + find.setAccessible(true); } @Test @@ -56,7 +54,7 @@ Object ret = language.eval(s).get(); assertNull("nothing is returned", ret); - ExportImportLanguage1 afterInitialization = Accessor.findLanguageByClass(vm, ExportImportLanguage1.class); + ExportImportLanguage1 afterInitialization = (ExportImportLanguage1) find.invoke(null, vm, ExportImportLanguage1.class); assertNotNull("Language found", afterInitialization); } }