Path: blob/master/test/hotspot/jtreg/runtime/InvocationTests/invocationOldCHATests.java
64474 views
/*1* Copyright (c) 2019, 2021, 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=special26* @summary Run invocation tests with old CHA (-XX:-UseVtableBasedCHA)27* @library /test/lib28* @modules java.base/jdk.internal.org.objectweb.asm29* java.base/jdk.internal.misc30* @compile invokespecial/Checker.java invokespecial/ClassGenerator.java invokespecial/Generator.java31*32* @run driver/timeout=1800 invocationOldCHATests special33*/3435/*36* @test id=virtual37* @summary Run invocation tests with old CHA (-XX:-UseVtableBasedCHA)38* @requires vm.flagless39* @library /test/lib40* @modules java.base/jdk.internal.org.objectweb.asm41* java.base/jdk.internal.misc42* @compile invokevirtual/Checker.java invokevirtual/ClassGenerator.java invokevirtual/Generator.java43*44* @run driver/timeout=1800 invocationOldCHATests virtual45*/4647/*48* @test id=interface49* @summary Run invocation tests with old CHA (-XX:-UseVtableBasedCHA)50* @requires vm.flagless51* @library /test/lib52* @modules java.base/jdk.internal.org.objectweb.asm53* java.base/jdk.internal.misc54* @compile invokeinterface/Checker.java invokeinterface/ClassGenerator.java invokeinterface/Generator.java55*56* @run driver/timeout=1800 invocationOldCHATests interface57*/5859import jdk.test.lib.process.ProcessTools;60import jdk.test.lib.process.OutputAnalyzer;61import jdk.test.lib.compiler.InMemoryJavaCompiler;6263public class invocationOldCHATests {6465public static void runTest(String whichTests, String classFileVersion) throws Throwable {66System.out.println("\nOld CHA invocation tests, Tests: " + whichTests +67", class file version: " + classFileVersion);68ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128M",69"-Xcomp", "-XX:+UnlockDiagnosticVMOptions", "-XX:-UseVtableBasedCHA",70"--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED",71whichTests, "--classfile_version=" + classFileVersion);72OutputAnalyzer output = new OutputAnalyzer(pb.start());73try {74output.shouldContain("EXECUTION STATUS: PASSED");75output.shouldHaveExitValue(0);76} catch (Throwable e) {77System.out.println(78"\nNote that an entry such as 'B.m/C.m' in the failure chart means that" +79" the test case failed because method B.m was invoked but the test " +80"expected method C.m to be invoked. Similarly, a result such as 'AME/C.m'" +81" means that an AbstractMethodError exception was thrown but the test" +82" case expected method C.m to be invoked.");83System.out.println(84"\nAlso note that passing --dump to invoke*.Generator will" +85" dump the generated classes (for debugging purposes).\n");8687throw e;88}89}9091public static void main(String args[]) throws Throwable {92if (args.length < 1) {93throw new IllegalArgumentException("Should provide the test name");94}95String testName = args[0];9697// Get current major class file version and test with it.98byte klassbuf[] = InMemoryJavaCompiler.compile("blah", "public class blah { }");99int major_version = klassbuf[6] << 8 | klassbuf[7];100101switch (testName) {102case "special":103runTest("invokespecial.Generator", String.valueOf(major_version));104break;105case "virtual":106runTest("invokevirtual.Generator", String.valueOf(major_version));107break;108case "interface":109runTest("invokeinterface.Generator", String.valueOf(major_version));110break;111default:112throw new IllegalArgumentException("Unknown test name: " + testName);113}114}115}116117118