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.
*
* This code is free software; you can redistribute it and/or modify it
@ -28,6 +28,7 @@
* @summary Check attribute_length of EnclosingMethod attribute
* @modules java.base/jdk.internal.misc
* java.management
* @compile EnclMethTest.jcod
* @run main EnclMethodAttr
*/
@ -41,8 +42,7 @@ public class EnclMethodAttr {
public static void main(String args[]) throws Throwable {
System.out.println("Regression test for bug 8044738");
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-jar", testsrc + File.separator + "enclMethodAttr.jar");
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("EnclMethTest");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
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.
*
* 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.
*
* 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.
*
* 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.
*
* This code is free software; you can redistribute it and/or modify it
@ -28,6 +28,7 @@
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @compile DuplicateLVT.jcod DuplicateLVTT.jcod NotFoundLVTT.jcod
* @compile -g -XDignore.symbol.file TestLVT.java
* @run main TestLVT
*/
@ -43,19 +44,19 @@ public class TestLVT {
String jarFile = System.getProperty("test.src") + "/testcase.jar";
// java -cp $testSrc/testcase.jar DuplicateLVT
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-cp", jarFile, "DuplicateLVT");
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("DuplicateLVT");
new OutputAnalyzer(pb.start())
.shouldContain("Duplicated LocalVariableTable attribute entry for 'by' in class file DuplicateLVT")
.shouldHaveExitValue(1);
// java -cp $testclasses/testcase.jar DuplicateLVTT
pb = ProcessTools.createJavaProcessBuilder("-cp", jarFile, "DuplicateLVTT");
pb = ProcessTools.createJavaProcessBuilder("DuplicateLVTT");
new OutputAnalyzer(pb.start())
.shouldContain("Duplicated LocalVariableTypeTable attribute entry for 'list' in class file DuplicateLVTT")
.shouldHaveExitValue(1);
// java -cp $testclasses/testcase.jar NotFoundLVTT
pb = ProcessTools.createJavaProcessBuilder("-cp", jarFile, "NotFoundLVTT");
pb = ProcessTools.createJavaProcessBuilder("NotFoundLVTT");
new OutputAnalyzer(pb.start())
.shouldContain("LVTT entry for 'list' in class file NotFoundLVTT does not match any LVT entry")
.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.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,7 +24,7 @@
/*
* @test Test7116786
* @summary verify that VerifyError messages are as expected
* @library testcases.jar
* @compile testcases.jcod
* @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.
*
* This code is free software; you can redistribute it and/or modify it
@ -28,6 +28,7 @@
* @summary Check for exception instead of assert.
* @modules java.base/jdk.internal.misc
* java.management
* @compile LambdaMath.jcod
* @run main ClassFileParserBug
*/
@ -39,9 +40,7 @@ public class ClassFileParserBug {
public static void main(String args[]) throws Throwable {
System.out.println("Regression test for bug 8040018");
String testsrc = System.getProperty("test.src") + "/";
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-jar", testsrc + File.separator + "test.jar");
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("LambdaMath");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("java.lang.ClassFormatError: Bad length on BootstrapMethods");
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.
*
* 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
* @modules java.base/jdk.internal.misc
* java.management
* @compile TestEmptyBootstrapMethodsAttr.java
* @compile emptynumbootstrapmethods1.jcod emptynumbootstrapmethods2.jcod
* @run main TestEmptyBootstrapMethodsAttr
*/
import java.io.File;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.JDKToolFinder;
public class TestEmptyBootstrapMethodsAttr {
public static void main(String args[]) throws Throwable {
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:
// Try loading class with empty bootstrap_methods table where no
@ -56,8 +49,8 @@ public class TestEmptyBootstrapMethodsAttr {
// ======= execute test case #1
// Expect a lack of main method, this implies that the class loaded correctly
// with an empty bootstrap_methods and did not generate a ClassFormatError.
pb = ProcessTools.createJavaProcessBuilder("-cp", ".", className);
output = new OutputAnalyzer(pb.start());
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(className);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldNotContain("java.lang.ClassFormatError");
output.shouldContain("Main method not found in class " + className);
output.shouldHaveExitValue(1);
@ -70,7 +63,7 @@ public class TestEmptyBootstrapMethodsAttr {
// ======= execute test case #2
// Expect a lack of main method, this implies that the class loaded correctly
// 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.shouldNotContain("java.lang.ClassFormatError");
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.
*
* 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.
* @modules java.base/jdk.internal.misc
* java.management
* @compile DuplAttributes.jcod
* @run main DuplAttributesTest
*/
@ -40,8 +41,7 @@ public class DuplAttributesTest {
static final String testsrc = System.getProperty("test.src");
public static void runTest(String test, String result) throws Throwable {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-cp", testsrc + File.separator + "test.jar", test);
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(test);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("java.lang.ClassFormatError: Multiple " + result);
}