Path: blob/master/test/hotspot/jtreg/runtime/InvocationTests/invokeinterfaceTests.java
64474 views
/*1* Copyright (c) 2019, 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*22*/2324/*25* @test id=current-int26* @bug 822413727* @summary Run invokeinterface invocation tests28* @library /test/lib29* @modules java.base/jdk.internal.org.objectweb.asm30* java.base/jdk.internal.misc31* @compile invokeinterface/Checker.java invokeinterface/ClassGenerator.java32* invokeinterface/Generator.java33*34* @run driver/timeout=1800 invokeinterfaceTests current-int35*/3637/*38* @test id=current-comp39* @bug 822413740* @summary Run invokeinterface invocation tests41* @requires vm.flagless42* @library /test/lib43* @modules java.base/jdk.internal.org.objectweb.asm44* java.base/jdk.internal.misc45* @compile invokeinterface/Checker.java invokeinterface/ClassGenerator.java46* invokeinterface/Generator.java47*48* @run driver/timeout=1800 invokeinterfaceTests current-comp49*/5051/*52* @test id=old-int53* @bug 822413754* @summary Run invokeinterface invocation tests55* @requires vm.flagless56* @library /test/lib57* @modules java.base/jdk.internal.org.objectweb.asm58* java.base/jdk.internal.misc59* @compile invokeinterface/Checker.java invokeinterface/ClassGenerator.java60* invokeinterface/Generator.java61*62* @run driver/timeout=1800 invokeinterfaceTests old-int63*/6465import jdk.test.lib.process.ProcessTools;66import jdk.test.lib.process.OutputAnalyzer;67import jdk.test.lib.compiler.InMemoryJavaCompiler;6869public class invokeinterfaceTests {7071public static void runTest(String classFileVersion, String option) throws Throwable {72System.out.println("\ninvokeinterface invocation tests, option: " + option +73", class file version: " + classFileVersion);74ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128M", option,75"--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED",76"invokeinterface.Generator", "--classfile_version=" + classFileVersion);77OutputAnalyzer output = new OutputAnalyzer(pb.start());78try {79output.shouldContain("EXECUTION STATUS: PASSED");80output.shouldHaveExitValue(0);81} catch (Throwable e) {82System.out.println(83"\nNote that an entry such as 'B.m/C.m' in the failure chart means that" +84" the test case failed because method B.m was invoked but the test " +85"expected method C.m to be invoked. Similarly, a result such as 'AME/C.m'" +86" means that an AbstractMethodError exception was thrown but the test" +87" case expected method C.m to be invoked.");88System.out.println(89"\nAlso note that passing --dump to invokeinterface.Generator will" +90" dump the generated classes (for debugging purposes).\n");9192throw e;93}94}9596public static void main(String args[]) throws Throwable {97if (args.length < 1) {98throw new IllegalArgumentException("Should provide the test name");99}100String testName = args[0];101102// Get current major class file version and test with it.103byte klassbuf[] = InMemoryJavaCompiler.compile("blah", "public class blah { }");104int major_version = klassbuf[6] << 8 | klassbuf[7];105106switch (testName) {107case "current-int":108runTest(String.valueOf(major_version), "-Xint");109break;110case "current-comp":111runTest(String.valueOf(major_version), "-Xcomp");112break;113case "old-int":114// Test old class file version.115runTest("51", "-Xint"); // JDK-7116break;117default:118throw new IllegalArgumentException("Unknown test name: " + testName);119}120}121}122123124