Skip to content

Commit b01026a

Browse files
committedApr 3, 2025
8353325: Rewrite appcds/methodHandles test cases to use CDSAppTester
Reviewed-by: ccheung
1 parent e2e1598 commit b01026a

17 files changed

+352
-1185
lines changed
 

Diff for: ‎test/hotspot/jtreg/TEST.groups

+1
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ hotspot_aot_classlinking = \
547547
-runtime/cds/appcds/jvmti \
548548
-runtime/cds/appcds/LambdaProxyClasslist.java \
549549
-runtime/cds/appcds/loaderConstraints/LoaderConstraintsTest.java \
550+
-runtime/cds/appcds/methodHandles \
550551
-runtime/cds/appcds/NestHostOldInf.java \
551552
-runtime/cds/appcds/OldClassTest.java \
552553
-runtime/cds/appcds/OldClassWithjsr.java \

Diff for: ‎test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/CDSMHTest_generate.sh

-136
This file was deleted.

Diff for: ‎test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesAsCollectorTest.java

-101
This file was deleted.

Diff for: ‎test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesCastFailureTest.java

-101
This file was deleted.

Diff for: ‎test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesGeneralTest.java

-101
This file was deleted.

Diff for: ‎test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesInvokersTest.java

-101
This file was deleted.

Diff for: ‎test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesPermuteArgumentsTest.java

-101
This file was deleted.

Diff for: ‎test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesSpreadArgumentsTest.java

-101
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -21,17 +21,23 @@
2121
# questions.
2222
#
2323

24-
echo "// --- start auto-generated"
24+
testnames=
25+
26+
testnames="$testnames MethodHandlesAsCollectorTest"
27+
testnames="$testnames MethodHandlesCastFailureTest"
28+
testnames="$testnames MethodHandlesGeneralTest"
29+
testnames="$testnames MethodHandlesInvokersTest"
30+
testnames="$testnames MethodHandlesPermuteArgumentsTest"
31+
testnames="$testnames MethodHandlesSpreadArgumentsTest"
2532

26-
testnames=( MethodHandlesGeneralTest MethodHandlesAsCollectorTest MethodHandlesCastFailureTest MethodHandlesInvokersTest MethodHandlesPermuteArgumentsTest MethodHandlesSpreadArgumentsTest )
2733
name_suffix='.java'
2834

29-
for i in "${testnames[@]}"
35+
for i in ${testnames}
3036
do
3137
fname="$i$name_suffix"
3238
cat << EOF > $fname
3339
/*
34-
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
40+
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
3541
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3642
*
3743
* This code is free software; you can redistribute it and/or modify it
@@ -55,88 +61,63 @@ do
5561
*/
5662
// this file is auto-generated by $0. Do not edit manually.
5763
64+
EOF
65+
66+
for w in AOT DYNAMIC STATIC; do
67+
id=$(echo "$w" | awk '{print tolower($0)}')
68+
69+
cat << EOF >> $fname
5870
/*
59-
* @test
60-
* @summary Run the $fname test in static CDS archive mode.
71+
* @test id=$id
72+
* @summary Run the $fname test in CDSAppTester::$w workflow.
6173
* @requires vm.cds & vm.compMode != "Xcomp"
74+
EOF
75+
76+
if test "$w" == "AOT"; then
77+
cat << EOF >> $fname
78+
* @requires vm.cds.supports.aot.class.linking
79+
* @comment work around JDK-8345635
80+
* @requires !vm.jvmci.enabled
81+
EOF
82+
fi
83+
84+
cat << EOF >> $fname
6285
* @comment Some of the tests run excessively slowly with -Xcomp. The original
6386
* tests aren't executed with -Xcomp in the CI pipeline, so let's exclude
6487
* the generated tests from -Xcomp execution as well.
6588
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
66-
* /test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes
6789
* @compile ../../../../../../jdk/java/lang/invoke/MethodHandlesTest.java
6890
* ../../../../../../lib/jdk/test/lib/Utils.java
6991
* ../../../../../../jdk/java/lang/invoke/$fname
7092
* ../../../../../../jdk/java/lang/invoke/remote/RemoteExample.java
7193
* ../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java
72-
* ../dynamicArchive/test-classes/TestMHApp.java
94+
EOF
95+
96+
if test "$w" == "DYNAMIC"; then
97+
98+
cat << EOF >> $fname
7399
* @build jdk.test.whitebox.WhiteBox
74100
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
75-
* @run junit/othervm/timeout=480 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. $i
101+
* @run junit/othervm/timeout=480 -Dcds.app.tester.workflow=$w -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. $i
76102
*/
103+
EOF
104+
else
105+
cat << EOF >> $fname
106+
* @run junit/othervm/timeout=480 -Dcds.app.tester.workflow=$w $i
107+
*/
108+
EOF
77109

78-
import org.junit.Test;
79-
80-
import java.io.File;
81-
import java.nio.file.Path;
110+
fi
111+
done
82112

83-
import jdk.test.lib.cds.CDSOptions;
84-
import jdk.test.lib.cds.CDSTestUtils;
85-
import jdk.test.lib.process.OutputAnalyzer;
86-
import jdk.test.lib.Platform;
113+
cat << EOF >> $fname
114+
import org.junit.Test;
87115
88116
public class $i {
89117
@Test
90118
public void test() throws Exception {
91-
testImpl();
92-
}
93-
94-
private static final String classDir = System.getProperty("test.classes");
95-
private static final String mainClass = "TestMHApp";
96-
private static final String javaClassPath = System.getProperty("java.class.path");
97-
private static final String ps = System.getProperty("path.separator");
98-
private static final String testPackageName = "test.java.lang.invoke";
99-
private static final String testClassName = "$i";
100-
101-
static void testImpl() throws Exception {
102-
String appJar = JarBuilder.build("MH", new File(classDir), null);
103-
String classList = testClassName + ".list";
104-
String archiveName = testClassName + ".jsa";
105-
// Disable VerifyDpendencies when running with debug build because
106-
// the test requires a lot more time to execute with the option enabled.
107-
String verifyOpt =
108-
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
109-
110-
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
111-
112-
String jars = appJar + ps + junitJar;
113-
114-
// dump class list
115-
CDSTestUtils.dumpClassList(classList, "-cp", jars, verifyOpt, mainClass,
116-
testPackageName + "." + testClassName);
117-
118-
// create archive with the class list
119-
CDSOptions opts = (new CDSOptions())
120-
.addPrefix("-XX:ExtraSharedClassListFile=" + classList,
121-
"-cp", jars,
122-
"-Xlog:class+load,cds")
123-
.setArchiveName(archiveName);
124-
OutputAnalyzer output = CDSTestUtils.createArchiveAndCheck(opts);
125-
if (testClassName.equals("MethodHandlesInvokersTest")) {
126-
output.shouldNotContain("Failed to generate LambdaForm holder classes. Is your classlist out of date?");
127-
}
128-
129-
// run with archive
130-
CDSOptions runOpts = (new CDSOptions())
131-
.addPrefix("-cp", jars, "-Xlog:class+load,cds=debug", verifyOpt)
132-
.setArchiveName(archiveName)
133-
.setUseVersion(false)
134-
.addSuffix(mainClass, testPackageName + "." + testClassName);
135-
output = CDSTestUtils.runWithArchive(runOpts);
136-
output.shouldMatch(".class.load. test.java.lang.invoke.$i[$][$]Lambda.*/0x.*source:.*shared.*objects.*file")
137-
.shouldHaveExitValue(0);
119+
JDKMethodHandlesTestRunner.test($i.class.getName());
138120
}
139121
}
140122
EOF
141123
done
142-
echo "// --- end auto-generated"

Diff for: ‎test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes/TestMHApp.java renamed to ‎test/hotspot/jtreg/runtime/cds/appcds/methodHandles/JDKMethodHandlesTestRunner.java

+75-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,19 +25,91 @@
2525
import java.lang.annotation.Annotation;
2626
import java.lang.reflect.InvocationTargetException;
2727
import java.lang.reflect.Method;
28+
import java.io.File;
29+
import java.nio.file.Path;
2830
import java.util.Arrays;
2931
import java.util.ArrayList;
3032
import java.util.List;
3133

32-
public class TestMHApp {
34+
import jdk.test.lib.cds.CDSAppTester;
35+
import jdk.test.lib.process.OutputAnalyzer;
36+
import jdk.test.lib.Platform;
37+
38+
import org.junit.Test;
39+
40+
// This class is for running the ../../../../../../jdk/java/lang/invoke/MethodHandles*java tests
41+
// using CDSAppTester
42+
public class JDKMethodHandlesTestRunner {
43+
private static final String classDir = System.getProperty("test.classes");
44+
private static final String mainClass = "TestMHApp";
45+
private static final String javaClassPath = System.getProperty("java.class.path");
46+
private static final String ps = System.getProperty("path.separator");
47+
private static final String testPackageName = "test.java.lang.invoke";
48+
49+
public static void test(String testClassName) throws Exception {
50+
String appJar = JarBuilder.build("MH", new File(classDir), null);
51+
String classList = testClassName + ".list";
52+
String archiveName = testClassName + ".jsa";
53+
// Disable VerifyDpendencies when running with debug build because
54+
// the test requires a lot more time to execute with the option enabled.
55+
String verifyOpt =
56+
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
57+
58+
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
59+
60+
String jars = appJar + ps + junitJar;
61+
62+
CDSAppTester tester = new CDSAppTester(testClassName) {
63+
@Override
64+
public String classpath(RunMode runMode) {
65+
return jars;
66+
}
67+
68+
@Override
69+
public String[] vmArgs(RunMode runMode) {
70+
if (runMode.isProductionRun()) {
71+
return new String[] {
72+
"-Xlog:class+load,cds=debug",
73+
verifyOpt,
74+
};
75+
} else {
76+
return new String[] {
77+
verifyOpt,
78+
};
79+
}
80+
}
81+
82+
@Override
83+
public String[] appCommandLine(RunMode runMode) {
84+
return new String[] {
85+
mainClass,
86+
testPackageName + "." + testClassName,
87+
};
88+
}
89+
90+
@Override
91+
public void checkExecution(OutputAnalyzer out, RunMode runMode) throws Exception {
92+
out.shouldHaveExitValue(0);
93+
if (runMode.isProductionRun()) {
94+
out.shouldMatch(".class.load. test.java.lang.invoke." + testClassName +
95+
"[$][$]Lambda.*/0x.*source:.*shared.*objects.*file");
96+
}
97+
}
98+
};
99+
100+
String workflow = System.getProperty("cds.app.tester.workflow");
101+
tester.run(workflow);
102+
}
103+
}
104+
105+
class TestMHApp {
33106
public static void main(String args[]) throws Exception {
34107
try {
35108
Class<?> testClass = Class.forName(args[0]);
36109
System.out.println(testClass);
37110
Object obj = testClass.newInstance();
38111
final List<Method> allMethods = new ArrayList<Method>(Arrays.asList(testClass.getDeclaredMethods()));
39112
for (final Method method : allMethods) {
40-
//System.out.println(method.toString());
41113
method.setAccessible(true);
42114
Annotation[] annotations = null;
43115
try {
@@ -63,7 +135,6 @@ public static void main(String args[]) throws Exception {
63135
System.out.println(iae.getCause());
64136
} catch (InvocationTargetException ite) {
65137
System.out.println("Got InvocationTargetException!!!");
66-
//System.out.println(ite.getCause());
67138
throw ite;
68139
}
69140
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,84 +24,60 @@
2424
// this file is auto-generated by CDSMHTest_generate.sh. Do not edit manually.
2525

2626
/*
27-
* @test
28-
* @summary Run the MethodHandlesAsCollectorTest.java test in static CDS archive mode.
27+
* @test id=aot
28+
* @summary Run the MethodHandlesAsCollectorTest.java test in CDSAppTester::AOT workflow.
29+
* @requires vm.cds & vm.compMode != "Xcomp"
30+
* @requires vm.cds.supports.aot.class.linking
31+
* @comment work around JDK-8345635
32+
* @requires !vm.jvmci.enabled
33+
* @comment Some of the tests run excessively slowly with -Xcomp. The original
34+
* tests aren't executed with -Xcomp in the CI pipeline, so let's exclude
35+
* the generated tests from -Xcomp execution as well.
36+
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
37+
* @compile ../../../../../../jdk/java/lang/invoke/MethodHandlesTest.java
38+
* ../../../../../../lib/jdk/test/lib/Utils.java
39+
* ../../../../../../jdk/java/lang/invoke/MethodHandlesAsCollectorTest.java
40+
* ../../../../../../jdk/java/lang/invoke/remote/RemoteExample.java
41+
* ../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java
42+
* @run junit/othervm/timeout=480 -Dcds.app.tester.workflow=AOT MethodHandlesAsCollectorTest
43+
*/
44+
/*
45+
* @test id=dynamic
46+
* @summary Run the MethodHandlesAsCollectorTest.java test in CDSAppTester::DYNAMIC workflow.
2947
* @requires vm.cds & vm.compMode != "Xcomp"
3048
* @comment Some of the tests run excessively slowly with -Xcomp. The original
3149
* tests aren't executed with -Xcomp in the CI pipeline, so let's exclude
3250
* the generated tests from -Xcomp execution as well.
3351
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
34-
* /test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes
3552
* @compile ../../../../../../jdk/java/lang/invoke/MethodHandlesTest.java
3653
* ../../../../../../lib/jdk/test/lib/Utils.java
3754
* ../../../../../../jdk/java/lang/invoke/MethodHandlesAsCollectorTest.java
3855
* ../../../../../../jdk/java/lang/invoke/remote/RemoteExample.java
3956
* ../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java
40-
* ../dynamicArchive/test-classes/TestMHApp.java
4157
* @build jdk.test.whitebox.WhiteBox
4258
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
43-
* @run junit/othervm/timeout=480 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesAsCollectorTest
59+
* @run junit/othervm/timeout=480 -Dcds.app.tester.workflow=DYNAMIC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesAsCollectorTest
60+
*/
61+
/*
62+
* @test id=static
63+
* @summary Run the MethodHandlesAsCollectorTest.java test in CDSAppTester::STATIC workflow.
64+
* @requires vm.cds & vm.compMode != "Xcomp"
65+
* @comment Some of the tests run excessively slowly with -Xcomp. The original
66+
* tests aren't executed with -Xcomp in the CI pipeline, so let's exclude
67+
* the generated tests from -Xcomp execution as well.
68+
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
69+
* @compile ../../../../../../jdk/java/lang/invoke/MethodHandlesTest.java
70+
* ../../../../../../lib/jdk/test/lib/Utils.java
71+
* ../../../../../../jdk/java/lang/invoke/MethodHandlesAsCollectorTest.java
72+
* ../../../../../../jdk/java/lang/invoke/remote/RemoteExample.java
73+
* ../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java
74+
* @run junit/othervm/timeout=480 -Dcds.app.tester.workflow=STATIC MethodHandlesAsCollectorTest
4475
*/
45-
4676
import org.junit.Test;
4777

48-
import java.io.File;
49-
import java.nio.file.Path;
50-
51-
import jdk.test.lib.cds.CDSOptions;
52-
import jdk.test.lib.cds.CDSTestUtils;
53-
import jdk.test.lib.process.OutputAnalyzer;
54-
import jdk.test.lib.Platform;
55-
5678
public class MethodHandlesAsCollectorTest {
5779
@Test
5880
public void test() throws Exception {
59-
testImpl();
60-
}
61-
62-
private static final String classDir = System.getProperty("test.classes");
63-
private static final String mainClass = "TestMHApp";
64-
private static final String javaClassPath = System.getProperty("java.class.path");
65-
private static final String ps = System.getProperty("path.separator");
66-
private static final String testPackageName = "test.java.lang.invoke";
67-
private static final String testClassName = "MethodHandlesAsCollectorTest";
68-
69-
static void testImpl() throws Exception {
70-
String appJar = JarBuilder.build("MH", new File(classDir), null);
71-
String classList = testClassName + ".list";
72-
String archiveName = testClassName + ".jsa";
73-
// Disable VerifyDpendencies when running with debug build because
74-
// the test requires a lot more time to execute with the option enabled.
75-
String verifyOpt =
76-
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
77-
78-
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
79-
80-
String jars = appJar + ps + junitJar;
81-
82-
// dump class list
83-
CDSTestUtils.dumpClassList(classList, "-cp", jars, verifyOpt, mainClass,
84-
testPackageName + "." + testClassName);
85-
86-
// create archive with the class list
87-
CDSOptions opts = (new CDSOptions())
88-
.addPrefix("-XX:ExtraSharedClassListFile=" + classList,
89-
"-cp", jars,
90-
"-Xlog:class+load,cds")
91-
.setArchiveName(archiveName);
92-
OutputAnalyzer output = CDSTestUtils.createArchiveAndCheck(opts);
93-
if (testClassName.equals("MethodHandlesInvokersTest")) {
94-
output.shouldNotContain("Failed to generate LambdaForm holder classes. Is your classlist out of date?");
95-
}
96-
97-
// run with archive
98-
CDSOptions runOpts = (new CDSOptions())
99-
.addPrefix("-cp", jars, "-Xlog:class+load,cds=debug", verifyOpt)
100-
.setArchiveName(archiveName)
101-
.setUseVersion(false)
102-
.addSuffix(mainClass, testPackageName + "." + testClassName);
103-
output = CDSTestUtils.runWithArchive(runOpts);
104-
output.shouldMatch(".class.load. test.java.lang.invoke.MethodHandlesAsCollectorTest[$][$]Lambda.*/0x.*source:.*shared.*objects.*file")
105-
.shouldHaveExitValue(0);
81+
JDKMethodHandlesTestRunner.test(MethodHandlesAsCollectorTest.class.getName());
10682
}
10783
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,84 +24,60 @@
2424
// this file is auto-generated by CDSMHTest_generate.sh. Do not edit manually.
2525

2626
/*
27-
* @test
28-
* @summary Run the MethodHandlesCastFailureTest.java test in static CDS archive mode.
27+
* @test id=aot
28+
* @summary Run the MethodHandlesCastFailureTest.java test in CDSAppTester::AOT workflow.
29+
* @requires vm.cds & vm.compMode != "Xcomp"
30+
* @requires vm.cds.supports.aot.class.linking
31+
* @comment work around JDK-8345635
32+
* @requires !vm.jvmci.enabled
33+
* @comment Some of the tests run excessively slowly with -Xcomp. The original
34+
* tests aren't executed with -Xcomp in the CI pipeline, so let's exclude
35+
* the generated tests from -Xcomp execution as well.
36+
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
37+
* @compile ../../../../../../jdk/java/lang/invoke/MethodHandlesTest.java
38+
* ../../../../../../lib/jdk/test/lib/Utils.java
39+
* ../../../../../../jdk/java/lang/invoke/MethodHandlesCastFailureTest.java
40+
* ../../../../../../jdk/java/lang/invoke/remote/RemoteExample.java
41+
* ../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java
42+
* @run junit/othervm/timeout=480 -Dcds.app.tester.workflow=AOT MethodHandlesCastFailureTest
43+
*/
44+
/*
45+
* @test id=dynamic
46+
* @summary Run the MethodHandlesCastFailureTest.java test in CDSAppTester::DYNAMIC workflow.
2947
* @requires vm.cds & vm.compMode != "Xcomp"
3048
* @comment Some of the tests run excessively slowly with -Xcomp. The original
3149
* tests aren't executed with -Xcomp in the CI pipeline, so let's exclude
3250
* the generated tests from -Xcomp execution as well.
3351
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
34-
* /test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes
3552
* @compile ../../../../../../jdk/java/lang/invoke/MethodHandlesTest.java
3653
* ../../../../../../lib/jdk/test/lib/Utils.java
3754
* ../../../../../../jdk/java/lang/invoke/MethodHandlesCastFailureTest.java
3855
* ../../../../../../jdk/java/lang/invoke/remote/RemoteExample.java
3956
* ../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java
40-
* ../dynamicArchive/test-classes/TestMHApp.java
4157
* @build jdk.test.whitebox.WhiteBox
4258
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
43-
* @run junit/othervm/timeout=480 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesCastFailureTest
59+
* @run junit/othervm/timeout=480 -Dcds.app.tester.workflow=DYNAMIC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesCastFailureTest
60+
*/
61+
/*
62+
* @test id=static
63+
* @summary Run the MethodHandlesCastFailureTest.java test in CDSAppTester::STATIC workflow.
64+
* @requires vm.cds & vm.compMode != "Xcomp"
65+
* @comment Some of the tests run excessively slowly with -Xcomp. The original
66+
* tests aren't executed with -Xcomp in the CI pipeline, so let's exclude
67+
* the generated tests from -Xcomp execution as well.
68+
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
69+
* @compile ../../../../../../jdk/java/lang/invoke/MethodHandlesTest.java
70+
* ../../../../../../lib/jdk/test/lib/Utils.java
71+
* ../../../../../../jdk/java/lang/invoke/MethodHandlesCastFailureTest.java
72+
* ../../../../../../jdk/java/lang/invoke/remote/RemoteExample.java
73+
* ../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java
74+
* @run junit/othervm/timeout=480 -Dcds.app.tester.workflow=STATIC MethodHandlesCastFailureTest
4475
*/
45-
4676
import org.junit.Test;
4777

48-
import java.io.File;
49-
import java.nio.file.Path;
50-
51-
import jdk.test.lib.cds.CDSOptions;
52-
import jdk.test.lib.cds.CDSTestUtils;
53-
import jdk.test.lib.process.OutputAnalyzer;
54-
import jdk.test.lib.Platform;
55-
5678
public class MethodHandlesCastFailureTest {
5779
@Test
5880
public void test() throws Exception {
59-
testImpl();
60-
}
61-
62-
private static final String classDir = System.getProperty("test.classes");
63-
private static final String mainClass = "TestMHApp";
64-
private static final String javaClassPath = System.getProperty("java.class.path");
65-
private static final String ps = System.getProperty("path.separator");
66-
private static final String testPackageName = "test.java.lang.invoke";
67-
private static final String testClassName = "MethodHandlesCastFailureTest";
68-
69-
static void testImpl() throws Exception {
70-
String appJar = JarBuilder.build("MH", new File(classDir), null);
71-
String classList = testClassName + ".list";
72-
String archiveName = testClassName + ".jsa";
73-
// Disable VerifyDpendencies when running with debug build because
74-
// the test requires a lot more time to execute with the option enabled.
75-
String verifyOpt =
76-
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
77-
78-
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
79-
80-
String jars = appJar + ps + junitJar;
81-
82-
// dump class list
83-
CDSTestUtils.dumpClassList(classList, "-cp", jars, verifyOpt, mainClass,
84-
testPackageName + "." + testClassName);
85-
86-
// create archive with the class list
87-
CDSOptions opts = (new CDSOptions())
88-
.addPrefix("-XX:ExtraSharedClassListFile=" + classList,
89-
"-cp", jars,
90-
"-Xlog:class+load,cds")
91-
.setArchiveName(archiveName);
92-
OutputAnalyzer output = CDSTestUtils.createArchiveAndCheck(opts);
93-
if (testClassName.equals("MethodHandlesInvokersTest")) {
94-
output.shouldNotContain("Failed to generate LambdaForm holder classes. Is your classlist out of date?");
95-
}
96-
97-
// run with archive
98-
CDSOptions runOpts = (new CDSOptions())
99-
.addPrefix("-cp", jars, "-Xlog:class+load,cds=debug", verifyOpt)
100-
.setArchiveName(archiveName)
101-
.setUseVersion(false)
102-
.addSuffix(mainClass, testPackageName + "." + testClassName);
103-
output = CDSTestUtils.runWithArchive(runOpts);
104-
output.shouldMatch(".class.load. test.java.lang.invoke.MethodHandlesCastFailureTest[$][$]Lambda.*/0x.*source:.*shared.*objects.*file")
105-
.shouldHaveExitValue(0);
81+
JDKMethodHandlesTestRunner.test(MethodHandlesCastFailureTest.class.getName());
10682
}
10783
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,84 +24,60 @@
2424
// this file is auto-generated by CDSMHTest_generate.sh. Do not edit manually.
2525

2626
/*
27-
* @test
28-
* @summary Run the MethodHandlesGeneralTest.java test in static CDS archive mode.
27+
* @test id=aot
28+
* @summary Run the MethodHandlesGeneralTest.java test in CDSAppTester::AOT workflow.
29+
* @requires vm.cds & vm.compMode != "Xcomp"
30+
* @requires vm.cds.supports.aot.class.linking
31+
* @comment work around JDK-8345635
32+
* @requires !vm.jvmci.enabled
33+
* @comment Some of the tests run excessively slowly with -Xcomp. The original
34+
* tests aren't executed with -Xcomp in the CI pipeline, so let's exclude
35+
* the generated tests from -Xcomp execution as well.
36+
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
37+
* @compile ../../../../../../jdk/java/lang/invoke/MethodHandlesTest.java
38+
* ../../../../../../lib/jdk/test/lib/Utils.java
39+
* ../../../../../../jdk/java/lang/invoke/MethodHandlesGeneralTest.java
40+
* ../../../../../../jdk/java/lang/invoke/remote/RemoteExample.java
41+
* ../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java
42+
* @run junit/othervm/timeout=480 -Dcds.app.tester.workflow=AOT MethodHandlesGeneralTest
43+
*/
44+
/*
45+
* @test id=dynamic
46+
* @summary Run the MethodHandlesGeneralTest.java test in CDSAppTester::DYNAMIC workflow.
2947
* @requires vm.cds & vm.compMode != "Xcomp"
3048
* @comment Some of the tests run excessively slowly with -Xcomp. The original
3149
* tests aren't executed with -Xcomp in the CI pipeline, so let's exclude
3250
* the generated tests from -Xcomp execution as well.
3351
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
34-
* /test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes
3552
* @compile ../../../../../../jdk/java/lang/invoke/MethodHandlesTest.java
3653
* ../../../../../../lib/jdk/test/lib/Utils.java
3754
* ../../../../../../jdk/java/lang/invoke/MethodHandlesGeneralTest.java
3855
* ../../../../../../jdk/java/lang/invoke/remote/RemoteExample.java
3956
* ../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java
40-
* ../dynamicArchive/test-classes/TestMHApp.java
4157
* @build jdk.test.whitebox.WhiteBox
4258
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
43-
* @run junit/othervm/timeout=480 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesGeneralTest
59+
* @run junit/othervm/timeout=480 -Dcds.app.tester.workflow=DYNAMIC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesGeneralTest
60+
*/
61+
/*
62+
* @test id=static
63+
* @summary Run the MethodHandlesGeneralTest.java test in CDSAppTester::STATIC workflow.
64+
* @requires vm.cds & vm.compMode != "Xcomp"
65+
* @comment Some of the tests run excessively slowly with -Xcomp. The original
66+
* tests aren't executed with -Xcomp in the CI pipeline, so let's exclude
67+
* the generated tests from -Xcomp execution as well.
68+
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
69+
* @compile ../../../../../../jdk/java/lang/invoke/MethodHandlesTest.java
70+
* ../../../../../../lib/jdk/test/lib/Utils.java
71+
* ../../../../../../jdk/java/lang/invoke/MethodHandlesGeneralTest.java
72+
* ../../../../../../jdk/java/lang/invoke/remote/RemoteExample.java
73+
* ../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java
74+
* @run junit/othervm/timeout=480 -Dcds.app.tester.workflow=STATIC MethodHandlesGeneralTest
4475
*/
45-
4676
import org.junit.Test;
4777

48-
import java.io.File;
49-
import java.nio.file.Path;
50-
51-
import jdk.test.lib.cds.CDSOptions;
52-
import jdk.test.lib.cds.CDSTestUtils;
53-
import jdk.test.lib.process.OutputAnalyzer;
54-
import jdk.test.lib.Platform;
55-
5678
public class MethodHandlesGeneralTest {
5779
@Test
5880
public void test() throws Exception {
59-
testImpl();
60-
}
61-
62-
private static final String classDir = System.getProperty("test.classes");
63-
private static final String mainClass = "TestMHApp";
64-
private static final String javaClassPath = System.getProperty("java.class.path");
65-
private static final String ps = System.getProperty("path.separator");
66-
private static final String testPackageName = "test.java.lang.invoke";
67-
private static final String testClassName = "MethodHandlesGeneralTest";
68-
69-
static void testImpl() throws Exception {
70-
String appJar = JarBuilder.build("MH", new File(classDir), null);
71-
String classList = testClassName + ".list";
72-
String archiveName = testClassName + ".jsa";
73-
// Disable VerifyDpendencies when running with debug build because
74-
// the test requires a lot more time to execute with the option enabled.
75-
String verifyOpt =
76-
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
77-
78-
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
79-
80-
String jars = appJar + ps + junitJar;
81-
82-
// dump class list
83-
CDSTestUtils.dumpClassList(classList, "-cp", jars, verifyOpt, mainClass,
84-
testPackageName + "." + testClassName);
85-
86-
// create archive with the class list
87-
CDSOptions opts = (new CDSOptions())
88-
.addPrefix("-XX:ExtraSharedClassListFile=" + classList,
89-
"-cp", jars,
90-
"-Xlog:class+load,cds")
91-
.setArchiveName(archiveName);
92-
OutputAnalyzer output = CDSTestUtils.createArchiveAndCheck(opts);
93-
if (testClassName.equals("MethodHandlesInvokersTest")) {
94-
output.shouldNotContain("Failed to generate LambdaForm holder classes. Is your classlist out of date?");
95-
}
96-
97-
// run with archive
98-
CDSOptions runOpts = (new CDSOptions())
99-
.addPrefix("-cp", jars, "-Xlog:class+load,cds=debug", verifyOpt)
100-
.setArchiveName(archiveName)
101-
.setUseVersion(false)
102-
.addSuffix(mainClass, testPackageName + "." + testClassName);
103-
output = CDSTestUtils.runWithArchive(runOpts);
104-
output.shouldMatch(".class.load. test.java.lang.invoke.MethodHandlesGeneralTest[$][$]Lambda.*/0x.*source:.*shared.*objects.*file")
105-
.shouldHaveExitValue(0);
81+
JDKMethodHandlesTestRunner.test(MethodHandlesGeneralTest.class.getName());
10682
}
10783
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,84 +24,60 @@
2424
// this file is auto-generated by CDSMHTest_generate.sh. Do not edit manually.
2525

2626
/*
27-
* @test
28-
* @summary Run the MethodHandlesInvokersTest.java test in static CDS archive mode.
27+
* @test id=aot
28+
* @summary Run the MethodHandlesInvokersTest.java test in CDSAppTester::AOT workflow.
29+
* @requires vm.cds & vm.compMode != "Xcomp"
30+
* @requires vm.cds.supports.aot.class.linking
31+
* @comment work around JDK-8345635
32+
* @requires !vm.jvmci.enabled
33+
* @comment Some of the tests run excessively slowly with -Xcomp. The original
34+
* tests aren't executed with -Xcomp in the CI pipeline, so let's exclude
35+
* the generated tests from -Xcomp execution as well.
36+
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
37+
* @compile ../../../../../../jdk/java/lang/invoke/MethodHandlesTest.java
38+
* ../../../../../../lib/jdk/test/lib/Utils.java
39+
* ../../../../../../jdk/java/lang/invoke/MethodHandlesInvokersTest.java
40+
* ../../../../../../jdk/java/lang/invoke/remote/RemoteExample.java
41+
* ../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java
42+
* @run junit/othervm/timeout=480 -Dcds.app.tester.workflow=AOT MethodHandlesInvokersTest
43+
*/
44+
/*
45+
* @test id=dynamic
46+
* @summary Run the MethodHandlesInvokersTest.java test in CDSAppTester::DYNAMIC workflow.
2947
* @requires vm.cds & vm.compMode != "Xcomp"
3048
* @comment Some of the tests run excessively slowly with -Xcomp. The original
3149
* tests aren't executed with -Xcomp in the CI pipeline, so let's exclude
3250
* the generated tests from -Xcomp execution as well.
3351
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
34-
* /test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes
3552
* @compile ../../../../../../jdk/java/lang/invoke/MethodHandlesTest.java
3653
* ../../../../../../lib/jdk/test/lib/Utils.java
3754
* ../../../../../../jdk/java/lang/invoke/MethodHandlesInvokersTest.java
3855
* ../../../../../../jdk/java/lang/invoke/remote/RemoteExample.java
3956
* ../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java
40-
* ../dynamicArchive/test-classes/TestMHApp.java
4157
* @build jdk.test.whitebox.WhiteBox
4258
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
43-
* @run junit/othervm/timeout=480 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesInvokersTest
59+
* @run junit/othervm/timeout=480 -Dcds.app.tester.workflow=DYNAMIC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesInvokersTest
60+
*/
61+
/*
62+
* @test id=static
63+
* @summary Run the MethodHandlesInvokersTest.java test in CDSAppTester::STATIC workflow.
64+
* @requires vm.cds & vm.compMode != "Xcomp"
65+
* @comment Some of the tests run excessively slowly with -Xcomp. The original
66+
* tests aren't executed with -Xcomp in the CI pipeline, so let's exclude
67+
* the generated tests from -Xcomp execution as well.
68+
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
69+
* @compile ../../../../../../jdk/java/lang/invoke/MethodHandlesTest.java
70+
* ../../../../../../lib/jdk/test/lib/Utils.java
71+
* ../../../../../../jdk/java/lang/invoke/MethodHandlesInvokersTest.java
72+
* ../../../../../../jdk/java/lang/invoke/remote/RemoteExample.java
73+
* ../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java
74+
* @run junit/othervm/timeout=480 -Dcds.app.tester.workflow=STATIC MethodHandlesInvokersTest
4475
*/
45-
4676
import org.junit.Test;
4777

48-
import java.io.File;
49-
import java.nio.file.Path;
50-
51-
import jdk.test.lib.cds.CDSOptions;
52-
import jdk.test.lib.cds.CDSTestUtils;
53-
import jdk.test.lib.process.OutputAnalyzer;
54-
import jdk.test.lib.Platform;
55-
5678
public class MethodHandlesInvokersTest {
5779
@Test
5880
public void test() throws Exception {
59-
testImpl();
60-
}
61-
62-
private static final String classDir = System.getProperty("test.classes");
63-
private static final String mainClass = "TestMHApp";
64-
private static final String javaClassPath = System.getProperty("java.class.path");
65-
private static final String ps = System.getProperty("path.separator");
66-
private static final String testPackageName = "test.java.lang.invoke";
67-
private static final String testClassName = "MethodHandlesInvokersTest";
68-
69-
static void testImpl() throws Exception {
70-
String appJar = JarBuilder.build("MH", new File(classDir), null);
71-
String classList = testClassName + ".list";
72-
String archiveName = testClassName + ".jsa";
73-
// Disable VerifyDpendencies when running with debug build because
74-
// the test requires a lot more time to execute with the option enabled.
75-
String verifyOpt =
76-
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
77-
78-
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
79-
80-
String jars = appJar + ps + junitJar;
81-
82-
// dump class list
83-
CDSTestUtils.dumpClassList(classList, "-cp", jars, verifyOpt, mainClass,
84-
testPackageName + "." + testClassName);
85-
86-
// create archive with the class list
87-
CDSOptions opts = (new CDSOptions())
88-
.addPrefix("-XX:ExtraSharedClassListFile=" + classList,
89-
"-cp", jars,
90-
"-Xlog:class+load,cds")
91-
.setArchiveName(archiveName);
92-
OutputAnalyzer output = CDSTestUtils.createArchiveAndCheck(opts);
93-
if (testClassName.equals("MethodHandlesInvokersTest")) {
94-
output.shouldNotContain("Failed to generate LambdaForm holder classes. Is your classlist out of date?");
95-
}
96-
97-
// run with archive
98-
CDSOptions runOpts = (new CDSOptions())
99-
.addPrefix("-cp", jars, "-Xlog:class+load,cds=debug", verifyOpt)
100-
.setArchiveName(archiveName)
101-
.setUseVersion(false)
102-
.addSuffix(mainClass, testPackageName + "." + testClassName);
103-
output = CDSTestUtils.runWithArchive(runOpts);
104-
output.shouldMatch(".class.load. test.java.lang.invoke.MethodHandlesInvokersTest[$][$]Lambda.*/0x.*source:.*shared.*objects.*file")
105-
.shouldHaveExitValue(0);
81+
JDKMethodHandlesTestRunner.test(MethodHandlesInvokersTest.class.getName());
10682
}
10783
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,84 +24,60 @@
2424
// this file is auto-generated by CDSMHTest_generate.sh. Do not edit manually.
2525

2626
/*
27-
* @test
28-
* @summary Run the MethodHandlesPermuteArgumentsTest.java test in static CDS archive mode.
27+
* @test id=aot
28+
* @summary Run the MethodHandlesPermuteArgumentsTest.java test in CDSAppTester::AOT workflow.
29+
* @requires vm.cds & vm.compMode != "Xcomp"
30+
* @requires vm.cds.supports.aot.class.linking
31+
* @comment work around JDK-8345635
32+
* @requires !vm.jvmci.enabled
33+
* @comment Some of the tests run excessively slowly with -Xcomp. The original
34+
* tests aren't executed with -Xcomp in the CI pipeline, so let's exclude
35+
* the generated tests from -Xcomp execution as well.
36+
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
37+
* @compile ../../../../../../jdk/java/lang/invoke/MethodHandlesTest.java
38+
* ../../../../../../lib/jdk/test/lib/Utils.java
39+
* ../../../../../../jdk/java/lang/invoke/MethodHandlesPermuteArgumentsTest.java
40+
* ../../../../../../jdk/java/lang/invoke/remote/RemoteExample.java
41+
* ../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java
42+
* @run junit/othervm/timeout=480 -Dcds.app.tester.workflow=AOT MethodHandlesPermuteArgumentsTest
43+
*/
44+
/*
45+
* @test id=dynamic
46+
* @summary Run the MethodHandlesPermuteArgumentsTest.java test in CDSAppTester::DYNAMIC workflow.
2947
* @requires vm.cds & vm.compMode != "Xcomp"
3048
* @comment Some of the tests run excessively slowly with -Xcomp. The original
3149
* tests aren't executed with -Xcomp in the CI pipeline, so let's exclude
3250
* the generated tests from -Xcomp execution as well.
3351
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
34-
* /test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes
3552
* @compile ../../../../../../jdk/java/lang/invoke/MethodHandlesTest.java
3653
* ../../../../../../lib/jdk/test/lib/Utils.java
3754
* ../../../../../../jdk/java/lang/invoke/MethodHandlesPermuteArgumentsTest.java
3855
* ../../../../../../jdk/java/lang/invoke/remote/RemoteExample.java
3956
* ../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java
40-
* ../dynamicArchive/test-classes/TestMHApp.java
4157
* @build jdk.test.whitebox.WhiteBox
4258
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
43-
* @run junit/othervm/timeout=480 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesPermuteArgumentsTest
59+
* @run junit/othervm/timeout=480 -Dcds.app.tester.workflow=DYNAMIC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesPermuteArgumentsTest
60+
*/
61+
/*
62+
* @test id=static
63+
* @summary Run the MethodHandlesPermuteArgumentsTest.java test in CDSAppTester::STATIC workflow.
64+
* @requires vm.cds & vm.compMode != "Xcomp"
65+
* @comment Some of the tests run excessively slowly with -Xcomp. The original
66+
* tests aren't executed with -Xcomp in the CI pipeline, so let's exclude
67+
* the generated tests from -Xcomp execution as well.
68+
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
69+
* @compile ../../../../../../jdk/java/lang/invoke/MethodHandlesTest.java
70+
* ../../../../../../lib/jdk/test/lib/Utils.java
71+
* ../../../../../../jdk/java/lang/invoke/MethodHandlesPermuteArgumentsTest.java
72+
* ../../../../../../jdk/java/lang/invoke/remote/RemoteExample.java
73+
* ../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java
74+
* @run junit/othervm/timeout=480 -Dcds.app.tester.workflow=STATIC MethodHandlesPermuteArgumentsTest
4475
*/
45-
4676
import org.junit.Test;
4777

48-
import java.io.File;
49-
import java.nio.file.Path;
50-
51-
import jdk.test.lib.cds.CDSOptions;
52-
import jdk.test.lib.cds.CDSTestUtils;
53-
import jdk.test.lib.process.OutputAnalyzer;
54-
import jdk.test.lib.Platform;
55-
5678
public class MethodHandlesPermuteArgumentsTest {
5779
@Test
5880
public void test() throws Exception {
59-
testImpl();
60-
}
61-
62-
private static final String classDir = System.getProperty("test.classes");
63-
private static final String mainClass = "TestMHApp";
64-
private static final String javaClassPath = System.getProperty("java.class.path");
65-
private static final String ps = System.getProperty("path.separator");
66-
private static final String testPackageName = "test.java.lang.invoke";
67-
private static final String testClassName = "MethodHandlesPermuteArgumentsTest";
68-
69-
static void testImpl() throws Exception {
70-
String appJar = JarBuilder.build("MH", new File(classDir), null);
71-
String classList = testClassName + ".list";
72-
String archiveName = testClassName + ".jsa";
73-
// Disable VerifyDpendencies when running with debug build because
74-
// the test requires a lot more time to execute with the option enabled.
75-
String verifyOpt =
76-
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
77-
78-
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
79-
80-
String jars = appJar + ps + junitJar;
81-
82-
// dump class list
83-
CDSTestUtils.dumpClassList(classList, "-cp", jars, verifyOpt, mainClass,
84-
testPackageName + "." + testClassName);
85-
86-
// create archive with the class list
87-
CDSOptions opts = (new CDSOptions())
88-
.addPrefix("-XX:ExtraSharedClassListFile=" + classList,
89-
"-cp", jars,
90-
"-Xlog:class+load,cds")
91-
.setArchiveName(archiveName);
92-
OutputAnalyzer output = CDSTestUtils.createArchiveAndCheck(opts);
93-
if (testClassName.equals("MethodHandlesInvokersTest")) {
94-
output.shouldNotContain("Failed to generate LambdaForm holder classes. Is your classlist out of date?");
95-
}
96-
97-
// run with archive
98-
CDSOptions runOpts = (new CDSOptions())
99-
.addPrefix("-cp", jars, "-Xlog:class+load,cds=debug", verifyOpt)
100-
.setArchiveName(archiveName)
101-
.setUseVersion(false)
102-
.addSuffix(mainClass, testPackageName + "." + testClassName);
103-
output = CDSTestUtils.runWithArchive(runOpts);
104-
output.shouldMatch(".class.load. test.java.lang.invoke.MethodHandlesPermuteArgumentsTest[$][$]Lambda.*/0x.*source:.*shared.*objects.*file")
105-
.shouldHaveExitValue(0);
81+
JDKMethodHandlesTestRunner.test(MethodHandlesPermuteArgumentsTest.class.getName());
10682
}
10783
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,84 +24,60 @@
2424
// this file is auto-generated by CDSMHTest_generate.sh. Do not edit manually.
2525

2626
/*
27-
* @test
28-
* @summary Run the MethodHandlesSpreadArgumentsTest.java test in static CDS archive mode.
27+
* @test id=aot
28+
* @summary Run the MethodHandlesSpreadArgumentsTest.java test in CDSAppTester::AOT workflow.
29+
* @requires vm.cds & vm.compMode != "Xcomp"
30+
* @requires vm.cds.supports.aot.class.linking
31+
* @comment work around JDK-8345635
32+
* @requires !vm.jvmci.enabled
33+
* @comment Some of the tests run excessively slowly with -Xcomp. The original
34+
* tests aren't executed with -Xcomp in the CI pipeline, so let's exclude
35+
* the generated tests from -Xcomp execution as well.
36+
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
37+
* @compile ../../../../../../jdk/java/lang/invoke/MethodHandlesTest.java
38+
* ../../../../../../lib/jdk/test/lib/Utils.java
39+
* ../../../../../../jdk/java/lang/invoke/MethodHandlesSpreadArgumentsTest.java
40+
* ../../../../../../jdk/java/lang/invoke/remote/RemoteExample.java
41+
* ../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java
42+
* @run junit/othervm/timeout=480 -Dcds.app.tester.workflow=AOT MethodHandlesSpreadArgumentsTest
43+
*/
44+
/*
45+
* @test id=dynamic
46+
* @summary Run the MethodHandlesSpreadArgumentsTest.java test in CDSAppTester::DYNAMIC workflow.
2947
* @requires vm.cds & vm.compMode != "Xcomp"
3048
* @comment Some of the tests run excessively slowly with -Xcomp. The original
3149
* tests aren't executed with -Xcomp in the CI pipeline, so let's exclude
3250
* the generated tests from -Xcomp execution as well.
3351
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
34-
* /test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes
3552
* @compile ../../../../../../jdk/java/lang/invoke/MethodHandlesTest.java
3653
* ../../../../../../lib/jdk/test/lib/Utils.java
3754
* ../../../../../../jdk/java/lang/invoke/MethodHandlesSpreadArgumentsTest.java
3855
* ../../../../../../jdk/java/lang/invoke/remote/RemoteExample.java
3956
* ../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java
40-
* ../dynamicArchive/test-classes/TestMHApp.java
4157
* @build jdk.test.whitebox.WhiteBox
4258
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
43-
* @run junit/othervm/timeout=480 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesSpreadArgumentsTest
59+
* @run junit/othervm/timeout=480 -Dcds.app.tester.workflow=DYNAMIC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesSpreadArgumentsTest
60+
*/
61+
/*
62+
* @test id=static
63+
* @summary Run the MethodHandlesSpreadArgumentsTest.java test in CDSAppTester::STATIC workflow.
64+
* @requires vm.cds & vm.compMode != "Xcomp"
65+
* @comment Some of the tests run excessively slowly with -Xcomp. The original
66+
* tests aren't executed with -Xcomp in the CI pipeline, so let's exclude
67+
* the generated tests from -Xcomp execution as well.
68+
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
69+
* @compile ../../../../../../jdk/java/lang/invoke/MethodHandlesTest.java
70+
* ../../../../../../lib/jdk/test/lib/Utils.java
71+
* ../../../../../../jdk/java/lang/invoke/MethodHandlesSpreadArgumentsTest.java
72+
* ../../../../../../jdk/java/lang/invoke/remote/RemoteExample.java
73+
* ../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java
74+
* @run junit/othervm/timeout=480 -Dcds.app.tester.workflow=STATIC MethodHandlesSpreadArgumentsTest
4475
*/
45-
4676
import org.junit.Test;
4777

48-
import java.io.File;
49-
import java.nio.file.Path;
50-
51-
import jdk.test.lib.cds.CDSOptions;
52-
import jdk.test.lib.cds.CDSTestUtils;
53-
import jdk.test.lib.process.OutputAnalyzer;
54-
import jdk.test.lib.Platform;
55-
5678
public class MethodHandlesSpreadArgumentsTest {
5779
@Test
5880
public void test() throws Exception {
59-
testImpl();
60-
}
61-
62-
private static final String classDir = System.getProperty("test.classes");
63-
private static final String mainClass = "TestMHApp";
64-
private static final String javaClassPath = System.getProperty("java.class.path");
65-
private static final String ps = System.getProperty("path.separator");
66-
private static final String testPackageName = "test.java.lang.invoke";
67-
private static final String testClassName = "MethodHandlesSpreadArgumentsTest";
68-
69-
static void testImpl() throws Exception {
70-
String appJar = JarBuilder.build("MH", new File(classDir), null);
71-
String classList = testClassName + ".list";
72-
String archiveName = testClassName + ".jsa";
73-
// Disable VerifyDpendencies when running with debug build because
74-
// the test requires a lot more time to execute with the option enabled.
75-
String verifyOpt =
76-
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
77-
78-
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
79-
80-
String jars = appJar + ps + junitJar;
81-
82-
// dump class list
83-
CDSTestUtils.dumpClassList(classList, "-cp", jars, verifyOpt, mainClass,
84-
testPackageName + "." + testClassName);
85-
86-
// create archive with the class list
87-
CDSOptions opts = (new CDSOptions())
88-
.addPrefix("-XX:ExtraSharedClassListFile=" + classList,
89-
"-cp", jars,
90-
"-Xlog:class+load,cds")
91-
.setArchiveName(archiveName);
92-
OutputAnalyzer output = CDSTestUtils.createArchiveAndCheck(opts);
93-
if (testClassName.equals("MethodHandlesInvokersTest")) {
94-
output.shouldNotContain("Failed to generate LambdaForm holder classes. Is your classlist out of date?");
95-
}
96-
97-
// run with archive
98-
CDSOptions runOpts = (new CDSOptions())
99-
.addPrefix("-cp", jars, "-Xlog:class+load,cds=debug", verifyOpt)
100-
.setArchiveName(archiveName)
101-
.setUseVersion(false)
102-
.addSuffix(mainClass, testPackageName + "." + testClassName);
103-
output = CDSTestUtils.runWithArchive(runOpts);
104-
output.shouldMatch(".class.load. test.java.lang.invoke.MethodHandlesSpreadArgumentsTest[$][$]Lambda.*/0x.*source:.*shared.*objects.*file")
105-
.shouldHaveExitValue(0);
81+
JDKMethodHandlesTestRunner.test(MethodHandlesSpreadArgumentsTest.class.getName());
10682
}
10783
}

Diff for: ‎test/lib/jdk/test/lib/cds/CDSAppTester.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ public OutputAnalyzer productionRun(String[] extraVmArgs, String[] extraAppArgs)
367367
return out;
368368
}
369369

370-
public void run(String args[]) throws Exception {
370+
public void run(String... args) throws Exception {
371371
String err = "Must have exactly one command line argument of the following: ";
372372
String prefix = "";
373373
for (Workflow wf : Workflow.values()) {

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Apr 3, 2025

@openjdk-notifier[bot]
Please sign in to comment.