Mercurial > hg > truffle
changeset 22533:1f7fe9f4207a
Putting the reflection back to allow the test to run when Accessor and the test are loaded by different classloaders
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Thu, 07 Jan 2016 11:07:28 +0100 |
parents | abb919421c2a |
children | 1133c68332ef |
files | truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/impl/AccessorTest.java |
diffstat | 1 files changed, 7 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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); } }