Skip to content

Commit 7f42804

Browse files
committed
8350524: Some hotspot/jtreg/serviceability/dcmd/vm tier1 tests fail on static JDK
Reviewed-by: stuefe
1 parent 712a70c commit 7f42804

File tree

4 files changed

+72
-21
lines changed

4 files changed

+72
-21
lines changed

test/hotspot/jtreg/serviceability/dcmd/vm/DynLibsTest.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 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
@@ -28,6 +28,7 @@
2828
import jdk.test.lib.Platform;
2929
import jdk.test.lib.dcmd.CommandExecutor;
3030
import jdk.test.lib.dcmd.JMXExecutor;
31+
import jdk.test.whitebox.WhiteBox;
3132

3233
/*
3334
* @test
@@ -37,16 +38,28 @@
3738
* java.compiler
3839
* java.management
3940
* jdk.internal.jvmstat/sun.jvmstat.monitor
40-
* @run testng DynLibsTest
41+
* @build jdk.test.whitebox.WhiteBox
42+
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
43+
* @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI DynLibsTest
4144
*/
4245

4346
public class DynLibsTest {
4447

4548
public void run(CommandExecutor executor) {
4649
OutputAnalyzer output = executor.execute("VM.dynlibs");
47-
output.shouldContain(Platform.buildSharedLibraryName("jvm"));
48-
output.shouldContain(Platform.buildSharedLibraryName("java"));
49-
output.shouldContain(Platform.buildSharedLibraryName("management"));
50+
if (WhiteBox.getWhiteBox().isStatic()) {
51+
// On static JDK, JDK/VM native libraries are statically
52+
// linked with the launcher. There is no separate mapping
53+
// for libjvm, libjava, etc.
54+
output.shouldContain("java");
55+
output.shouldNotContain(Platform.buildSharedLibraryName("jvm"));
56+
output.shouldNotContain(Platform.buildSharedLibraryName("java"));
57+
output.shouldNotContain(Platform.buildSharedLibraryName("management"));
58+
} else {
59+
output.shouldContain(Platform.buildSharedLibraryName("jvm"));
60+
output.shouldContain(Platform.buildSharedLibraryName("java"));
61+
output.shouldContain(Platform.buildSharedLibraryName("management"));
62+
}
5063
}
5164

5265
@Test

test/hotspot/jtreg/serviceability/dcmd/vm/SystemDumpMapTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2023, 2024, Red Hat, Inc. and/or its affiliates.
2+
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2023, 2025, Red Hat, Inc. and/or its affiliates.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,9 @@
4040
* java.compiler
4141
* java.management
4242
* jdk.internal.jvmstat/sun.jvmstat.monitor
43-
* @run testng/othervm -XX:+UsePerfData SystemDumpMapTest
43+
* @build jdk.test.whitebox.WhiteBox
44+
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
45+
* @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UsePerfData SystemDumpMapTest
4446
*/
4547
public class SystemDumpMapTest extends SystemMapTestBase {
4648

test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2023, 2024, Red Hat, Inc. and/or its affiliates.
2+
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2023, 2025, Red Hat, Inc. and/or its affiliates.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,9 @@
3636
* java.compiler
3737
* java.management
3838
* jdk.internal.jvmstat/sun.jvmstat.monitor
39-
* @run testng/othervm -XX:+UsePerfData SystemMapTest
39+
* @build jdk.test.whitebox.WhiteBox
40+
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
41+
* @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UsePerfData SystemMapTest
4042
*/
4143

4244
/*
@@ -49,7 +51,9 @@
4951
* java.compiler
5052
* java.management
5153
* jdk.internal.jvmstat/sun.jvmstat.monitor
52-
* @run testng/othervm -XX:+UsePerfData -XX:+UseZGC SystemMapTest
54+
* @build jdk.test.whitebox.WhiteBox
55+
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
56+
* @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UsePerfData -XX:+UseZGC SystemMapTest
5357
*/
5458
public class SystemMapTest extends SystemMapTestBase {
5559
public void run(CommandExecutor executor) {

test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTestBase.java

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2024, Red Hat, Inc. and/or its affiliates.
2+
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2025, Red Hat, Inc. and/or its affiliates.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
2323
*/
2424

2525
import jdk.test.lib.Platform;
26+
import jdk.test.lib.StringArrayUtils;
27+
import jdk.test.whitebox.WhiteBox;
2628

2729
public class SystemMapTestBase {
2830

@@ -82,14 +84,17 @@ private static class LinuxPatterns implements MapPatterns {
8284
static final String shouldMatchUnconditionally_linux[] = {
8385
// java launcher
8486
regexBase_committed + "/bin/java",
85-
// libjvm
86-
regexBase_committed + "/lib/.*/libjvm.so",
8787
// heap segment, should be part of all user space apps on all architectures OpenJDK supports.
8888
regexBase_committed + "\\[heap\\]",
8989
// we should see the hs-perf data file, and it should appear as shared as well as committed
9090
regexBase_shared_and_committed + "hsperfdata_.*"
9191
};
9292

93+
static final String shouldMatch_linux_libjvm[] = {
94+
// libjvm
95+
regexBase_committed + "/lib/.*/libjvm.so"
96+
};
97+
9398
static final String shouldMatchIfNMTIsEnabled_linux[] = {
9499
regexBase_java_heap + "JAVAHEAP.*",
95100
// metaspace
@@ -103,7 +108,14 @@ private static class LinuxPatterns implements MapPatterns {
103108
};
104109

105110
public String[] shouldMatchUnconditionally() {
106-
return shouldMatchUnconditionally_linux;
111+
if (WhiteBox.getWhiteBox().isStatic()) {
112+
// On static JDK, libjvm is statically linked with the 'java'
113+
// launcher. There is no separate mapping for libjvm.
114+
return shouldMatchUnconditionally_linux;
115+
} else {
116+
return StringArrayUtils.concat(shouldMatchUnconditionally_linux,
117+
shouldMatch_linux_libjvm);
118+
}
107119
}
108120

109121
public String[] shouldMatchIfNMTIsEnabled() {
@@ -125,6 +137,9 @@ private static class WindowsPatterns implements MapPatterns {
125137
static final String shouldMatchUnconditionally_windows[] = {
126138
// java launcher
127139
winimage + ".*[\\/\\\\]bin[\\/\\\\]java[.]exe",
140+
};
141+
142+
static final String shouldMatch_windows_libjvm[] = {
128143
// libjvm
129144
winimage + ".*[\\/\\\\]bin[\\/\\\\].*[\\/\\\\]jvm.dll"
130145
};
@@ -142,7 +157,14 @@ private static class WindowsPatterns implements MapPatterns {
142157
};
143158

144159
public String[] shouldMatchUnconditionally() {
145-
return shouldMatchUnconditionally_windows;
160+
if (WhiteBox.getWhiteBox().isStatic()) {
161+
// On static JDK, libjvm is statically linked with the 'java'
162+
// launcher. There is no separate mapping for libjvm.
163+
return shouldMatchUnconditionally_windows;
164+
} else {
165+
return StringArrayUtils.concat(shouldMatchUnconditionally_windows,
166+
shouldMatch_windows_libjvm);
167+
}
146168
}
147169

148170
public String[] shouldMatchIfNMTIsEnabled() {
@@ -165,12 +187,15 @@ private static class MacOSPatterns implements MapPatterns {
165187
static final String shouldMatchUnconditionally_macOS[] = {
166188
// java launcher
167189
macOSbase + macow + space + someNumber + space + "/.*/bin/java",
168-
// libjvm
169-
macOSbase + macow + space + someNumber + space + "/.*/lib/server/libjvm.dylib",
170190
// we should see the hs-perf data file, and it should appear as shared as well as committed
171191
macOSbase + macprivate + space + someNumber + space + ".*/.*/hsperfdata_.*"
172192
};
173193

194+
static final String shouldMatch_macOS_libjvm[] = {
195+
// libjvm
196+
macOSbase + macow + space + someNumber + space + "/.*/lib/server/libjvm.dylib",
197+
};
198+
174199
static final String shouldMatchIfNMTIsEnabled_macOS[] = {
175200
// heap is private with G1GC, shared with ZGC
176201
macOSbase + macprivate_or_shared + space + someNumber + space + "JAVAHEAP.*",
@@ -183,7 +208,14 @@ private static class MacOSPatterns implements MapPatterns {
183208
};
184209

185210
public String[] shouldMatchUnconditionally() {
186-
return shouldMatchUnconditionally_macOS;
211+
if (WhiteBox.getWhiteBox().isStatic()) {
212+
// On static JDK, libjvm is statically linked with the 'java'
213+
// launcher. There is no separate mapping for libjvm.
214+
return shouldMatchUnconditionally_macOS;
215+
} else {
216+
return StringArrayUtils.concat(shouldMatchUnconditionally_macOS,
217+
shouldMatch_macOS_libjvm);
218+
}
187219
}
188220

189221
public String[] shouldMatchIfNMTIsEnabled() {

0 commit comments

Comments
 (0)