Path: blob/master/test/hotspot/jtreg/runtime/InvocationTests/invocationC1Tests.java
40942 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 822695627* @summary Run invocation tests against C1 compiler28* @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 invokespecial/Checker.java invokespecial/ClassGenerator.java invokespecial/Generator.java35* invokevirtual/Checker.java invokevirtual/ClassGenerator.java invokevirtual/Generator.java36* invokeinterface/Checker.java invokeinterface/ClassGenerator.java invokeinterface/Generator.java37*38* @run driver/timeout=1800 invocationC1Tests39*/4041import jdk.test.lib.process.ProcessTools;42import jdk.test.lib.process.OutputAnalyzer;43import jdk.test.lib.compiler.InMemoryJavaCompiler;4445public class invocationC1Tests {4647public static void runTest(String whichTests, String classFileVersion) throws Throwable {48System.out.println("\nC1 invocation tests, Tests: " + whichTests +49", class file version: " + classFileVersion);50ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128M",51"-Xcomp", "-XX:TieredStopAtLevel=1",52"--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED",53whichTests, "--classfile_version=" + classFileVersion);54OutputAnalyzer output = new OutputAnalyzer(pb.start());55try {56output.shouldContain("EXECUTION STATUS: PASSED");57output.shouldHaveExitValue(0);58} catch (Throwable e) {59System.out.println(60"\nNote that an entry such as 'B.m/C.m' in the failure chart means that" +61" the test case failed because method B.m was invoked but the test " +62"expected method C.m to be invoked. Similarly, a result such as 'AME/C.m'" +63" means that an AbstractMethodError exception was thrown but the test" +64" case expected method C.m to be invoked.");65System.out.println(66"\nAlso note that passing --dump to invoke*.Generator will" +67" dump the generated classes (for debugging purposes).\n");6869throw e;70}71}7273public static void main(String args[]) throws Throwable {74// Get current major class file version and test with it.75byte klassbuf[] = InMemoryJavaCompiler.compile("blah", "public class blah { }");76int major_version = klassbuf[6] << 8 | klassbuf[7];77runTest("invokespecial.Generator", String.valueOf(major_version));78runTest("invokeinterface.Generator", String.valueOf(major_version));79runTest("invokevirtual.Generator", String.valueOf(major_version));80}81}828384