8239461: Use jcod rather than jar files in runtime tests

Reviewed-by: hseigel, lmesnik, dholmes
This commit is contained in:
Coleen Phillimore 2020-02-20 07:25:14 -05:00
parent 58a5910393
commit b4ffe4d8f7
16 changed files with 4209 additions and 31 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,6 +28,7 @@
* @summary Check attribute_length of EnclosingMethod attribute * @summary Check attribute_length of EnclosingMethod attribute
* @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.misc
* java.management * java.management
* @compile EnclMethTest.jcod
* @run main EnclMethodAttr * @run main EnclMethodAttr
*/ */
@ -41,8 +42,7 @@ public class EnclMethodAttr {
public static void main(String args[]) throws Throwable { public static void main(String args[]) throws Throwable {
System.out.println("Regression test for bug 8044738"); System.out.println("Regression test for bug 8044738");
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("EnclMethTest");
"-jar", testsrc + File.separator + "enclMethodAttr.jar");
OutputAnalyzer output = new OutputAnalyzer(pb.start()); OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("java.lang.ClassFormatError: Wrong EnclosingMethod"); output.shouldContain("java.lang.ClassFormatError: Wrong EnclosingMethod");
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,6 +28,7 @@
* @library /test/lib * @library /test/lib
* @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.misc
* java.management * java.management
* @compile DuplicateLVT.jcod DuplicateLVTT.jcod NotFoundLVTT.jcod
* @compile -g -XDignore.symbol.file TestLVT.java * @compile -g -XDignore.symbol.file TestLVT.java
* @run main TestLVT * @run main TestLVT
*/ */
@ -43,19 +44,19 @@ public class TestLVT {
String jarFile = System.getProperty("test.src") + "/testcase.jar"; String jarFile = System.getProperty("test.src") + "/testcase.jar";
// java -cp $testSrc/testcase.jar DuplicateLVT // java -cp $testSrc/testcase.jar DuplicateLVT
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-cp", jarFile, "DuplicateLVT"); ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("DuplicateLVT");
new OutputAnalyzer(pb.start()) new OutputAnalyzer(pb.start())
.shouldContain("Duplicated LocalVariableTable attribute entry for 'by' in class file DuplicateLVT") .shouldContain("Duplicated LocalVariableTable attribute entry for 'by' in class file DuplicateLVT")
.shouldHaveExitValue(1); .shouldHaveExitValue(1);
// java -cp $testclasses/testcase.jar DuplicateLVTT // java -cp $testclasses/testcase.jar DuplicateLVTT
pb = ProcessTools.createJavaProcessBuilder("-cp", jarFile, "DuplicateLVTT"); pb = ProcessTools.createJavaProcessBuilder("DuplicateLVTT");
new OutputAnalyzer(pb.start()) new OutputAnalyzer(pb.start())
.shouldContain("Duplicated LocalVariableTypeTable attribute entry for 'list' in class file DuplicateLVTT") .shouldContain("Duplicated LocalVariableTypeTable attribute entry for 'list' in class file DuplicateLVTT")
.shouldHaveExitValue(1); .shouldHaveExitValue(1);
// java -cp $testclasses/testcase.jar NotFoundLVTT // java -cp $testclasses/testcase.jar NotFoundLVTT
pb = ProcessTools.createJavaProcessBuilder("-cp", jarFile, "NotFoundLVTT"); pb = ProcessTools.createJavaProcessBuilder("NotFoundLVTT");
new OutputAnalyzer(pb.start()) new OutputAnalyzer(pb.start())
.shouldContain("LVTT entry for 'list' in class file NotFoundLVTT does not match any LVT entry") .shouldContain("LVTT entry for 'list' in class file NotFoundLVTT does not match any LVT entry")
.shouldHaveExitValue(1); .shouldHaveExitValue(1);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,7 +24,7 @@
/* /*
* @test Test7116786 * @test Test7116786
* @summary verify that VerifyError messages are as expected * @summary verify that VerifyError messages are as expected
* @library testcases.jar * @compile testcases.jcod
* @run main/othervm -Xverify:all Test7116786 * @run main/othervm -Xverify:all Test7116786
*/ */

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,6 +28,7 @@
* @summary Check for exception instead of assert. * @summary Check for exception instead of assert.
* @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.misc
* java.management * java.management
* @compile LambdaMath.jcod
* @run main ClassFileParserBug * @run main ClassFileParserBug
*/ */
@ -39,9 +40,7 @@ public class ClassFileParserBug {
public static void main(String args[]) throws Throwable { public static void main(String args[]) throws Throwable {
System.out.println("Regression test for bug 8040018"); System.out.println("Regression test for bug 8040018");
String testsrc = System.getProperty("test.src") + "/"; ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("LambdaMath");
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-jar", testsrc + File.separator + "test.jar");
OutputAnalyzer output = new OutputAnalyzer(pb.start()); OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("java.lang.ClassFormatError: Bad length on BootstrapMethods"); output.shouldContain("java.lang.ClassFormatError: Bad length on BootstrapMethods");
output.shouldHaveExitValue(1); output.shouldHaveExitValue(1);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,25 +28,18 @@
* @summary Test empty bootstrap_methods table within BootstrapMethods attribute * @summary Test empty bootstrap_methods table within BootstrapMethods attribute
* @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.misc
* java.management * java.management
* @compile TestEmptyBootstrapMethodsAttr.java * @compile emptynumbootstrapmethods1.jcod emptynumbootstrapmethods2.jcod
* @run main TestEmptyBootstrapMethodsAttr * @run main TestEmptyBootstrapMethodsAttr
*/ */
import java.io.File; import java.io.File;
import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.JDKToolFinder;
public class TestEmptyBootstrapMethodsAttr { public class TestEmptyBootstrapMethodsAttr {
public static void main(String args[]) throws Throwable { public static void main(String args[]) throws Throwable {
System.out.println("Regression test for bug 8041918"); System.out.println("Regression test for bug 8041918");
String jarFile = System.getProperty("test.src") + File.separator + "emptynumbootstrapmethods.jar";
// ====== extract the test case
ProcessBuilder pb = new ProcessBuilder(new String[] { JDKToolFinder.getJDKTool("jar"), "xvf", jarFile } );
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
// Test case #1: // Test case #1:
// Try loading class with empty bootstrap_methods table where no // Try loading class with empty bootstrap_methods table where no
@ -56,8 +49,8 @@ public class TestEmptyBootstrapMethodsAttr {
// ======= execute test case #1 // ======= execute test case #1
// Expect a lack of main method, this implies that the class loaded correctly // Expect a lack of main method, this implies that the class loaded correctly
// with an empty bootstrap_methods and did not generate a ClassFormatError. // with an empty bootstrap_methods and did not generate a ClassFormatError.
pb = ProcessTools.createJavaProcessBuilder("-cp", ".", className); ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(className);
output = new OutputAnalyzer(pb.start()); OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldNotContain("java.lang.ClassFormatError"); output.shouldNotContain("java.lang.ClassFormatError");
output.shouldContain("Main method not found in class " + className); output.shouldContain("Main method not found in class " + className);
output.shouldHaveExitValue(1); output.shouldHaveExitValue(1);
@ -70,7 +63,7 @@ public class TestEmptyBootstrapMethodsAttr {
// ======= execute test case #2 // ======= execute test case #2
// Expect a lack of main method, this implies that the class loaded correctly // Expect a lack of main method, this implies that the class loaded correctly
// with an empty bootstrap_methods and did not generate ClassFormatError. // with an empty bootstrap_methods and did not generate ClassFormatError.
pb = ProcessTools.createJavaProcessBuilder("-cp", ".", className); pb = ProcessTools.createJavaProcessBuilder(className);
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
output.shouldNotContain("java.lang.ClassFormatError"); output.shouldNotContain("java.lang.ClassFormatError");
output.shouldContain("Main method not found in class " + className); output.shouldContain("Main method not found in class " + className);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,6 +28,7 @@
* @summary Throw exceptions when duplicate attributes are detected. * @summary Throw exceptions when duplicate attributes are detected.
* @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.misc
* java.management * java.management
* @compile DuplAttributes.jcod
* @run main DuplAttributesTest * @run main DuplAttributesTest
*/ */
@ -40,8 +41,7 @@ public class DuplAttributesTest {
static final String testsrc = System.getProperty("test.src"); static final String testsrc = System.getProperty("test.src");
public static void runTest(String test, String result) throws Throwable { public static void runTest(String test, String result) throws Throwable {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(test);
"-cp", testsrc + File.separator + "test.jar", test);
OutputAnalyzer output = new OutputAnalyzer(pb.start()); OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("java.lang.ClassFormatError: Multiple " + result); output.shouldContain("java.lang.ClassFormatError: Multiple " + result);
} }