Path: blob/master/test/hotspot/jtreg/compiler/jvmci/compilerToVM/AsResolvedJavaMethodTest.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.org.objectweb.asm31* java.base/jdk.internal.org.objectweb.asm.tree32* jdk.internal.vm.ci/jdk.vm.ci.hotspot33* jdk.internal.vm.ci/jdk.vm.ci.code34* jdk.internal.vm.ci/jdk.vm.ci.meta35* jdk.internal.vm.ci/jdk.vm.ci.runtime36*37* @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper38* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler39* compiler.jvmci.compilerToVM.AsResolvedJavaMethodTest40*/4142package compiler.jvmci.compilerToVM;4344import jdk.test.lib.Asserts;45import jdk.vm.ci.hotspot.CompilerToVMHelper;46import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;4748import java.lang.reflect.Executable;49import java.util.Arrays;50import java.util.ArrayList;51import java.util.List;5253public class AsResolvedJavaMethodTest {5455private static class A {56{57System.out.println("Dummy");58}59public void f1() {}60public int f2() { return 0; }61public String f3() { return ""; }62}636465private static class S {66static {67System.out.println("Dummy static");68}69public S() {}70public void f1() {}71public int f2() { return 0; }72public String f3() { return ""; }73}7475private class B extends A {76public void f4() {}77}7879private interface I {80void f1();81int f2();82String f3();83}8485public static void main(String[] args) {86List<Class<?>> testCases = getTestCases();87testCases.forEach(AsResolvedJavaMethodTest::test);88}8990private static List<Class<?>> getTestCases() {91List<Class<?>> testCases = new ArrayList<>();92testCases.add(A.class);93testCases.add(S.class);94testCases.add(I.class);95testCases.add(B.class);96return testCases;97}9899private static void test(Class<?> aClass) {100testCorrectMethods(aClass);101}102103private static void testCorrectMethods(Class<?> holder) {104List<Executable> executables = new ArrayList<>();105executables.addAll(Arrays.asList(holder.getDeclaredMethods()));106executables.addAll(Arrays.asList(holder.getDeclaredConstructors()));107for (Executable executable : executables) {108HotSpotResolvedJavaMethod method = CompilerToVMHelper109.asResolvedJavaMethod(executable);110Asserts.assertNotNull(method, "could not convert " + method);111}112}113}114115116