Skip to content

Commit f4354fa

Browse files
committed
Merge master jdk-17.0.13+5 into openj9-staging
Signed-off-by: J9 Build <[email protected]>
2 parents d440eb1 + 5fef984 commit f4354fa

36 files changed

+1585
-624
lines changed

test/hotspot/jtreg/compiler/codecache/CodeCacheFullCountTest.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,20 @@ public static void main(String args[]) throws Throwable {
4545
}
4646
}
4747

48-
public static void wasteCodeCache() throws Exception {
48+
public static void wasteCodeCache() throws Throwable {
4949
URL url = CodeCacheFullCountTest.class.getProtectionDomain().getCodeSource().getLocation();
5050

51-
for (int i = 0; i < 500; i++) {
52-
ClassLoader cl = new MyClassLoader(url);
53-
refClass(cl.loadClass("SomeClass"));
51+
try {
52+
for (int i = 0; i < 500; i++) {
53+
ClassLoader cl = new MyClassLoader(url);
54+
refClass(cl.loadClass("SomeClass"));
55+
}
56+
} catch (Throwable t) {
57+
// Expose the root cause of the Throwable instance.
58+
while (t.getCause() != null) {
59+
t = t.getCause();
60+
}
61+
throw t;
5462
}
5563
}
5664

@@ -59,7 +67,7 @@ public static void runTest() throws Throwable {
5967
"-XX:ReservedCodeCacheSize=2496k", "-XX:-UseCodeCacheFlushing", "CodeCacheFullCountTest", "WasteCodeCache");
6068
OutputAnalyzer oa = ProcessTools.executeProcess(pb);
6169
// Ignore adapter creation failures
62-
if (oa.getExitValue() != 0 && !oa.getStderr().contains("Out of space in CodeCache for adapters")) {
70+
if (oa.getExitValue() != 0 && !oa.getOutput().contains("Out of space in CodeCache for adapters")) {
6371
oa.reportDiagnosticSummary();
6472
throw new RuntimeException("VM finished with exit code " + oa.getExitValue());
6573
}

test/hotspot/jtreg/containers/docker/TestJcmd.java

Lines changed: 101 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,22 @@ public class TestJcmd {
5555
private static final String IMAGE_NAME = Common.imageName("jcmd");
5656
private static final int TIME_TO_RUN_CONTAINER_PROCESS = (int) (10 * Utils.TIMEOUT_FACTOR); // seconds
5757
private static final String CONTAINER_NAME = "test-container";
58+
private static final boolean IS_PODMAN = Container.ENGINE_COMMAND.contains("podman");
59+
private static final String ROOT_UID = "0";
5860

5961

6062
public static void main(String[] args) throws Exception {
6163
DockerTestUtils.canTestDocker();
6264

63-
// See JDK-8273216 for details
64-
if (Container.ENGINE_COMMAND.equals("podman")) {
65-
throw new SkippedException("JCMD does not work across container boundaries when using Podman");
65+
// podman versions below 3.3.1 hava a bug where cross-container testing with correct
66+
// permissions fails. See JDK-8273216
67+
if (IS_PODMAN && PodmanVersion.VERSION_3_3_1.compareTo(getPodmanVersion()) > 0) {
68+
throw new SkippedException("Podman version too old for this test. Expected >= 3.3.1");
6669
}
6770

6871
// Need to create a custom dockerfile where user name and id, as well as group name and id
6972
// of the JVM running in container must match the ones from the inspecting JCMD process.
70-
String uid = getId("-u");
71-
String gid = getId("-g");
72-
String userName = getId("-un");
73-
String groupName = getId("-gn");
74-
String content = generateCustomDockerfile(uid, gid, userName, groupName);
73+
String content = generateCustomDockerfile();
7574
DockerTestUtils.buildJdkContainerImage(IMAGE_NAME, content);
7675

7776
try {
@@ -135,17 +134,26 @@ private static void testVmInfo(long pid) throws Exception {
135134

136135
// Need to make sure that user name+id and group name+id are created for the image, and
137136
// match the host system. This is necessary to allow proper permission/access for JCMD.
138-
private static String generateCustomDockerfile(String uid, String gid,
139-
String userName, String groupName) throws Exception {
137+
// For podman --userns=keep-id is sufficient.
138+
private static String generateCustomDockerfile() throws Exception {
140139
StringBuilder sb = new StringBuilder();
141140
sb.append(String.format("FROM %s:%s\n", DockerfileConfig.getBaseImageName(),
142141
DockerfileConfig.getBaseImageVersion()));
143142
sb.append("COPY /jdk /jdk\n");
144143
sb.append("ENV JAVA_HOME=/jdk\n");
145144

146-
sb.append(String.format("RUN groupadd --gid %s %s \n", gid, groupName));
147-
sb.append(String.format("RUN useradd --uid %s --gid %s %s \n", uid, gid, userName));
148-
sb.append(String.format("USER %s \n", userName));
145+
if (!IS_PODMAN) { // only needed for docker
146+
String uid = getId("-u");
147+
String gid = getId("-g");
148+
String userName = getId("-un");
149+
String groupName = getId("-gn");
150+
// Only needed when run as regular user. UID == 0 should already exist
151+
if (!ROOT_UID.equals(uid)) {
152+
sb.append(String.format("RUN groupadd --gid %s %s \n", gid, groupName));
153+
sb.append(String.format("RUN useradd --uid %s --gid %s %s \n", uid, gid, userName));
154+
sb.append(String.format("USER %s \n", userName));
155+
}
156+
}
149157

150158
sb.append("CMD [\"/bin/bash\"]\n");
151159

@@ -155,12 +163,17 @@ private static String generateCustomDockerfile(String uid, String gid,
155163

156164
private static Process startObservedContainer() throws Exception {
157165
DockerRunOptions opts = new DockerRunOptions(IMAGE_NAME, "/jdk/bin/java", "EventGeneratorLoop");
158-
opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/")
166+
opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/:z")
159167
.addJavaOpts("-cp", "/test-classes/")
160168
.addDockerOpts("--cap-add=SYS_PTRACE")
161169
.addDockerOpts("--name", CONTAINER_NAME)
162170
.addClassOptions("" + TIME_TO_RUN_CONTAINER_PROCESS);
163171

172+
if (IS_PODMAN) {
173+
// map the current userid to the one in the target namespace
174+
opts.addDockerOpts("--userns=keep-id");
175+
}
176+
164177
// avoid large Xmx
165178
opts.appendTestJavaOptions = false;
166179

@@ -190,4 +203,78 @@ private static String getId(String param) throws Exception {
190203
System.out.println("getId() " + param + " returning: " + result);
191204
return result;
192205
}
206+
207+
// pre: IS_PODMAN == true
208+
private static String getPodmanVersionStr() {
209+
if (!IS_PODMAN) {
210+
return null;
211+
}
212+
try {
213+
ProcessBuilder pb = new ProcessBuilder(Container.ENGINE_COMMAND, "--version");
214+
OutputAnalyzer out = new OutputAnalyzer(pb.start())
215+
.shouldHaveExitValue(0);
216+
String result = out.asLines().get(0);
217+
System.out.println(Container.ENGINE_COMMAND + " --version returning: " + result);
218+
return result;
219+
} catch (Exception e) {
220+
System.out.println(Container.ENGINE_COMMAND + " --version command failed. Returning null");
221+
return null;
222+
}
223+
}
224+
225+
private static PodmanVersion getPodmanVersion() {
226+
return PodmanVersion.fromVersionString(getPodmanVersionStr());
227+
}
228+
229+
private static class PodmanVersion implements Comparable<PodmanVersion> {
230+
private static final PodmanVersion DEFAULT = new PodmanVersion(0, 0, 0);
231+
private static final PodmanVersion VERSION_3_3_1 = new PodmanVersion(3, 3, 1);
232+
private final int major;
233+
private final int minor;
234+
private final int micro;
235+
236+
private PodmanVersion(int major, int minor, int micro) {
237+
this.major = major;
238+
this.minor = minor;
239+
this.micro = micro;
240+
}
241+
242+
@Override
243+
public int compareTo(PodmanVersion other) {
244+
if (this.major > other.major) {
245+
return 1;
246+
} else if (this.major < other.major) {
247+
return -1;
248+
} else { // equal major
249+
if (this.minor > other.minor) {
250+
return 1;
251+
} else if (this.minor < other.minor) {
252+
return -1;
253+
} else { // equal majors and minors
254+
if (this.micro > other.micro) {
255+
return 1;
256+
} else if (this.micro < other.micro) {
257+
return -1;
258+
} else {
259+
// equal majors, minors, micro
260+
return 0;
261+
}
262+
}
263+
}
264+
}
265+
266+
private static PodmanVersion fromVersionString(String version) {
267+
try {
268+
// Example 'podman version 3.2.1'
269+
String versNums = version.split("\\s+", 3)[2];
270+
String[] numbers = versNums.split("\\.", 3);
271+
return new PodmanVersion(Integer.parseInt(numbers[0]),
272+
Integer.parseInt(numbers[1]),
273+
Integer.parseInt(numbers[2]));
274+
} catch (Exception e) {
275+
System.out.println("Failed to parse podman version: " + version);
276+
return DEFAULT;
277+
}
278+
}
279+
}
193280
}

test/hotspot/jtreg/gc/stress/TestStressG1Humongous.java

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,41 @@
2424
package gc.stress;
2525

2626
/*
27-
* @test TestStressG1Humongous
27+
* @test
2828
* @key stress
2929
* @summary Stress G1 by humongous allocations in situation near OOM
3030
* @requires vm.gc.G1
3131
* @requires !vm.flightRecorder
3232
* @library /test/lib
3333
* @modules java.base/jdk.internal.misc
34-
* @run driver/timeout=1300 gc.stress.TestStressG1Humongous
34+
* @run driver/timeout=180 gc.stress.TestStressG1Humongous 4 3 1.1 120
35+
*/
36+
37+
/*
38+
* @test
39+
* @requires vm.gc.G1
40+
* @requires !vm.flightRecorder
41+
* @library /test/lib
42+
* @modules java.base/jdk.internal.misc
43+
* @run driver/timeout=180 gc.stress.TestStressG1Humongous 16 5 2.1 120
44+
*/
45+
46+
/*
47+
* @test
48+
* @requires vm.gc.G1
49+
* @requires !vm.flightRecorder
50+
* @library /test/lib
51+
* @modules java.base/jdk.internal.misc
52+
* @run driver/timeout=180 gc.stress.TestStressG1Humongous 32 4 0.6 120
53+
*/
54+
55+
/*
56+
* @test
57+
* @requires vm.gc.G1
58+
* @requires !vm.flightRecorder
59+
* @library /test/lib
60+
* @modules java.base/jdk.internal.misc
61+
* @run driver/timeout=900 gc.stress.TestStressG1Humongous 1 7 0.6 600
3562
*/
3663

3764
import java.util.ArrayList;
@@ -48,17 +75,19 @@
4875
public class TestStressG1Humongous{
4976

5077
public static void main(String[] args) throws Exception {
78+
if (args.length != 4) {
79+
throw new IllegalArgumentException("Test expects 4 arguments");
80+
}
81+
5182
// Limit heap size on 32-bit platforms
5283
int heapSize = Platform.is32bit() ? 512 : 1024;
53-
// Heap size, region size, threads, humongous size, timeout
54-
run(heapSize, 4, 3, 1.1, 120);
55-
run(heapSize, 16, 5, 2.1, 120);
56-
run(heapSize, 32, 4, 0.6, 120);
57-
run(heapSize, 1, 7, 0.6, 600);
58-
}
5984

60-
private static void run(int heapSize, int regionSize, int threads, double humongousSize, int timeout)
61-
throws Exception {
85+
// Region size, threads, humongous size, and timeout passed as @run arguments
86+
int regionSize = Integer.parseInt(args[0]);
87+
int threads = Integer.parseInt(args[1]);
88+
double humongousSize = Double.parseDouble(args[2]);
89+
int timeout = Integer.parseInt(args[3]);
90+
6291
ArrayList<String> options = new ArrayList<>();
6392
Collections.addAll(options, Utils.getTestJavaOpts());
6493
Collections.addAll(options,

test/hotspot/jtreg/runtime/cds/TestCDSVMCrash.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
/*
2525
* @test TestCDSVMCrash
2626
* @summary Verify that an exception is thrown when the VM crashes during executeAndLog
27+
* @requires vm.cds
2728
* @modules java.base/jdk.internal.misc
2829
* @library /test/lib
2930
* @run driver TestCDSVMCrash

test/hotspot/jtreg/runtime/logging/ClassLoadUnloadTest.java

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
import jdk.test.lib.classloader.ClassUnloadCommon;
4545

4646
public class ClassLoadUnloadTest {
47-
private static OutputAnalyzer out;
48-
private static ProcessBuilder pb;
4947
private static class ClassUnloadTestMain {
5048
public static void main(String... args) throws Exception {
5149
String className = "test.Empty";
@@ -56,63 +54,62 @@ public static void main(String... args) throws Exception {
5654
}
5755
}
5856

59-
static void checkFor(String... outputStrings) throws Exception {
60-
out = new OutputAnalyzer(pb.start());
57+
static void checkFor(OutputAnalyzer output, String... outputStrings) throws Exception {
6158
for (String s: outputStrings) {
62-
out.shouldContain(s);
59+
output.shouldContain(s);
6360
}
64-
out.shouldHaveExitValue(0);
6561
}
6662

67-
static void checkAbsent(String... outputStrings) throws Exception {
68-
out = new OutputAnalyzer(pb.start());
63+
static void checkAbsent(OutputAnalyzer output, String... outputStrings) throws Exception {
6964
for (String s: outputStrings) {
70-
out.shouldNotContain(s);
65+
output.shouldNotContain(s);
7166
}
72-
out.shouldHaveExitValue(0);
7367
}
7468

7569
// Use the same command-line heap size setting as ../ClassUnload/UnloadTest.java
76-
static ProcessBuilder exec(String... args) throws Exception {
70+
static OutputAnalyzer exec(String... args) throws Exception {
7771
List<String> argsList = new ArrayList<>();
7872
Collections.addAll(argsList, args);
79-
Collections.addAll(argsList, "-Xmn8m");
80-
Collections.addAll(argsList, "-Dtest.class.path=" + System.getProperty("test.class.path", "."));
81-
Collections.addAll(argsList, "-XX:+ClassUnloading");
82-
Collections.addAll(argsList, ClassUnloadTestMain.class.getName());
83-
return ProcessTools.createJavaProcessBuilder(argsList);
73+
Collections.addAll(argsList, "-Xmn8m", "-Dtest.class.path=" + System.getProperty("test.class.path", "."),
74+
"-XX:+ClassUnloading", ClassUnloadTestMain.class.getName());
75+
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(argsList);
76+
OutputAnalyzer output = new OutputAnalyzer(pb.start());
77+
output.shouldHaveExitValue(0);
78+
return output;
8479
}
8580

8681
public static void main(String... args) throws Exception {
8782

83+
OutputAnalyzer output;
84+
8885
// -Xlog:class+unload=info
89-
pb = exec("-Xlog:class+unload=info");
90-
checkFor("[class,unload]", "unloading class");
86+
output = exec("-Xlog:class+unload=info");
87+
checkFor(output, "[class,unload]", "unloading class");
9188

9289
// -Xlog:class+unload=off
93-
pb = exec("-Xlog:class+unload=off");
94-
checkAbsent("[class,unload]");
90+
output = exec("-Xlog:class+unload=off");
91+
checkAbsent(output,"[class,unload]");
9592

9693
// -Xlog:class+load=info
97-
pb = exec("-Xlog:class+load=info");
98-
checkFor("[class,load]", "java.lang.Object", "source:");
94+
output = exec("-Xlog:class+load=info");
95+
checkFor(output,"[class,load]", "java.lang.Object", "source:");
9996

10097
// -Xlog:class+load=debug
101-
pb = exec("-Xlog:class+load=debug");
102-
checkFor("[class,load]", "java.lang.Object", "source:", "klass:", "super:", "loader:", "bytes:");
98+
output = exec("-Xlog:class+load=debug");
99+
checkFor(output,"[class,load]", "java.lang.Object", "source:", "klass:", "super:", "loader:", "bytes:");
103100

104101
// -Xlog:class+load=off
105-
pb = exec("-Xlog:class+load=off");
106-
checkAbsent("[class,load]");
102+
output = exec("-Xlog:class+load=off");
103+
checkAbsent(output,"[class,load]");
107104

108105
// -verbose:class
109-
pb = exec("-verbose:class");
110-
checkFor("[class,load]", "java.lang.Object", "source:");
111-
checkFor("[class,unload]", "unloading class");
106+
output = exec("-verbose:class");
107+
checkFor(output,"[class,load]", "java.lang.Object", "source:");
108+
checkFor(output,"[class,unload]", "unloading class");
112109

113110
// -Xlog:class+loader+data=trace
114-
pb = exec("-Xlog:class+loader+data=trace");
115-
checkFor("[class,loader,data]", "create loader data");
111+
output = exec("-Xlog:class+loader+data=trace");
112+
checkFor(output, "[class,loader,data]", "create loader data");
116113

117114
}
118115
}

0 commit comments

Comments
 (0)