24 25 /** 26 * @test 27 * @bug 8136421 28 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64" 29 * @library /testlibrary /../../test/lib / 30 * @compile ../common/CompilerToVMHelper.java 31 * @run main ClassFileInstaller jdk.vm.ci.hotspot.CompilerToVMHelper 32 * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI 33 * -Xbootclasspath/a:. 34 * compiler.jvmci.compilerToVM.MethodIsIgnoredBySecurityStackWalkTest 35 */ 36 37 package compiler.jvmci.compilerToVM; 38 39 import compiler.jvmci.common.CTVMUtilities; 40 import java.lang.reflect.Method; 41 import java.lang.reflect.Executable; 42 import java.util.HashMap; 43 import java.util.Map; 44 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethodImpl; 45 import jdk.vm.ci.hotspot.CompilerToVMHelper; 46 import jdk.test.lib.Asserts; 47 48 public class MethodIsIgnoredBySecurityStackWalkTest { 49 50 public static void main(String[] args) { 51 Map<Executable, Boolean> testCases = createTestCases(); 52 testCases.forEach( 53 MethodIsIgnoredBySecurityStackWalkTest::runSanityTest); 54 } 55 56 private static void runSanityTest(Executable aMethod, Boolean expected) { 57 HotSpotResolvedJavaMethodImpl method 58 = CTVMUtilities.getResolvedMethod(aMethod); 59 boolean isIgnored = CompilerToVMHelper 60 .methodIsIgnoredBySecurityStackWalk(method); 61 String msg = String.format("%s is%s ignored but must%s", aMethod, 62 isIgnored ? "" : " not", 63 expected ? "" : " not"); 64 Asserts.assertEQ(isIgnored, expected, msg); 65 } 66 67 private static Map<Executable, Boolean> createTestCases() { 68 Map<Executable, Boolean> testCases = new HashMap<>(); 69 70 try { 71 Class<?> aClass = Method.class; 72 testCases.put(aClass.getMethod("invoke", Object.class, 73 Object[].class), true); 74 75 aClass = Class.forName("sun.reflect.NativeMethodAccessorImpl"); 76 testCases.put(aClass.getMethod("invoke", Object.class, 77 Object[].class), true); | 24 25 /** 26 * @test 27 * @bug 8136421 28 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64" 29 * @library /testlibrary /../../test/lib / 30 * @compile ../common/CompilerToVMHelper.java 31 * @run main ClassFileInstaller jdk.vm.ci.hotspot.CompilerToVMHelper 32 * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI 33 * -Xbootclasspath/a:. 34 * compiler.jvmci.compilerToVM.MethodIsIgnoredBySecurityStackWalkTest 35 */ 36 37 package compiler.jvmci.compilerToVM; 38 39 import compiler.jvmci.common.CTVMUtilities; 40 import java.lang.reflect.Method; 41 import java.lang.reflect.Executable; 42 import java.util.HashMap; 43 import java.util.Map; 44 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; 45 import jdk.vm.ci.hotspot.CompilerToVMHelper; 46 import jdk.test.lib.Asserts; 47 48 public class MethodIsIgnoredBySecurityStackWalkTest { 49 50 public static void main(String[] args) { 51 Map<Executable, Boolean> testCases = createTestCases(); 52 testCases.forEach( 53 MethodIsIgnoredBySecurityStackWalkTest::runSanityTest); 54 } 55 56 private static void runSanityTest(Executable aMethod, Boolean expected) { 57 HotSpotResolvedJavaMethod method 58 = CTVMUtilities.getResolvedMethod(aMethod); 59 boolean isIgnored = CompilerToVMHelper 60 .methodIsIgnoredBySecurityStackWalk(method); 61 String msg = String.format("%s is%s ignored but must%s", aMethod, 62 isIgnored ? "" : " not", 63 expected ? "" : " not"); 64 Asserts.assertEQ(isIgnored, expected, msg); 65 } 66 67 private static Map<Executable, Boolean> createTestCases() { 68 Map<Executable, Boolean> testCases = new HashMap<>(); 69 70 try { 71 Class<?> aClass = Method.class; 72 testCases.put(aClass.getMethod("invoke", Object.class, 73 Object[].class), true); 74 75 aClass = Class.forName("sun.reflect.NativeMethodAccessorImpl"); 76 testCases.put(aClass.getMethod("invoke", Object.class, 77 Object[].class), true); |