Mercurial > hg > graal-compiler
changeset 22787:a9363c9d0f58
fixed test for JDK9
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 08 Oct 2015 14:58:22 +0100 |
parents | fc5e7703e588 |
children | 26bbed810326 |
files | graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/ConstantPoolSubstitutionsTests.java |
diffstat | 1 files changed, 16 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/ConstantPoolSubstitutionsTests.java Thu Oct 08 14:58:00 2015 +0100 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/ConstantPoolSubstitutionsTests.java Thu Oct 08 14:58:22 2015 +0100 @@ -25,9 +25,6 @@ import org.junit.Test; -import sun.misc.SharedSecrets; -import sun.reflect.ConstantPool; - import com.oracle.graal.compiler.test.GraalCompilerTest; import com.oracle.graal.debug.Debug; import com.oracle.graal.debug.Debug.Scope; @@ -36,6 +33,8 @@ import com.oracle.graal.nodes.StructuredGraph; import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; +import sun.reflect.ConstantPool; + public class ConstantPoolSubstitutionsTests extends GraalCompilerTest { @SuppressWarnings("try") @@ -60,9 +59,22 @@ return graph; } + private static ConstantPool getConstantPoolForObject() { + String javaVersion = System.getProperty("java.specification.version"); + String miscPackage = javaVersion.compareTo("1.9") < 0 ? "sun.misc" : "jdk.internal.misc"; + try { + Class<?> sharedSecretsClass = Class.forName(miscPackage + ".SharedSecrets"); + Class<?> javaLangAccessClass = Class.forName(miscPackage + ".JavaLangAccess"); + Object jla = sharedSecretsClass.getDeclaredMethod("getJavaLangAccess").invoke(null); + return (ConstantPool) javaLangAccessClass.getDeclaredMethod("getConstantPool", Class.class).invoke(jla, Object.class); + } catch (Exception e) { + throw new AssertionError(e); + } + } + @Test public void testGetSize() { - ConstantPool cp = SharedSecrets.getJavaLangAccess().getConstantPool(Object.class); + ConstantPool cp = getConstantPoolForObject(); test("getSize", cp); }