Path: blob/master/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java
41153 views
/*1* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 813642126* @requires vm.jvmci27* @library /test/lib /28* @library ../common/patches29* @modules java.base/jdk.internal.misc30* @modules java.base/jdk.internal.reflect31* java.base/jdk.internal.org.objectweb.asm32* java.base/jdk.internal.org.objectweb.asm.tree33* jdk.internal.vm.ci/jdk.vm.ci.hotspot34* jdk.internal.vm.ci/jdk.vm.ci.code35* jdk.internal.vm.ci/jdk.vm.ci.meta36* jdk.internal.vm.ci/jdk.vm.ci.runtime37*38* @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper39* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI40* -XX:-UseJVMCICompiler41* compiler.jvmci.compilerToVM.MethodIsIgnoredBySecurityStackWalkTest42*/4344package compiler.jvmci.compilerToVM;4546import compiler.jvmci.common.CTVMUtilities;47import jdk.test.lib.Asserts;48import jdk.vm.ci.hotspot.CompilerToVMHelper;49import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;5051import java.lang.reflect.Executable;52import java.lang.reflect.Method;53import java.util.HashMap;54import java.util.Map;5556public class MethodIsIgnoredBySecurityStackWalkTest {5758public static void main(String[] args) {59Map<Executable, Boolean> testCases = createTestCases();60testCases.forEach(61MethodIsIgnoredBySecurityStackWalkTest::runSanityTest);62}6364private static void runSanityTest(Executable aMethod, Boolean expected) {65HotSpotResolvedJavaMethod method66= CTVMUtilities.getResolvedMethod(aMethod);67boolean isIgnored = CompilerToVMHelper68.methodIsIgnoredBySecurityStackWalk(method);69String msg = String.format("%s is%s ignored but must%s", aMethod,70isIgnored ? "" : " not",71expected ? "" : " not");72Asserts.assertEQ(isIgnored, expected, msg);73}7475private static Map<Executable, Boolean> createTestCases() {76Map<Executable, Boolean> testCases = new HashMap<>();7778try {79Class<?> aClass = Method.class;80testCases.put(aClass.getMethod("invoke", Object.class,81Object[].class), true);8283aClass = Class.forName("jdk.internal.reflect.NativeMethodAccessorImpl");84testCases.put(aClass.getMethod("invoke", Object.class,85Object[].class), true);86testCases.put(aClass.getDeclaredMethod("invoke0", Method.class,87Object.class, Object[].class), true);8889aClass = MethodIsIgnoredBySecurityStackWalkTest.class;90for (Executable method : aClass.getMethods()) {91testCases.put(method, false);92}93for (Executable method : aClass.getDeclaredMethods()) {94testCases.put(method, false);95}96for (Executable method : aClass.getConstructors()) {97testCases.put(method, false);98}99} catch (NoSuchMethodException | ClassNotFoundException e) {100throw new Error("TEST BUG " + e.getMessage(), e);101}102return testCases;103}104}105106107