From 960ad211867d65a993b2fc4e6dafa8cea9827b3f Mon Sep 17 00:00:00 2001 From: Jiangli Zhou Date: Thu, 20 Feb 2025 15:47:54 +0000 Subject: [PATCH] 8349620: Add VMProps for static JDK Reviewed-by: alanb, manc --- src/hotspot/share/prims/whitebox.cpp | 8 +++++++- test/hotspot/jtreg/TEST.ROOT | 3 ++- test/hotspot/jtreg/runtime/modules/ModulesSymLink.java | 1 + test/jdk/TEST.ROOT | 3 ++- test/jtreg-ext/requires/VMProps.java | 5 +++++ test/lib/jdk/test/whitebox/WhiteBox.java | 2 ++ 6 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index 686797f8dd6..a612a3d55a9 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -47,6 +47,7 @@ #include "gc/shared/gcConfig.hpp" #include "gc/shared/gcLocker.inline.hpp" #include "gc/shared/genArguments.hpp" +#include "jvm.h" #include "jvmtifiles/jvmtiEnv.hpp" #include "logging/log.hpp" #include "memory/iterator.hpp" @@ -1804,6 +1805,10 @@ WB_ENTRY(jlong, WB_RootChunkWordSize(JNIEnv* env)) return (jlong)Metaspace::reserve_alignment_words(); WB_END +WB_ENTRY(jboolean, WB_IsStaticallyLinked(JNIEnv* env, jobject wb)) + return JVM_IsStaticallyLinked(); +WB_END + ////////////// WB_ENTRY(jlong, WB_AllocateMetaspace(JNIEnv* env, jobject wb, jobject class_loader, jlong size)) @@ -3003,7 +3008,8 @@ static JNINativeMethod methods[] = { {CC"printString", CC"(Ljava/lang/String;I)Ljava/lang/String;", (void*)&WB_PrintString}, {CC"lockAndStuckInSafepoint", CC"()V", (void*)&WB_TakeLockAndHangInSafepoint}, {CC"wordSize", CC"()J", (void*)&WB_WordSize}, - {CC"rootChunkWordSize", CC"()J", (void*)&WB_RootChunkWordSize} + {CC"rootChunkWordSize", CC"()J", (void*)&WB_RootChunkWordSize}, + {CC"isStatic", CC"()Z", (void*)&WB_IsStaticallyLinked} }; diff --git a/test/hotspot/jtreg/TEST.ROOT b/test/hotspot/jtreg/TEST.ROOT index ac4321e6839..ffc70d1bb18 100644 --- a/test/hotspot/jtreg/TEST.ROOT +++ b/test/hotspot/jtreg/TEST.ROOT @@ -92,7 +92,8 @@ requires.properties= \ systemd.support \ jdk.containerized \ jlink.runtime.linkable \ - jlink.packagedModules + jlink.packagedModules \ + jdk.static # Minimum jtreg version requiredVersion=7.5.1+1 diff --git a/test/hotspot/jtreg/runtime/modules/ModulesSymLink.java b/test/hotspot/jtreg/runtime/modules/ModulesSymLink.java index f19897f9638..18d618cf8bc 100644 --- a/test/hotspot/jtreg/runtime/modules/ModulesSymLink.java +++ b/test/hotspot/jtreg/runtime/modules/ModulesSymLink.java @@ -27,6 +27,7 @@ * @bug 8220095 * @requires os.family == "linux" | os.family == "mac" * @requires vm.flagless + * @requires !jdk.static * @library /test/lib * @modules java.management * jdk.jlink diff --git a/test/jdk/TEST.ROOT b/test/jdk/TEST.ROOT index 3b0b824b36f..91c44bc4d05 100644 --- a/test/jdk/TEST.ROOT +++ b/test/jdk/TEST.ROOT @@ -111,7 +111,8 @@ requires.properties= \ jdk.containerized \ jdk.foreign.linker \ jlink.runtime.linkable \ - jlink.packagedModules + jlink.packagedModules \ + jdk.static # Minimum jtreg version requiredVersion=7.5.1+1 diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index 7e4553f0611..6f8beff8cf9 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -140,6 +140,7 @@ public class VMProps implements Callable> { map.put("vm.flagless", this::isFlagless); map.put("jdk.foreign.linker", this::jdkForeignLinker); map.put("jlink.packagedModules", this::packagedModules); + map.put("jdk.static", this::isStatic); vmGC(map); // vm.gc.X = true/false vmGCforCDS(map); // may set vm.gc vmOptFinalFlags(map); @@ -820,6 +821,10 @@ public class VMProps implements Callable> { return String.valueOf(CABI.current()); } + private String isStatic() { + return Boolean.toString(WB.isStatic()); + } + /** * Dumps the map to the file if the file name is given as the property. * This functionality could be helpful to know context in the real diff --git a/test/lib/jdk/test/whitebox/WhiteBox.java b/test/lib/jdk/test/whitebox/WhiteBox.java index 41ad60a7c4b..7222c6fedcf 100644 --- a/test/lib/jdk/test/whitebox/WhiteBox.java +++ b/test/lib/jdk/test/whitebox/WhiteBox.java @@ -798,4 +798,6 @@ public class WhiteBox { public native void preTouchMemory(long addr, long size); public native long rss(); + + public native boolean isStatic(); }