< prev index next >

test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java

Print this page




  36  *          jdk.vm.ci/jdk.vm.ci.meta
  37  *          jdk.vm.ci/jdk.vm.ci.runtime
  38  *
  39  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper sun.hotspot.WhiteBox
  40  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  41  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
  42  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  43  *                   -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
  44  *                   compiler.jvmci.compilerToVM.ResolveFieldInPoolTest
  45  */
  46 
  47 package compiler.jvmci.compilerToVM;
  48 
  49 import compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes;
  50 import compiler.jvmci.compilerToVM.ConstantPoolTestCase.TestedCPEntry;
  51 import compiler.jvmci.compilerToVM.ConstantPoolTestCase.Validator;
  52 import compiler.jvmci.compilerToVM.ConstantPoolTestsHelper.DummyClasses;
  53 import jdk.internal.misc.Unsafe;
  54 import jdk.internal.org.objectweb.asm.Opcodes;
  55 import jdk.test.lib.Asserts;
  56 import jdk.test.lib.unsafe.UnsafeHelper;
  57 import jdk.vm.ci.hotspot.CompilerToVMHelper;
  58 import jdk.vm.ci.hotspot.HotSpotResolvedObjectType;
  59 import jdk.vm.ci.meta.ConstantPool;
  60 
  61 import java.lang.reflect.Field;
  62 import java.util.HashMap;
  63 import java.util.Map;
  64 
  65 import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_FIELDREF;
  66 
  67 /**
  68  * Test for {@code jdk.vm.ci.hotspot.CompilerToVM.resolveFieldInPool} method
  69  */
  70 public class ResolveFieldInPoolTest {
  71 
  72     private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe();
  73 
  74     public static void main(String[] args) throws Exception {
  75         Map<ConstantTypes, Validator> typeTests = new HashMap<>();
  76         typeTests.put(CONSTANT_FIELDREF, ResolveFieldInPoolTest::validate);
  77         ConstantPoolTestCase testCase = new ConstantPoolTestCase(typeTests);
  78         testCase.test();
  79         // The next "Class.forName" and repeating "testCase.test()"
  80         // are here for the following reason.
  81         // The first test run is without dummy class initialization,
  82         // which means no constant pool cache exists.
  83         // The second run is with initialized class (with constant pool cache available).
  84         // Some CompilerToVM methods require different input
  85         // depending on whether CP cache exists or not.
  86         for (DummyClasses dummy : DummyClasses.values()) {
  87             Class.forName(dummy.klass.getName());
  88         }
  89         testCase.test();
  90     }
  91 
  92     private static void validate(ConstantPool constantPoolCTVM,




  36  *          jdk.vm.ci/jdk.vm.ci.meta
  37  *          jdk.vm.ci/jdk.vm.ci.runtime
  38  *
  39  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper sun.hotspot.WhiteBox
  40  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  41  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
  42  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  43  *                   -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
  44  *                   compiler.jvmci.compilerToVM.ResolveFieldInPoolTest
  45  */
  46 
  47 package compiler.jvmci.compilerToVM;
  48 
  49 import compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes;
  50 import compiler.jvmci.compilerToVM.ConstantPoolTestCase.TestedCPEntry;
  51 import compiler.jvmci.compilerToVM.ConstantPoolTestCase.Validator;
  52 import compiler.jvmci.compilerToVM.ConstantPoolTestsHelper.DummyClasses;
  53 import jdk.internal.misc.Unsafe;
  54 import jdk.internal.org.objectweb.asm.Opcodes;
  55 import jdk.test.lib.Asserts;

  56 import jdk.vm.ci.hotspot.CompilerToVMHelper;
  57 import jdk.vm.ci.hotspot.HotSpotResolvedObjectType;
  58 import jdk.vm.ci.meta.ConstantPool;
  59 
  60 import java.lang.reflect.Field;
  61 import java.util.HashMap;
  62 import java.util.Map;
  63 
  64 import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_FIELDREF;
  65 
  66 /**
  67  * Test for {@code jdk.vm.ci.hotspot.CompilerToVM.resolveFieldInPool} method
  68  */
  69 public class ResolveFieldInPoolTest {
  70 
  71     private static final Unsafe UNSAFE = Unsafe.getUnsafe();
  72 
  73     public static void main(String[] args) throws Exception {
  74         Map<ConstantTypes, Validator> typeTests = new HashMap<>();
  75         typeTests.put(CONSTANT_FIELDREF, ResolveFieldInPoolTest::validate);
  76         ConstantPoolTestCase testCase = new ConstantPoolTestCase(typeTests);
  77         testCase.test();
  78         // The next "Class.forName" and repeating "testCase.test()"
  79         // are here for the following reason.
  80         // The first test run is without dummy class initialization,
  81         // which means no constant pool cache exists.
  82         // The second run is with initialized class (with constant pool cache available).
  83         // Some CompilerToVM methods require different input
  84         // depending on whether CP cache exists or not.
  85         for (DummyClasses dummy : DummyClasses.values()) {
  86             Class.forName(dummy.klass.getName());
  87         }
  88         testCase.test();
  89     }
  90 
  91     private static void validate(ConstantPool constantPoolCTVM,


< prev index next >