< prev index next >

test/compiler/jvmci/compilerToVM/GetBytecodeTest.java

Print this page




  26  * @test
  27  * @bug 8136421
  28  * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64")
  29  * @library /testlibrary /test/lib /
  30  * @library ../common/patches
  31  * @modules java.base/jdk.internal.misc
  32  * @modules java.base/jdk.internal.org.objectweb.asm
  33  *          java.base/jdk.internal.org.objectweb.asm.tree
  34  *          jdk.vm.ci/jdk.vm.ci.hotspot
  35  *          jdk.vm.ci/jdk.vm.ci.code
  36  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
  37  * @build compiler.jvmci.compilerToVM.GetBytecodeTest
  38  * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
  39  *                   compiler.jvmci.compilerToVM.GetBytecodeTest
  40  */
  41 
  42 package compiler.jvmci.compilerToVM;
  43 
  44 import compiler.jvmci.common.CTVMUtilities;
  45 import compiler.jvmci.common.testcases.TestCase;
  46 import java.lang.reflect.Executable;
  47 import java.lang.reflect.Modifier;
  48 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
  49 import jdk.vm.ci.hotspot.CompilerToVMHelper;
  50 import jdk.internal.org.objectweb.asm.Opcodes;
  51 import jdk.test.lib.Asserts;





  52 
  53 public class GetBytecodeTest {
  54 
  55     public static void main(String[] args) {
  56         TestCase.getAllExecutables()
  57                 .forEach(GetBytecodeTest::runSanityTest);
  58     }
  59 
  60     private static void runSanityTest(Executable aMethod) {
  61         HotSpotResolvedJavaMethod method = CTVMUtilities
  62                 .getResolvedMethod(aMethod);
  63         byte[] bytecode = CompilerToVMHelper.getBytecode(method);
  64 
  65         int mods = aMethod.getModifiers();
  66         boolean shouldHasZeroLength = Modifier.isAbstract(mods)
  67                 || Modifier.isNative(mods);
  68         boolean correctLength = (bytecode.length == 0 && shouldHasZeroLength)
  69                 || (bytecode.length > 0 && !shouldHasZeroLength);
  70 
  71         Asserts.assertTrue(correctLength, "Bytecode of '" + aMethod + "' has "




  26  * @test
  27  * @bug 8136421
  28  * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64")
  29  * @library /testlibrary /test/lib /
  30  * @library ../common/patches
  31  * @modules java.base/jdk.internal.misc
  32  * @modules java.base/jdk.internal.org.objectweb.asm
  33  *          java.base/jdk.internal.org.objectweb.asm.tree
  34  *          jdk.vm.ci/jdk.vm.ci.hotspot
  35  *          jdk.vm.ci/jdk.vm.ci.code
  36  * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
  37  * @build compiler.jvmci.compilerToVM.GetBytecodeTest
  38  * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
  39  *                   compiler.jvmci.compilerToVM.GetBytecodeTest
  40  */
  41 
  42 package compiler.jvmci.compilerToVM;
  43 
  44 import compiler.jvmci.common.CTVMUtilities;
  45 import compiler.jvmci.common.testcases.TestCase;




  46 import jdk.internal.org.objectweb.asm.Opcodes;
  47 import jdk.test.lib.Asserts;
  48 import jdk.vm.ci.hotspot.CompilerToVMHelper;
  49 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
  50 
  51 import java.lang.reflect.Executable;
  52 import java.lang.reflect.Modifier;
  53 
  54 public class GetBytecodeTest {
  55 
  56     public static void main(String[] args) {
  57         TestCase.getAllExecutables()
  58                 .forEach(GetBytecodeTest::runSanityTest);
  59     }
  60 
  61     private static void runSanityTest(Executable aMethod) {
  62         HotSpotResolvedJavaMethod method = CTVMUtilities
  63                 .getResolvedMethod(aMethod);
  64         byte[] bytecode = CompilerToVMHelper.getBytecode(method);
  65 
  66         int mods = aMethod.getModifiers();
  67         boolean shouldHasZeroLength = Modifier.isAbstract(mods)
  68                 || Modifier.isNative(mods);
  69         boolean correctLength = (bytecode.length == 0 && shouldHasZeroLength)
  70                 || (bytecode.length > 0 && !shouldHasZeroLength);
  71 
  72         Asserts.assertTrue(correctLength, "Bytecode of '" + aMethod + "' has "


< prev index next >