Path: blob/master/test/hotspot/jtreg/runtime/InvocationTests/invokeinterfaceTests.java
40941 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* @test26* @bug 822413727* @summary Run invokeinterface invocation tests28* @library /test/lib29* @modules java.base/jdk.internal.org.objectweb.asm30* java.base/jdk.internal.misc31* @compile shared/AbstractGenerator.java shared/AccessCheck.java shared/AccessType.java32* shared/Caller.java shared/ExecutorGenerator.java shared/Utils.java33* shared/ByteArrayClassLoader.java shared/Checker.java shared/GenericClassGenerator.java34* @compile invokeinterface/Checker.java invokeinterface/ClassGenerator.java35* invokeinterface/Generator.java36*37* @run driver/timeout=1800 invokeinterfaceTests38*/3940import jdk.test.lib.process.ProcessTools;41import jdk.test.lib.process.OutputAnalyzer;42import jdk.test.lib.compiler.InMemoryJavaCompiler;4344public class invokeinterfaceTests {4546public static void runTest(String classFileVersion, String option) throws Throwable {47System.out.println("\ninvokeinterface invocation tests, option: " + option +48", class file version: " + classFileVersion);49ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128M", option,50"--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED",51"invokeinterface.Generator", "--classfile_version=" + classFileVersion);52OutputAnalyzer output = new OutputAnalyzer(pb.start());53try {54output.shouldContain("EXECUTION STATUS: PASSED");55output.shouldHaveExitValue(0);56} catch (Throwable e) {57System.out.println(58"\nNote that an entry such as 'B.m/C.m' in the failure chart means that" +59" the test case failed because method B.m was invoked but the test " +60"expected method C.m to be invoked. Similarly, a result such as 'AME/C.m'" +61" means that an AbstractMethodError exception was thrown but the test" +62" case expected method C.m to be invoked.");63System.out.println(64"\nAlso note that passing --dump to invokeinterface.Generator will" +65" dump the generated classes (for debugging purposes).\n");6667throw e;68}69}7071public static void main(String args[]) throws Throwable {72// Get current major class file version and test with it.73byte klassbuf[] = InMemoryJavaCompiler.compile("blah", "public class blah { }");74int major_version = klassbuf[6] << 8 | klassbuf[7];75runTest(String.valueOf(major_version), "-Xint");76runTest(String.valueOf(major_version), "-Xcomp");7778// Test old class file version.79runTest("51", "-Xint"); // JDK-780}81}828384