test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8073191-work Sdiff test/compiler/jvmci/compilerToVM

test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java

Print this page




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 /*
  26  * @test
  27  * @bug 8138708
  28  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  29  * @library /testlibrary /test/lib /
  30  * @library ../common/patches
  31  * @modules java.base/jdk.internal.misc
  32  *          java.base/jdk.internal.reflect
  33  *          java.base/jdk.internal.org.objectweb.asm
  34  *          java.base/jdk.internal.org.objectweb.asm.tree
  35  *          jdk.vm.ci/jdk.vm.ci.hotspot
  36  *          jdk.vm.ci/jdk.vm.ci.meta

  37  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
  38  * @build sun.hotspot.WhiteBox
  39  *        compiler.jvmci.compilerToVM.ResolveFieldInPoolTest
  40  * @run main 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.ConstantPoolTestsHelper.DummyClasses;
  50 import compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes;
  51 import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.*;
  52 import compiler.jvmci.compilerToVM.ConstantPoolTestCase.TestedCPEntry;
  53 import compiler.jvmci.compilerToVM.ConstantPoolTestCase.Validator;
  54 import java.lang.reflect.Field;
  55 import java.util.HashMap;
  56 import java.util.Map;


  90     private static void validate(ConstantPool constantPoolCTVM,
  91                                  ConstantTypes cpType,
  92                                  DummyClasses dummyClass,
  93                                  int cpi) {
  94         TestedCPEntry entry = cpType.getTestedCPEntry(dummyClass, cpi);
  95         if (entry == null) {
  96             return;
  97         }
  98         int index = cpi;
  99         String cached = "";
 100         int cpci = dummyClass.getCPCacheIndex(cpi);
 101         if (cpci != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT) {
 102             index = cpci;
 103             cached = "cached ";
 104         }
 105         for (int j = 0; j < entry.opcodes.length; j++) {
 106             long[] info = new long[2];
 107             HotSpotResolvedObjectType fieldToVerify
 108                     = CompilerToVMHelper.resolveFieldInPool(constantPoolCTVM,
 109                                                            index,

 110                                                            entry.opcodes[j],
 111                                                            info);
 112             String msg = String.format("Object returned by resolveFieldInPool method"
 113                                                + " for %sindex %d  should not be null",
 114                                        cached,
 115                                        index);
 116             Asserts.assertNotNull(fieldToVerify, msg);
 117             String classNameToRefer = entry.klass;
 118             String fieldToVerifyKlassToString = fieldToVerify.klass().toValueString();
 119             if (!fieldToVerifyKlassToString.contains(classNameToRefer)) {
 120                 msg = String.format("String representation \"%s\" of the object"
 121                                             + " returned by resolveFieldInPool method"
 122                                             + " for index %d does not contain a field's class name,"
 123                                             + " should contain %s",
 124                                     fieldToVerifyKlassToString,
 125                                     index,
 126                                     classNameToRefer);
 127                 throw new AssertionError(msg);
 128             }
 129             msg = String.format("Access flags returned by resolveFieldInPool"




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 /*
  26  * @test
  27  * @bug 8138708
  28  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  29  * @library /testlibrary /test/lib /
  30  * @library ../common/patches
  31  * @modules java.base/jdk.internal.misc
  32  *          java.base/jdk.internal.reflect
  33  *          java.base/jdk.internal.org.objectweb.asm
  34  *          java.base/jdk.internal.org.objectweb.asm.tree
  35  *          jdk.vm.ci/jdk.vm.ci.hotspot
  36  *          jdk.vm.ci/jdk.vm.ci.meta
  37  *          jdk.vm.ci/jdk.vm.ci.runtime
  38  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
  39  * @build sun.hotspot.WhiteBox
  40  *        compiler.jvmci.compilerToVM.ResolveFieldInPoolTest
  41  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  42  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  43  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  44  *                   -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
  45  *                   compiler.jvmci.compilerToVM.ResolveFieldInPoolTest
  46  */
  47 
  48 package compiler.jvmci.compilerToVM;
  49 
  50 import compiler.jvmci.compilerToVM.ConstantPoolTestsHelper.DummyClasses;
  51 import compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes;
  52 import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.*;
  53 import compiler.jvmci.compilerToVM.ConstantPoolTestCase.TestedCPEntry;
  54 import compiler.jvmci.compilerToVM.ConstantPoolTestCase.Validator;
  55 import java.lang.reflect.Field;
  56 import java.util.HashMap;
  57 import java.util.Map;


  91     private static void validate(ConstantPool constantPoolCTVM,
  92                                  ConstantTypes cpType,
  93                                  DummyClasses dummyClass,
  94                                  int cpi) {
  95         TestedCPEntry entry = cpType.getTestedCPEntry(dummyClass, cpi);
  96         if (entry == null) {
  97             return;
  98         }
  99         int index = cpi;
 100         String cached = "";
 101         int cpci = dummyClass.getCPCacheIndex(cpi);
 102         if (cpci != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT) {
 103             index = cpci;
 104             cached = "cached ";
 105         }
 106         for (int j = 0; j < entry.opcodes.length; j++) {
 107             long[] info = new long[2];
 108             HotSpotResolvedObjectType fieldToVerify
 109                     = CompilerToVMHelper.resolveFieldInPool(constantPoolCTVM,
 110                                                            index,
 111                                                            entry.methods == null ? null : entry.methods[j],
 112                                                            entry.opcodes[j],
 113                                                            info);
 114             String msg = String.format("Object returned by resolveFieldInPool method"
 115                                                + " for %sindex %d  should not be null",
 116                                        cached,
 117                                        index);
 118             Asserts.assertNotNull(fieldToVerify, msg);
 119             String classNameToRefer = entry.klass;
 120             String fieldToVerifyKlassToString = fieldToVerify.klass().toValueString();
 121             if (!fieldToVerifyKlassToString.contains(classNameToRefer)) {
 122                 msg = String.format("String representation \"%s\" of the object"
 123                                             + " returned by resolveFieldInPool method"
 124                                             + " for index %d does not contain a field's class name,"
 125                                             + " should contain %s",
 126                                     fieldToVerifyKlassToString,
 127                                     index,
 128                                     classNameToRefer);
 129                 throw new AssertionError(msg);
 130             }
 131             msg = String.format("Access flags returned by resolveFieldInPool"


test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File