test/hotspot/jtreg/compiler/unsafe/UnsafeGetConstantField.java
changeset 52015 821bfc24d750
parent 51016 a926b7737d3b
child 52220 9c260a6b6471
equal deleted inserted replaced
52014:1aa9beac610e 52015:821bfc24d750
    29  * @requires vm.flavor == "server" & !vm.emulatedClient
    29  * @requires vm.flavor == "server" & !vm.emulatedClient
    30  *
    30  *
    31  * @modules java.base/jdk.internal.org.objectweb.asm
    31  * @modules java.base/jdk.internal.org.objectweb.asm
    32  *          java.base/jdk.internal.vm.annotation
    32  *          java.base/jdk.internal.vm.annotation
    33  *          java.base/jdk.internal.misc
    33  *          java.base/jdk.internal.misc
       
    34  *
       
    35  * @library ../jsr292/patches
       
    36  * @build java.base/java.lang.invoke.MethodHandleHelper
    34  *
    37  *
    35  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions
    38  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions
    36  *                                 -Xbatch -XX:-TieredCompilation
    39  *                                 -Xbatch -XX:-TieredCompilation
    37  *                                 -XX:+FoldStableValues
    40  *                                 -XX:+FoldStableValues
    38  *                                 -XX:CompileCommand=dontinline,compiler.unsafe.UnsafeGetConstantField::checkGetAddress
    41  *                                 -XX:CompileCommand=dontinline,compiler.unsafe.UnsafeGetConstantField::checkGetAddress
    62 import jdk.internal.org.objectweb.asm.Type;
    65 import jdk.internal.org.objectweb.asm.Type;
    63 import jdk.internal.vm.annotation.Stable;
    66 import jdk.internal.vm.annotation.Stable;
    64 import jdk.test.lib.Asserts;
    67 import jdk.test.lib.Asserts;
    65 import jdk.test.lib.Platform;
    68 import jdk.test.lib.Platform;
    66 
    69 
       
    70 import java.lang.invoke.MethodHandleHelper;
       
    71 import java.lang.invoke.MethodHandles;
       
    72 import java.lang.invoke.MethodHandles.Lookup;
    67 import java.io.IOException;
    73 import java.io.IOException;
    68 import java.nio.file.Files;
    74 import java.nio.file.Files;
    69 import java.nio.file.Path;
    75 import java.nio.file.Path;
    70 import java.nio.file.Paths;
    76 import java.nio.file.Paths;
    71 
    77 
   391 
   397 
   392             return cw.toByteArray();
   398             return cw.toByteArray();
   393         }
   399         }
   394 
   400 
   395         Test generate() {
   401         Test generate() {
   396             Class<?> c = U.defineClass(className, classFile, 0, classFile.length, THIS_CLASS.getClassLoader(), null);
       
   397             try {
   402             try {
       
   403                 Lookup lookup = MethodHandleHelper.IMPL_LOOKUP.in(MethodHandles.class);
       
   404                 Class<?> c = lookup.defineClass(classFile);
   398                 return (Test) c.newInstance();
   405                 return (Test) c.newInstance();
   399             } catch(Exception e) {
   406             } catch(Exception e) {
   400                 throw new Error(e);
   407                 throw new Error(e);
   401             }
   408             }
   402         }
   409         }