Path: blob/master/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetConstantPoolTest.java
41153 views
/*1* Copyright (c) 2015, 2020, 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* @ignore 824962130* @modules java.base/jdk.internal.misc31* @modules 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.meta35* jdk.internal.vm.ci/jdk.vm.ci.code36*37* @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper38* @run main/othervm -Xbootclasspath/a:.39* -XX:+UnlockDiagnosticVMOptions40* -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI41* -XX:-UseJVMCICompiler42* compiler.jvmci.compilerToVM.GetConstantPoolTest43*/44package compiler.jvmci.compilerToVM;4546import jdk.test.lib.Utils;47import compiler.jvmci.common.CTVMUtilities;48import compiler.jvmci.common.testcases.TestCase;49import jdk.vm.ci.hotspot.CompilerToVMHelper;50import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;51import jdk.vm.ci.hotspot.HotSpotResolvedObjectType;52import jdk.vm.ci.meta.ConstantPool;5354import java.lang.reflect.Field;55import java.lang.reflect.Executable;5657/**58* Tests for jdk.vm.ci.hotspot.CompilerToVM::getConstantPool method59*/60public class GetConstantPoolTest {6162public static void testMethod(Executable executable) {63test(CTVMUtilities.getResolvedMethod(executable));64}6566public static void testClass(Class cls) {67HotSpotResolvedObjectType type = CompilerToVMHelper68.lookupTypeHelper(Utils.toJVMTypeSignature(cls),69GetConstantPoolTest.class, /* resolve = */ true);70test(type);71}7273private static void test(Object object) {74ConstantPool cp = CompilerToVMHelper.getConstantPool(object);75System.out.println(object + " -> " + cp);76}7778public static void main(String[] args) {79TestCase.getAllClasses().forEach(GetConstantPoolTest::testClass);80TestCase.getAllExecutables().forEach(GetConstantPoolTest::testMethod);81testNull();82testObject();83}8485private static void testNull() {86try {87Object cp = CompilerToVMHelper.getConstantPool(null);88throw new AssertionError("Test OBJECT."89+ " Expected IllegalArgumentException has not been caught");90} catch (NullPointerException npe) {91// expected92}93}94private static void testObject() {95try {96Object cp = CompilerToVMHelper.getConstantPool(new Object());97throw new AssertionError("Test OBJECT."98+ " Expected IllegalArgumentException has not been caught");99} catch (IllegalArgumentException iae) {100// expected101}102}103}104105106