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
2323 */
2424
2525import jdk .test .lib .Platform ;
26+ import jdk .test .lib .StringArrayUtils ;
27+ import jdk .test .whitebox .WhiteBox ;
2628
2729public 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