17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 /*
26 * @test
27 * @bug 8224137
28 * @summary Run invokevirtual invocation tests
29 * @library /test/lib
30 * @modules java.base/jdk.internal.org.objectweb.asm
31 * java.base/jdk.internal.misc
32 * @compile shared/AbstractGenerator.java shared/AccessCheck.java shared/AccessType.java
33 * shared/Caller.java shared/ExecutorGenerator.java shared/Utils.java
34 * shared/ByteArrayClassLoader.java shared/Checker.java shared/GenericClassGenerator.java
35 * @compile invokevirtual/Checker.java invokevirtual/ClassGenerator.java invokevirtual/Generator.java
36 *
37 * @run main/othervm/timeout=1800 invokevirtualTests
38 */
39
40 import jdk.test.lib.process.ProcessTools;
41 import jdk.test.lib.process.OutputAnalyzer;
42 import jdk.test.lib.compiler.InMemoryJavaCompiler;
43
44 public class invokevirtualTests {
45
46 public static void runTest(String classFileVersion, String option) throws Exception {
47 System.out.println("\ninvokevirtual invocation tests, option: " + option +
48 ", class file version: " + classFileVersion);
49 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false, "-Xmx128M", option,
50 "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED",
51 "invokevirtual.Generator", "--classfile_version=" + classFileVersion);
52 OutputAnalyzer output = new OutputAnalyzer(pb.start());
53 try {
54 output.shouldContain("EXECUTION STATUS: PASSED");
55 output.shouldHaveExitValue(0);
56 } catch (Throwable e) {
57 System.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.");
63 System.out.println(
64 "\nAlso note that passing --dump to invokevirtual.Generator will" +
65 " dump the generated classes (for debugging purposes).\n");
66 System.exit(1);
67 }
68 }
69
70 public static void main(String args[]) throws Throwable {
71 // Get current major class file version and test with it.
72 byte klassbuf[] = InMemoryJavaCompiler.compile("blah", "public class blah { }");
73 int major_version = klassbuf[6] << 8 | klassbuf[7];
74 runTest(String.valueOf(major_version), "-Xint");
75 // Uncomment the below test once JDK-8226588 is fixed
76 // runTest(String.valueOf(major_version), "-Xcomp");
77
78 // Test old class file version.
79 runTest("51", "-Xint"); // JDK-7
80 }
81 }
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 /*
26 * @test
27 * @bug 8224137
28 * @summary Run invokevirtual invocation tests
29 * @library /test/lib
30 * @modules java.base/jdk.internal.org.objectweb.asm
31 * java.base/jdk.internal.misc
32 * @compile shared/AbstractGenerator.java shared/AccessCheck.java shared/AccessType.java
33 * shared/Caller.java shared/ExecutorGenerator.java shared/Utils.java
34 * shared/ByteArrayClassLoader.java shared/Checker.java shared/GenericClassGenerator.java
35 * @compile invokevirtual/Checker.java invokevirtual/ClassGenerator.java invokevirtual/Generator.java
36 *
37 * @run driver/timeout=1800 invokevirtualTests
38 */
39
40 import jdk.test.lib.process.ProcessTools;
41 import jdk.test.lib.process.OutputAnalyzer;
42 import jdk.test.lib.compiler.InMemoryJavaCompiler;
43
44 public class invokevirtualTests {
45
46 public static void runTest(String classFileVersion, String option) throws Throwable {
47 System.out.println("\ninvokevirtual invocation tests, option: " + option +
48 ", class file version: " + classFileVersion);
49 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false, "-Xmx128M", option,
50 "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED",
51 "invokevirtual.Generator", "--classfile_version=" + classFileVersion);
52 OutputAnalyzer output = new OutputAnalyzer(pb.start());
53 try {
54 output.shouldContain("EXECUTION STATUS: PASSED");
55 output.shouldHaveExitValue(0);
56 } catch (Throwable e) {
57 System.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.");
63 System.out.println(
64 "\nAlso note that passing --dump to invokevirtual.Generator will" +
65 " dump the generated classes (for debugging purposes).\n");
66
67 throw e;
68 }
69 }
70
71 public static void main(String args[]) throws Throwable {
72 // Get current major class file version and test with it.
73 byte klassbuf[] = InMemoryJavaCompiler.compile("blah", "public class blah { }");
74 int major_version = klassbuf[6] << 8 | klassbuf[7];
75 runTest(String.valueOf(major_version), "-Xint");
76 // Uncomment the below test once JDK-8226588 is fixed
77 // runTest(String.valueOf(major_version), "-Xcomp");
78
79 // Test old class file version.
80 runTest("51", "-Xint"); // JDK-7
81 }
82 }
|