From 37232815d175ccd954bb879a2eb556c6db9086c7 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Thu, 8 May 2025 09:44:31 +0200 Subject: [PATCH 1/4] svm: mark JDK21OrEarlier as deprecated for removal --- .../src/com/oracle/svm/core/jdk/JDK21OrEarlier.java | 1 + 1 file changed, 1 insertion(+) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JDK21OrEarlier.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JDK21OrEarlier.java index dcf75cb50a33..64f4b631c747 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JDK21OrEarlier.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JDK21OrEarlier.java @@ -28,6 +28,7 @@ import jdk.graal.compiler.serviceprovider.JavaVersionUtil; +@Deprecated(since = "25.0.0", forRemoval = true) public class JDK21OrEarlier implements BooleanSupplier { @Override public boolean getAsBoolean() { From 5fcf5a221b77173e00d7e650f3600e7ff6e20c82 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Thu, 8 May 2025 10:03:30 +0200 Subject: [PATCH 2/4] svm: remove JDK 21 substitutions --- ...Target_java_lang_foreign_SymbolLookup.java | 7 +- ...k_internal_foreign_Utils_BaseAndScale.java | 8 - ..._jdk_internal_misc_ScopedMemoryAccess.java | 9 - .../oracle/svm/core/dcmd/AbstractJfrDCmd.java | 11 +- .../svm/core/heap/ReferenceInternals.java | 7 +- .../heap/Target_java_lang_ref_Reference.java | 4 +- .../Target_java_lang_ref_ReferenceQueue.java | 5 - .../heap/Target_jdk_internal_ref_Cleaner.java | 55 +-- .../com/oracle/svm/core/hub/DynamicHub.java | 42 -- .../core/hub/SunReflectTypeSubstitutions.java | 47 --- .../jdk/ForeignDisabledSubstitutions.java | 7 - .../svm/core/jdk/JavaLangSubstitutions.java | 43 +- .../oracle/svm/core/jdk/RecomputedFields.java | 37 -- .../svm/core/jdk/SecuritySubstitutions.java | 169 -------- .../oracle/svm/core/jdk/StackTraceUtils.java | 30 +- .../svm/core/jdk/SunMiscSubstitutions.java | 6 - .../jdk/Target_java_lang_ClassLoader.java | 16 - .../svm/core/jdk/Target_java_lang_Module.java | 4 - .../jdk/Target_java_net_URLClassLoader.java | 7 - ...et_java_security_AccessControlContext.java | 61 --- .../jdk/Target_java_util_ServiceLoader.java | 5 - ...ava_util_concurrent_CompletableFuture.java | 53 +-- ...get_java_util_concurrent_ForkJoinTask.java | 12 +- .../core/jdk/Target_jdk_internal_misc_VM.java | 10 - .../Target_java_util_ResourceBundle.java | 27 -- .../core/jdk/proxy/ProxySubstitutions.java | 15 - .../svm/core/jfr/JfrEventWriterAccess.java | 6 +- .../svm/core/jfr/JfrJdkCompatibility.java | 32 +- .../com/oracle/svm/core/jfr/JfrManager.java | 10 +- .../com/oracle/svm/core/jfr/SubstrateJVM.java | 7 +- ...jfr_internal_JVM_ChunkRotationMonitor.java | 34 -- .../Target_jdk_jfr_internal_JVM_JDK21.java | 370 ------------------ .../Target_jdk_jfr_internal_Repository.java | 19 - ...dk_jfr_internal_SecuritySupport_JDK21.java | 54 --- .../Target_jdk_jfr_internal_StringPool.java | 7 - ...et_jdk_jfr_internal_dcmd_AbstractDCmd.java | 5 - ...et_jdk_jfr_internal_event_EventWriter.java | 7 - ...jdk_jfr_internal_instrument_JDKEvents.java | 12 - .../core/jfr/events/JavaMonitorWaitEvent.java | 4 +- ..._java_lang_invoke_MethodHandleNatives.java | 13 - ...java_lang_invoke_MethodHandles_Lookup.java | 9 - .../monitor/MultiThreadedMonitorSupport.java | 21 +- ...dk_internal_reflect_AccessorGenerator.java | 74 ---- .../oracle/svm/core/thread/JavaThreads.java | 8 - .../thread/Target_java_lang_ScopedValue.java | 20 - .../core/thread/Target_java_lang_Thread.java | 65 +-- .../Target_java_lang_VirtualThread.java | 159 -------- 47 files changed, 23 insertions(+), 1610 deletions(-) delete mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/SunReflectTypeSubstitutions.java delete mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_security_AccessControlContext.java delete mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM_ChunkRotationMonitor.java delete mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM_JDK21.java delete mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_SecuritySupport_JDK21.java delete mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_jdk_internal_reflect_AccessorGenerator.java diff --git a/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_java_lang_foreign_SymbolLookup.java b/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_java_lang_foreign_SymbolLookup.java index b1b77f4832f3..4da7d5adb58a 100644 --- a/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_java_lang_foreign_SymbolLookup.java +++ b/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_java_lang_foreign_SymbolLookup.java @@ -50,7 +50,6 @@ import com.oracle.svm.core.jdk.Target_java_lang_Module; import com.oracle.svm.core.snippets.KnownIntrinsics; -import jdk.graal.compiler.serviceprovider.JavaVersionUtil; import jdk.internal.foreign.MemorySessionImpl; import jdk.internal.foreign.Utils; import jdk.internal.loader.NativeLibrary; @@ -139,11 +138,7 @@ static void ensureNativeAccess(Class currentClass, Class owner, String met */ Target_java_lang_Module module = SubstrateUtil.cast(currentClass != null ? currentClass.getModule() : ClassLoader.getSystemClassLoader().getUnnamedModule(), Target_java_lang_Module.class); - if (JavaVersionUtil.JAVA_SPEC <= 21) { - module.ensureNativeAccess(owner, methodName); - } else { - module.ensureNativeAccess(owner, methodName, currentClass, false); - } + module.ensureNativeAccess(owner, methodName, currentClass, false); } diff --git a/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_foreign_Utils_BaseAndScale.java b/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_foreign_Utils_BaseAndScale.java index e2f30836421b..549a1cd437f9 100644 --- a/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_foreign_Utils_BaseAndScale.java +++ b/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_foreign_Utils_BaseAndScale.java @@ -30,7 +30,6 @@ import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.config.ConfigurationValues; -import com.oracle.svm.core.jdk.JDK21OrEarlier; import com.oracle.svm.core.jdk.JDKLatest; import com.oracle.svm.core.util.VMError; @@ -45,13 +44,6 @@ final class Target_jdk_internal_foreign_Utils_BaseAndScale { long base; } -@TargetClass(className = "jdk.internal.foreign.Utils", innerClass = "BaseAndScale", onlyWith = {ForeignAPIPredicates.Enabled.class, JDK21OrEarlier.class}) -final class Target_jdk_internal_foreign_Utils_BaseAndScale_JDK21 { - @Alias // - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = BaseFieldRecomputer.class) // - int base; -} - final class BaseFieldRecomputer implements FieldValueTransformer { @Override diff --git a/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_misc_ScopedMemoryAccess.java b/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_misc_ScopedMemoryAccess.java index 4d36f0448230..f1f9cd468a19 100644 --- a/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_misc_ScopedMemoryAccess.java +++ b/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_misc_ScopedMemoryAccess.java @@ -34,7 +34,6 @@ import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDK21OrEarlier; import com.oracle.svm.core.jdk.JDKLatest; import com.oracle.svm.core.nodes.foreign.MemoryArenaValidInScopeNode; import com.oracle.svm.core.util.BasedOnJDKFile; @@ -206,14 +205,6 @@ public void forceInternal(MemorySessionImpl session, MappedMemoryUtilsProxy mapp void closeScope0(Target_jdk_internal_foreign_MemorySessionImpl session, @SuppressWarnings("unused") Target_jdk_internal_misc_ScopedMemoryAccess_ScopedAccessError error) { new SyncCloseScopeOperation(session).enqueue(); } - - @SuppressWarnings("static-method") - @Substitute - @TargetElement(onlyWith = JDK21OrEarlier.class) - boolean closeScope0(Target_jdk_internal_foreign_MemorySessionImpl session) { - new SyncCloseScopeOperation(session).enqueue(); - return true; - } } @Retention(RetentionPolicy.RUNTIME) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/dcmd/AbstractJfrDCmd.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/dcmd/AbstractJfrDCmd.java index cd7a260037cc..24c8bafadbac 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/dcmd/AbstractJfrDCmd.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/dcmd/AbstractJfrDCmd.java @@ -28,8 +28,6 @@ import com.oracle.svm.core.jfr.Target_jdk_jfr_internal_dcmd_AbstractDCmd; import com.oracle.svm.core.util.VMError; -import jdk.graal.compiler.serviceprovider.JavaVersionUtil; - /** * Base class for JFR-related diagnostic commands. Note that the JDK already implements those * diagnostic commands, so we wrap and reuse the JDK implementations. @@ -57,16 +55,9 @@ protected String execute(DCmdArguments args) throws Throwable { @Override protected String getSyntaxAndExamples() { Target_jdk_jfr_internal_dcmd_AbstractDCmd cmd = createDCmd(); - String[] lines = getHelp(cmd); + String[] lines = cmd.getHelp(); return String.join(System.lineSeparator(), lines); } - private static String[] getHelp(Target_jdk_jfr_internal_dcmd_AbstractDCmd cmd) { - if (JavaVersionUtil.JAVA_SPEC <= 21) { - return cmd.printHelp(); - } - return cmd.getHelp(); - } - protected abstract Target_jdk_jfr_internal_dcmd_AbstractDCmd createDCmd(); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceInternals.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceInternals.java index 69e81e18c86e..5acf5458c076 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceInternals.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceInternals.java @@ -30,7 +30,6 @@ import java.lang.ref.Reference; import java.lang.ref.SoftReference; -import jdk.graal.compiler.serviceprovider.JavaVersionUtil; import org.graalvm.word.Pointer; import com.oracle.svm.core.NeverInline; @@ -162,8 +161,7 @@ public static void setNextDiscovered(Reference instance, Reference new } public static boolean hasQueue(Reference instance) { - return cast(instance).queue != (JavaVersionUtil.JAVA_SPEC > 21 ? Target_java_lang_ref_ReferenceQueue.NULL_QUEUE - : Target_java_lang_ref_ReferenceQueue.NULL); + return cast(instance).queue != Target_java_lang_ref_ReferenceQueue.NULL_QUEUE; } /* @@ -231,8 +229,7 @@ public static void processPendingReferences() { } else { @SuppressWarnings("unchecked") Target_java_lang_ref_ReferenceQueue queue = SubstrateUtil.cast(ref.queue, Target_java_lang_ref_ReferenceQueue.class); - if (queue != (JavaVersionUtil.JAVA_SPEC > 21 ? Target_java_lang_ref_ReferenceQueue.NULL_QUEUE - : Target_java_lang_ref_ReferenceQueue.NULL)) { + if (queue != Target_java_lang_ref_ReferenceQueue.NULL_QUEUE) { // Enqueues, avoiding the potentially overridden Reference.enqueue(). queue.enqueue(ref); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_Reference.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_Reference.java index 15c8b564a5e9..aa449e624ed3 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_Reference.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_Reference.java @@ -29,7 +29,6 @@ import java.lang.reflect.Field; import java.util.function.BooleanSupplier; -import jdk.graal.compiler.serviceprovider.JavaVersionUtil; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.hosted.FieldValueTransformer; @@ -120,8 +119,7 @@ public final class Target_java_lang_ref_Reference { @Uninterruptible(reason = "The initialization of the fields must be atomic with respect to collection.") Target_java_lang_ref_Reference(T referent, Target_java_lang_ref_ReferenceQueue queue) { this.referent = referent; - this.queue = (queue == null) ? (JavaVersionUtil.JAVA_SPEC > 21 ? Target_java_lang_ref_ReferenceQueue.NULL_QUEUE - : Target_java_lang_ref_ReferenceQueue.NULL) : queue; + this.queue = (queue == null) ? Target_java_lang_ref_ReferenceQueue.NULL_QUEUE : queue; } @KeepOriginal diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_ReferenceQueue.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_ReferenceQueue.java index 396550b6a344..d7145888cdff 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_ReferenceQueue.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_ReferenceQueue.java @@ -31,7 +31,6 @@ import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDK21OrEarlier; import com.oracle.svm.core.jdk.JDKLatest; @TargetClass(ReferenceQueue.class) @@ -42,10 +41,6 @@ final class Target_java_lang_ref_ReferenceQueue { static Target_java_lang_ref_ReferenceQueue NULL_QUEUE; // CheckStyle: resume - @Alias // - @TargetElement(onlyWith = JDK21OrEarlier.class) // - static Target_java_lang_ref_ReferenceQueue NULL; - @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) // volatile Reference head; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_jdk_internal_ref_Cleaner.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_jdk_internal_ref_Cleaner.java index 682ec5381bff..6193ef886eb1 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_jdk_internal_ref_Cleaner.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_jdk_internal_ref_Cleaner.java @@ -27,7 +27,6 @@ import java.lang.ref.Cleaner; import java.lang.ref.ReferenceQueue; -import jdk.graal.compiler.serviceprovider.JavaVersionUtil; import org.graalvm.nativeimage.hosted.FieldValueTransformer; import com.oracle.svm.core.NeverInline; @@ -37,11 +36,11 @@ import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDK21OrEarlier; import com.oracle.svm.core.jdk.JDKLatest; import com.oracle.svm.core.thread.VMThreads; import com.oracle.svm.util.ReflectionUtil; +import jdk.graal.compiler.serviceprovider.JavaVersionUtil; import jdk.internal.misc.InnocuousThread; @TargetClass(className = "jdk.internal.ref.Cleaner") @@ -79,10 +78,6 @@ final class Target_java_lang_ref_Cleaner_Cleanable { @TargetClass(className = "jdk.internal.ref.CleanerImpl") final class Target_jdk_internal_ref_CleanerImpl { - @TargetElement(onlyWith = JDK21OrEarlier.class)// - @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClassName = "jdk.internal.ref.CleanerImpl$PhantomCleanableRef")// - Target_jdk_internal_ref_PhantomCleanable_JDK21 phantomCleanableList; - @TargetElement(onlyWith = JDKLatest.class)// @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClassName = "jdk.internal.ref.CleanerImpl$CleanableList")// Target_jdk_internal_ref_CleanerImpl_CleanableList activeList; @@ -90,33 +85,6 @@ final class Target_jdk_internal_ref_CleanerImpl { @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClassName = "java.lang.ref.ReferenceQueue")// public ReferenceQueue queue; - /** - * This loop executes in a daemon thread and waits until there are no more cleanables (including - * the {@code Cleaner} itself), ignoring {@link InterruptedException}. This blocks VM tear-down, - * so we add a check if the VM is tearing down here. - */ - @TargetElement(name = "run", onlyWith = JDK21OrEarlier.class) - @Substitute - public void runJDK21() { - Thread t = Thread.currentThread(); - InnocuousThread mlThread = (t instanceof InnocuousThread) ? (InnocuousThread) t : null; - while (!phantomCleanableList.isListEmpty()) { - if (mlThread != null) { - mlThread.eraseThreadLocals(); - } - try { - Cleaner.Cleanable ref = (Cleaner.Cleanable) queue.remove(60 * 1000L); - if (ref != null) { - ref.clean(); - } - } catch (Throwable e) { - if (VMThreads.isTearingDown()) { - return; - } - } - } - } - @TargetElement(name = "run", onlyWith = JDKLatest.class) @Substitute public void run() { @@ -140,27 +108,6 @@ public void run() { } } -@TargetClass(className = "jdk.internal.ref.PhantomCleanable", onlyWith = JDK21OrEarlier.class) -final class Target_jdk_internal_ref_PhantomCleanable_JDK21 { - /* - * Unlink from the list for the image heap so that we cannot reach Cleanables irrelevant for the - * image heap which could fail the image build; we reset the list head anyway. - */ - @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = HolderObjectFieldTransformer.class) // - Target_jdk_internal_ref_PhantomCleanable_JDK21 prev; - @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = HolderObjectFieldTransformer.class) // - Target_jdk_internal_ref_PhantomCleanable_JDK21 next; - @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = HolderObjectFieldTransformer.class) // - Target_jdk_internal_ref_PhantomCleanable_JDK21 list; - - @Alias - native boolean isListEmpty(); - - @AnnotateOriginal - @NeverInline("Ensure that every exception can be caught, including implicit exceptions.") - /* final */ native void clean(); -} - @TargetClass(className = "jdk.internal.ref.PhantomCleanable", onlyWith = JDKLatest.class) final class Target_jdk_internal_ref_PhantomCleanable { @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = GetCleanableListSingletonTransformer.class) // diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHub.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHub.java index c2ca3e8b5677..c86b2987bff2 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHub.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHub.java @@ -114,7 +114,6 @@ import com.oracle.svm.core.heap.UnknownPrimitiveField; import com.oracle.svm.core.imagelayer.DynamicImageLayerInfo; import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; -import com.oracle.svm.core.jdk.JDK21OrEarlier; import com.oracle.svm.core.jdk.JDKLatest; import com.oracle.svm.core.jdk.ProtectionDomainSupport; import com.oracle.svm.core.jdk.Resources; @@ -1113,10 +1112,6 @@ void setClassLoaderAtRuntime(ClassLoader loader) { @KeepOriginal private native boolean isAnonymousClass(); - @KeepOriginal - @TargetElement(onlyWith = JDK21OrEarlier.class) - private native boolean isUnnamedClass(); - @Substitute @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) public boolean isHidden() { @@ -1500,29 +1495,6 @@ private RecordComponent[] getRecordComponents0() { @KeepOriginal private native Class[] getPermittedSubclasses(); - @TargetElement(onlyWith = JDK21OrEarlier.class) - @Substitute - @SuppressWarnings("unused") - private void checkMemberAccess(SecurityManager sm, int which, Class caller, boolean checkProxyInterfaces) { - /* No runtime access checks. */ - } - - @TargetElement(onlyWith = JDK21OrEarlier.class) - @Substitute - @SuppressWarnings({"deprecation", "unused"}) - private void checkPackageAccess(SecurityManager sm, ClassLoader ccl, boolean checkProxyInterfaces) { - /* No runtime access checks. */ - } - - /** - * Never called as it is partially evaluated away due to SecurityManager. - */ - @TargetElement(onlyWith = JDK21OrEarlier.class) - @KeepOriginal - @SuppressWarnings({"deprecation", "unused"}) - private static native void checkPackageAccessForPermittedSubclasses(@SuppressWarnings("removal") SecurityManager sm, - ClassLoader ccl, Class[] subClasses); - @Substitute private static ReflectionFactory getReflectionFactory() { return Target_jdk_internal_reflect_ReflectionFactory.getReflectionFactory(); @@ -1634,9 +1606,7 @@ private static Class forName(Module module, String className) throws Throwabl return forName(module, className, Reflection.getCallerClass()); } - @Substitute @CallerSensitiveAdapter - @TargetElement(onlyWith = JDK21OrEarlier.class) private static Class forName(@SuppressWarnings("unused") Module module, String className, Class caller) throws Throwable { /* * The module system is not supported for now, therefore the module parameter is ignored and @@ -1655,9 +1625,7 @@ private static Class forName(String name, boolean initialize, ClassLoader loa return forName(name, initialize, loader, Reflection.getCallerClass()); } - @Substitute @CallerSensitiveAdapter - @TargetElement(onlyWith = JDK21OrEarlier.class) private static Class forName(String name, boolean initialize, ClassLoader loader, @SuppressWarnings("unused") Class caller) throws Throwable { if (name == null) { throw new NullPointerException(); @@ -1767,12 +1735,6 @@ public ProtectionDomain getProtectionDomain() { return companion.protectionDomain; } - @Substitute - @TargetElement(onlyWith = JDK21OrEarlier.class) - private ProtectionDomain protectionDomain() { - return getProtectionDomain(); - } - void setProtectionDomainAtRuntime(ProtectionDomain protectionDomain) { VMError.guarantee(companion.protectionDomain == null && protectionDomain != null); companion.protectionDomain = protectionDomain; @@ -2101,10 +2063,6 @@ private Class[] getPermittedSubclasses0() { @KeepOriginal private static native void addAll(Collection c, Field[] o); - @KeepOriginal - @TargetElement(onlyWith = JDK21OrEarlier.class) - private native Target_java_lang_PublicMethods_MethodList getMethodsRecursive(String methodName, Class[] parameterTypes, boolean includeStatic); - @KeepOriginal @TargetElement(onlyWith = JDKLatest.class) private native Target_java_lang_PublicMethods_MethodList getMethodsRecursive(String methodName, Class[] parameterTypes, boolean includeStatic, boolean publicOnly); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/SunReflectTypeSubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/SunReflectTypeSubstitutions.java deleted file mode 100644 index 7fc00500f05c..000000000000 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/SunReflectTypeSubstitutions.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2017, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.svm.core.hub; - -import java.lang.reflect.GenericDeclaration; - -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.jdk.JDK21OrEarlier; - -@TargetClass(value = sun.reflect.generics.reflectiveObjects.TypeVariableImpl.class, onlyWith = JDK21OrEarlier.class) -final class Target_sun_reflect_generics_reflectiveObjects_TypeVariableImpl { - - @Alias GenericDeclaration genericDeclaration; - - /** Reason for substitutions: disable access checks in original method. */ - @Substitute - public GenericDeclaration getGenericDeclaration() { - return genericDeclaration; - } -} - -public class SunReflectTypeSubstitutions { -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ForeignDisabledSubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ForeignDisabledSubstitutions.java index c53431a100bc..99e9a956c262 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ForeignDisabledSubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ForeignDisabledSubstitutions.java @@ -52,13 +52,6 @@ public boolean getAsBoolean() { @TargetClass(className = "jdk.internal.foreign.MemorySessionImpl", onlyWith = ForeignDisabled.class) final class Target_jdk_internal_foreign_MemorySessionImpl { - @Substitute - @SuppressWarnings("static-method") - @TargetElement(name = "asArena", onlyWith = JDK21OrEarlier.class) - Target_java_lang_foreign_Arena asArenaJDK21() { - throw ForeignDisabledSubstitutions.fail(); - } - @Substitute @SuppressWarnings("static-method") @TargetElement(onlyWith = JDKLatest.class) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaLangSubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaLangSubstitutions.java index def6b688c365..5cbd61ea5c27 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaLangSubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaLangSubstitutions.java @@ -32,7 +32,6 @@ import java.io.InputStream; import java.io.PrintStream; import java.net.URL; -import java.security.Permission; import java.util.Enumeration; import java.util.Map; import java.util.Properties; @@ -41,7 +40,6 @@ import java.util.function.BooleanSupplier; import java.util.stream.Stream; -import com.oracle.svm.core.util.BasedOnJDKFile; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.hosted.FieldValueTransformer; @@ -71,6 +69,7 @@ import com.oracle.svm.core.snippets.SubstrateForeignCallTarget; import com.oracle.svm.core.thread.JavaThreads; import com.oracle.svm.core.thread.VMOperation; +import com.oracle.svm.core.util.BasedOnJDKFile; import com.oracle.svm.core.util.VMError; import com.oracle.svm.util.ReflectionUtil; @@ -426,37 +425,6 @@ private static String getProperty(String key, String def) { @Alias private static native void checkKey(String key); - - /** - * Force System.Never in case it was set at build time via the `-Djava.security.manager=allow` - * passed to the image builder. - */ - @Alias @RecomputeFieldValue(kind = Kind.FromAlias, isFinal = true) // - @TargetElement(onlyWith = JDK21OrEarlier.class) private static int allowSecurityManager = 1; - - /** - * We do not support the {@link SecurityManager} so this method must throw a - * {@link SecurityException} when 'java.security.manager' is set to anything but - * disallow. - * - * @see System#setSecurityManager(SecurityManager) - * @see SecurityManager - */ - @Substitute - @SuppressWarnings({"removal", "javadoc"}) - @TargetElement(onlyWith = JDK21OrEarlier.class) - private static void setSecurityManager(SecurityManager sm) { - if (sm != null) { - /* Read the property collected at isolate creation as that is what happens on the JVM */ - String smp = SystemPropertiesSupport.singleton().getInitialProperty("java.security.manager"); - if (smp != null && !smp.equals("disallow")) { - throw new SecurityException("Setting the SecurityManager is not supported by Native Image"); - } else { - throw new UnsupportedOperationException( - "The Security Manager is deprecated and will be removed in a future release"); - } - } - } } final class NotAArch64 implements BooleanSupplier { @@ -711,15 +679,6 @@ public static Enumeration findResources(String name) { // Checkstyle: resume } -@TargetClass(value = jdk.internal.logger.LoggerFinderLoader.class) -final class Target_jdk_internal_logger_LoggerFinderLoader { - // Checkstyle: stop - @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset, isFinal = true)// - @TargetElement(onlyWith = JDK21OrEarlier.class)// - static Permission READ_PERMISSION; - // Checkstyle: resume -} - final class ClassLoaderValueMapFieldValueTransformer implements FieldValueTransformer { @Override public Object transform(Object receiver, Object originalValue) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RecomputedFields.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RecomputedFields.java index bbbe5e31498b..62dd4a3bab4f 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RecomputedFields.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RecomputedFields.java @@ -188,43 +188,6 @@ final class Target_java_util_concurrent_atomic_AtomicLongFieldUpdater_CASUpdater } -@TargetClass(className = "java.util.concurrent.atomic.AtomicLongFieldUpdater$LockedUpdater", onlyWith = JDK21OrEarlier.class) -final class Target_java_util_concurrent_atomic_AtomicLongFieldUpdater_LockedUpdater { - @Alias @RecomputeFieldValue(kind = AtomicFieldUpdaterOffset) // - private long offset; - - /** the same as tclass, used for checks */ - @Alias private Class cclass; - /** class holding the field */ - @Alias private Class tclass; - - // simplified version of the original constructor - @SuppressWarnings("unused") - @Substitute - Target_java_util_concurrent_atomic_AtomicLongFieldUpdater_LockedUpdater(final Class tclass, - final String fieldName, final Class caller) { - Field field = null; - int modifiers = 0; - try { - field = tclass.getDeclaredField(fieldName); - modifiers = field.getModifiers(); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - - if (field.getType() != long.class) - throw new IllegalArgumentException("Must be long type"); - - if (!Modifier.isVolatile(modifiers)) - throw new IllegalArgumentException("Must be volatile type"); - - // access checks are disabled - this.cclass = tclass; - this.tclass = tclass; - this.offset = Unsafe.getUnsafe().objectFieldOffset(field); - } -} - @AutomaticallyRegisteredFeature @Platforms(InternalPlatform.NATIVE_ONLY.class) class InnocuousForkJoinWorkerThreadFeature implements InternalFeature { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SecuritySubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SecuritySubstitutions.java index 51fa6c0300ec..6a09fa07222a 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SecuritySubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SecuritySubstitutions.java @@ -29,14 +29,11 @@ import java.lang.ref.ReferenceQueue; import java.lang.reflect.Constructor; import java.net.URL; -import java.security.AccessControlContext; import java.security.CodeSource; import java.security.Permission; import java.security.PermissionCollection; import java.security.Permissions; import java.security.Policy; -import java.security.PrivilegedAction; -import java.security.PrivilegedExceptionAction; import java.security.ProtectionDomain; import java.security.Provider; import java.security.SecureRandom; @@ -57,14 +54,11 @@ import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.Delete; import com.oracle.svm.core.annotate.InjectAccessors; import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.graal.snippets.CEntryPointSnippets; -import com.oracle.svm.core.thread.Target_java_lang_Thread; import com.oracle.svm.core.thread.Target_java_lang_ThreadLocal; import com.oracle.svm.core.util.BasedOnJDKFile; import com.oracle.svm.core.util.VMError; @@ -76,88 +70,6 @@ * All security checks are disabled. */ -@TargetClass(value = java.security.AccessController.class, onlyWith = JDK21OrEarlier.class) -@Platforms(InternalPlatform.NATIVE_ONLY.class) -@SuppressWarnings({"unused"}) -final class Target_java_security_AccessController { - - @Substitute - @SuppressWarnings("deprecation") - static AccessControlContext getStackAccessControlContext() { - if (!CEntryPointSnippets.isIsolateInitialized()) { - /* - * If isolate still isn't initialized, we can assume that we are so early in the JDK - * initialization that any attempt at stalk walk will fail as not even the basic - * PrintWriter/Logging is available yet. This manifested when - * UseDedicatedVMOperationThread hosted option was set, triggering a runtime crash. - */ - return null; - } - return StackAccessControlContextVisitor.getFromStack(); - } - - @Substitute - static AccessControlContext getInheritedAccessControlContext() { - return SubstrateUtil.cast(Thread.currentThread(), Target_java_lang_Thread.class).inheritedAccessControlContext; - } - - @Substitute - private static ProtectionDomain getProtectionDomain(final Class caller) { - return caller.getProtectionDomain(); - } - - @Substitute - @SuppressWarnings("deprecation") // deprecated starting JDK 17 - static T executePrivileged(PrivilegedExceptionAction action, AccessControlContext context, Class caller) throws Throwable { - if (action == null) { - throw new NullPointerException("Null action"); - } - - PrivilegedStack.push(context, caller); - try { - return action.run(); - } finally { - PrivilegedStack.pop(); - } - } - - @Substitute - @SuppressWarnings("deprecation") // deprecated starting JDK 17 - static T executePrivileged(PrivilegedAction action, AccessControlContext context, Class caller) { - if (action == null) { - throw new NullPointerException("Null action"); - } - - PrivilegedStack.push(context, caller); - try { - return action.run(); - } finally { - PrivilegedStack.pop(); - } - } - - @Substitute - @SuppressWarnings("deprecation") - static AccessControlContext checkContext(AccessControlContext context, Class caller) { - - if (context != null && context.equals(AccessControllerUtil.DISALLOWED_CONTEXT_MARKER)) { - VMError.shouldNotReachHere( - "Non-allowed AccessControlContext that was replaced with a blank one at build time was invoked without being reinitialized at run time." + System.lineSeparator() + - "This might be an indicator of improper build time initialization, or of a non-compatible JDK version." + System.lineSeparator() + - "In order to fix this you can either:" + System.lineSeparator() + - " * Annotate the offending context's field with @RecomputeFieldValue" + System.lineSeparator() + - " * Implement a custom runtime accessor and annotate said field with @InjectAccessors" + System.lineSeparator() + - " * If this context originates from the JDK, and it doesn't leak sensitive info, you can allow it in 'AccessControlContextReplacerFeature.duringSetup'"); - } - - // check if caller is authorized to create context - if (System.getSecurityManager() != null) { - throw VMError.unsupportedFeature("SecurityManager isn't supported"); - } - return context; - } -} - @TargetClass(SecurityManager.class) @Platforms(InternalPlatform.NATIVE_ONLY.class) @SuppressWarnings({"static-method", "unused"}) @@ -196,11 +108,6 @@ final class Target_java_security_Provider_ServiceKey { @TargetClass(value = java.security.Provider.class) final class Target_java_security_Provider { - @Alias // - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = ServiceKeyComputer.class) // - @TargetElement(name = "previousKey", onlyWith = JDK21OrEarlier.class) // - private static Target_java_security_Provider_ServiceKey previousKeyJDK21; - @Alias // @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = ThreadLocalServiceKeyComputer.class) // @TargetElement(onlyWith = JDKLatest.class) // @@ -463,38 +370,6 @@ public boolean test(Class originalClass) { } } -@TargetClass(value = java.security.Policy.class, innerClass = "PolicyInfo", onlyWith = JDK21OrEarlier.class) -final class Target_java_security_Policy_PolicyInfo { -} - -@TargetClass(value = java.security.Policy.class, onlyWith = JDK21OrEarlier.class) -final class Target_java_security_Policy { - - @Delete // - private static Target_java_security_Policy_PolicyInfo policyInfo; - - @Substitute - private static Policy getPolicyNoCheck() { - return AllPermissionsPolicy.SINGLETON; - } - - @Substitute - private static boolean isSet() { - return true; - } - - @Substitute - @SuppressWarnings("unused") - private static void setPolicy(Policy p) { - /* - * We deliberately treat this as a non-recoverable fatal error. We want to prevent bugs - * where an exception is silently ignored by an application and then necessary security - * checks are not in place. - */ - throw VMError.shouldNotReachHere("Installing a Policy is not yet supported"); - } -} - final class AllPermissionsPolicy extends Policy { static final Policy SINGLETON = new AllPermissionsPolicy(); @@ -527,50 +402,6 @@ public boolean implies(ProtectionDomain domain, Permission permission) { } } -/** - * This class is instantiated indirectly from the {@code Policy#getInstance} methods via the - * {@link java.security.Security#getProviders security provider} abstractions. We could just - * substitute the Policy.getInstance methods to return {@link AllPermissionsPolicy#SINGLETON}, this - * version is more fool-proof in case someone manually registers security providers for reflective - * instantiation. - */ -@TargetClass(className = "sun.security.provider.PolicySpiFile", onlyWith = JDK21OrEarlier.class) -@SuppressWarnings({"unused", "static-method", "deprecation"}) -final class Target_sun_security_provider_PolicySpiFile { - - @Substitute - private Target_sun_security_provider_PolicySpiFile(Policy.Parameters params) { - } - - @Substitute - @SuppressWarnings("deprecation") // deprecated starting JDK 17 - private PermissionCollection engineGetPermissions(CodeSource codesource) { - return AllPermissionsPolicy.SINGLETON.getPermissions(codesource); - } - - @Substitute - @SuppressWarnings("deprecation") // deprecated starting JDK 17 - private PermissionCollection engineGetPermissions(ProtectionDomain d) { - return AllPermissionsPolicy.SINGLETON.getPermissions(d); - } - - @Substitute - @SuppressWarnings("deprecation") // deprecated starting JDK 17 - private boolean engineImplies(ProtectionDomain d, Permission p) { - return AllPermissionsPolicy.SINGLETON.implies(d, p); - } - - @Substitute - private void engineRefresh() { - AllPermissionsPolicy.SINGLETON.refresh(); - } -} - -@Delete("Substrate VM does not use SecurityManager, so loading a security policy file would be misleading") -@TargetClass(className = "sun.security.provider.PolicyFile", onlyWith = JDK21OrEarlier.class) -final class Target_sun_security_provider_PolicyFile { -} - @TargetClass(className = "sun.security.jca.ProviderConfig") @SuppressWarnings({"unused", "static-method"}) final class Target_sun_security_jca_ProviderConfig { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/StackTraceUtils.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/StackTraceUtils.java index 190a09d1c3ac..b13f678a9fd0 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/StackTraceUtils.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/StackTraceUtils.java @@ -33,9 +33,6 @@ import java.util.ArrayList; import java.util.Arrays; -import com.oracle.svm.core.hub.DynamicHub; -import com.oracle.svm.core.interpreter.InterpreterFrameSourceInfo; -import com.oracle.svm.core.interpreter.InterpreterSupport; import org.graalvm.nativeimage.AnnotationAccess; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.c.function.CodePointer; @@ -44,7 +41,6 @@ import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.code.CodeInfo; import com.oracle.svm.core.code.CodeInfoQueryResult; @@ -56,7 +52,9 @@ import com.oracle.svm.core.heap.Heap; import com.oracle.svm.core.heap.ReferenceAccess; import com.oracle.svm.core.heap.VMOperationInfos; -import com.oracle.svm.core.snippets.KnownIntrinsics; +import com.oracle.svm.core.hub.DynamicHub; +import com.oracle.svm.core.interpreter.InterpreterFrameSourceInfo; +import com.oracle.svm.core.interpreter.InterpreterSupport; import com.oracle.svm.core.stack.JavaStackFrameVisitor; import com.oracle.svm.core.stack.JavaStackWalker; import com.oracle.svm.core.stack.StackFrameVisitor; @@ -804,26 +802,4 @@ public boolean visitFrame(FrameSourceInfo frameSourceInfo) { return !isPrivileged; } - - @NeverInline("Starting a stack walk in the caller frame") - @SuppressWarnings({"deprecation"}) // deprecated starting JDK 17 - public static AccessControlContext getFromStack() { - StackAccessControlContextVisitor visitor = new StackAccessControlContextVisitor(); - JavaStackWalker.walkCurrentThread(KnownIntrinsics.readCallerStackPointer(), visitor); - Target_java_security_AccessControlContext wrapper; - - if (visitor.localArray.isEmpty()) { - if (visitor.isPrivileged && visitor.privilegedContext == null) { - return null; - } - wrapper = new Target_java_security_AccessControlContext(null, visitor.privilegedContext); - } else { - ProtectionDomain[] context = visitor.localArray.toArray(new ProtectionDomain[visitor.localArray.size()]); - wrapper = new Target_java_security_AccessControlContext(context, visitor.privilegedContext); - } - - wrapper.isPrivileged = visitor.isPrivileged; - wrapper.isAuthorized = true; - return SubstrateUtil.cast(wrapper, AccessControlContext.class); - } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SunMiscSubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SunMiscSubstitutions.java index 31211dd4d8a0..c08b22dcf9bd 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SunMiscSubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SunMiscSubstitutions.java @@ -97,12 +97,6 @@ int pageSize() { return (int) VirtualMemoryProvider.get().getGranularity().rawValue(); } - @Substitute - @TargetElement(name = "arrayBaseOffset", onlyWith = JDK21OrEarlier.class) - public int arrayBaseOffsetJDK21(Class clazz) { - return (int) LayoutEncoding.getArrayBaseOffset(DynamicHub.fromClass(clazz).getLayoutEncoding()).rawValue(); - } - @Substitute @TargetElement(name = "arrayBaseOffset", onlyWith = JDKLatest.class) public long arrayBaseOffset(Class clazz) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_ClassLoader.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_ClassLoader.java index ca93e9d93755..875126ca0b04 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_ClassLoader.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_ClassLoader.java @@ -42,7 +42,6 @@ import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; import com.oracle.svm.core.hub.ClassForNameSupport; import com.oracle.svm.core.hub.PredefinedClassesSupport; import com.oracle.svm.core.hub.RuntimeClassLoading; @@ -149,12 +148,6 @@ Class loadClass(String name, boolean resolve) throws ClassNotFoundException { @Delete static native Class findBootstrapClassOrNull(String name); - @Substitute - @SuppressWarnings("unused") - @TargetElement(onlyWith = JDK21OrEarlier.class) - static void checkClassLoaderPermission(ClassLoader cl, Class caller) { - } - @Substitute // @SuppressWarnings("unused") Class loadClass(Module module, String name) { @@ -245,15 +238,6 @@ private void clearAssertionStatus() { @Delete private static native void registerNatives(); - /** - * Ignores {@code loader}, like {@link Target_java_lang_ClassLoader#loadLibrary} does. - */ - @Substitute - @TargetElement(onlyWith = JDK21OrEarlier.class) - private static long findNative(@SuppressWarnings("unused") ClassLoader loader, String entryName) { - return NativeLibrarySupport.singleton().findSymbol(entryName).rawValue(); - } - @Substitute @SuppressWarnings({"unused", "static-method"}) Class defineClass(byte[] b, int off, int len) throws ClassFormatError { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_Module.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_Module.java index 9156100b8c7b..2ab7d07bacd9 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_Module.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_Module.java @@ -61,10 +61,6 @@ public boolean isNativeAccessEnabled() { throw ForeignDisabledSubstitutions.fail(); } - @Alias - @TargetElement(onlyWith = JDK21OrEarlier.class) - public native void ensureNativeAccess(Class owner, String methodName); - @Alias @TargetElement(onlyWith = JDKLatest.class) public native void ensureNativeAccess(Class owner, String methodName, Class currentClass, boolean jni); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_net_URLClassLoader.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_net_URLClassLoader.java index 2bdcd1620ea8..4c931a946f5b 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_net_URLClassLoader.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_net_URLClassLoader.java @@ -27,7 +27,6 @@ import java.io.Closeable; import java.net.URL; import java.net.URLClassLoader; -import java.security.AccessControlContext; import java.util.ArrayList; import java.util.HashMap; import java.util.WeakHashMap; @@ -35,7 +34,6 @@ import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; @TargetClass(className = "jdk.internal.loader.URLClassPath") @SuppressWarnings({"unused", "static-method"}) @@ -52,11 +50,6 @@ final class Target_jdk_internal_loader_URLClassPath { /* The original locations of the .jar files are no longer available at run time. */ @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClass = ArrayList.class)// private ArrayList path; - - /* Reset acc to null, since contexts in image heap are replaced */ - @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// - @TargetElement(onlyWith = JDK21OrEarlier.class)// - private AccessControlContext acc; } @TargetClass(URLClassLoader.class) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_security_AccessControlContext.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_security_AccessControlContext.java deleted file mode 100644 index 1602bd8bf127..000000000000 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_security_AccessControlContext.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2021, 2021, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.svm.core.jdk; - -import java.security.AccessControlContext; -import java.security.ProtectionDomain; - -import com.oracle.svm.core.AlwaysInline; -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; - -import sun.security.util.Debug; - -@TargetClass(value = java.security.AccessControlContext.class, onlyWith = JDK21OrEarlier.class) -final class Target_java_security_AccessControlContext { - - @Alias // - boolean isPrivileged; - - @Alias // - protected boolean isAuthorized; - - @Alias // - @SuppressWarnings("unused") // - Target_java_security_AccessControlContext(ProtectionDomain[] context, AccessControlContext privilegedContext) { - } - - /** - * Avoid making the code for debug printing reachable. We do not need it, and it only increases - * code size. If we ever want to enable debug printing, several classes related to it need to be - * initialized at run time because configuration parsing is in a class initializer. - */ - @Substitute - @AlwaysInline(value = "Null must propagate") - static Debug getDebug() { - return null; - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_util_ServiceLoader.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_util_ServiceLoader.java index 3e5bc4b593fe..180ecb39fa46 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_util_ServiceLoader.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_util_ServiceLoader.java @@ -26,14 +26,12 @@ package com.oracle.svm.core.jdk; import java.lang.reflect.Constructor; -import java.security.AccessControlContext; import java.util.ArrayList; import java.util.List; import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; /** * Disable the module based iteration in favour of classpath based iteration. See @@ -43,9 +41,6 @@ final class Target_java_util_ServiceLoader { @Alias Class service; - @TargetElement(onlyWith = JDK21OrEarlier.class)// - @Alias AccessControlContext acc; - @Alias static native void fail(Class service, String msg); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_util_concurrent_CompletableFuture.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_util_concurrent_CompletableFuture.java index 2a5b8fd5e479..64368a6328a5 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_util_concurrent_CompletableFuture.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_util_concurrent_CompletableFuture.java @@ -24,7 +24,6 @@ */ package com.oracle.svm.core.jdk; -import java.util.concurrent.Executor; import java.util.concurrent.ForkJoinPool; import org.graalvm.nativeimage.hosted.RuntimeClassInitialization; @@ -33,27 +32,15 @@ import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.InjectAccessors; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.util.VMError; -import jdk.graal.compiler.serviceprovider.JavaVersionUtil; - @TargetClass(java.util.concurrent.CompletableFuture.class) final class Target_java_util_concurrent_CompletableFuture { // Checkstyle: stop - @Alias @InjectAccessors(CompletableFutureUseCommonPoolJDK21Accessor.class) // - @TargetElement(onlyWith = JDK21OrEarlier.class) // - private static boolean USE_COMMON_POOL; - - @Alias @InjectAccessors(CompletableFutureAsyncPoolJDK21Accessor.class) // - @TargetElement(onlyWith = JDK21OrEarlier.class) // - private static Executor ASYNC_POOL; - @Alias @InjectAccessors(CompletableFutureAsyncPoolAccessor.class) // - @TargetElement(name = "ASYNC_POOL", onlyWith = JDKLatest.class) // - private static ForkJoinPool ASYNC_POOL_JDK_LATEST; + private static ForkJoinPool ASYNC_POOL; // Checkstyle: resume } @@ -85,61 +72,23 @@ class DelaySchedulerNanoTimeOffsetHolder { } } -class CompletableFutureUseCommonPoolJDK21Accessor { - static boolean get() { - return CompletableFutureJDK21FieldHolder.USE_COMMON_POOL; - } -} - -class CompletableFutureAsyncPoolJDK21Accessor { - static Executor get() { - return CompletableFutureJDK21FieldHolder.ASYNC_POOL; - } -} - class CompletableFutureAsyncPoolAccessor { static ForkJoinPool get() { return CompletableFutureFieldHolder.ASYNC_POOL; } } -/* Note that this class is initialized at run time. */ -class CompletableFutureJDK21FieldHolder { - /* The following is copied from CompletableFuture. */ - - static final boolean USE_COMMON_POOL = ForkJoinPool.getCommonPoolParallelism() > 1; - - static final Executor ASYNC_POOL; - - static { - if (JavaVersionUtil.JAVA_SPEC <= 21) { - if (USE_COMMON_POOL) { - ASYNC_POOL = ForkJoinPool.commonPool(); - } else { - ASYNC_POOL = SubstrateUtil.cast(new Target_java_util_concurrent_CompletableFuture_ThreadPerTaskExecutor(), Executor.class); - } - } else { - ASYNC_POOL = null; - } - } -} - /* Note that this class is initialized at run time. */ class CompletableFutureFieldHolder { /* The following is copied from CompletableFuture. */ static final ForkJoinPool ASYNC_POOL = Target_java_util_concurrent_ForkJoinPool.asyncCommonPool(); } -@TargetClass(value = java.util.concurrent.CompletableFuture.class, innerClass = "ThreadPerTaskExecutor", onlyWith = JDK21OrEarlier.class) -final class Target_java_util_concurrent_CompletableFuture_ThreadPerTaskExecutor { -} - @AutomaticallyRegisteredFeature class CompletableFutureFeature implements InternalFeature { @Override public void duringSetup(DuringSetupAccess access) { RuntimeClassInitialization.initializeAtRunTime(CompletableFutureFieldHolder.class); - RuntimeClassInitialization.initializeAtRunTime(CompletableFutureJDK21FieldHolder.class); RuntimeClassInitialization.initializeAtRunTime(DelaySchedulerNanoTimeOffsetHolder.class); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_util_concurrent_ForkJoinTask.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_util_concurrent_ForkJoinTask.java index 7692abc0f0fa..d8e6be663199 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_util_concurrent_ForkJoinTask.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_util_concurrent_ForkJoinTask.java @@ -28,9 +28,9 @@ import java.util.concurrent.ExecutionException; import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.annotate.Substitute; import jdk.graal.compiler.core.common.SuppressFBWarnings; @@ -52,16 +52,6 @@ final class Target_java_util_concurrent_ForkJoinTask { * by the original method. */ @Substitute - @TargetElement(onlyWith = JDK21OrEarlier.class) - private Throwable getThrowableException() { - Target_java_util_concurrent_ForkJoinTask_Aux a = aux; - return a != null ? a.ex : null; - } - - /** - * JDK24 variant of the above. - */ - @Substitute @TargetElement(onlyWith = JDKLatest.class) @SuppressWarnings("all") @SuppressFBWarnings(value = "BC_IMPOSSIBLE_INSTANCEOF", justification = "Check for @TargetClass") diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_misc_VM.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_misc_VM.java index 4408a2f86d73..00accd83255e 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_misc_VM.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_misc_VM.java @@ -71,10 +71,6 @@ public static ClassLoader latestUserDefinedLoader0() { @Alias @InjectAccessors(PageAlignDirectMemoryAccessors.class) // @TargetElement(onlyWith = JDKLatest.class) // private static Boolean pageAlignDirectMemory; - - @Alias @InjectAccessors(PageAlignDirectMemoryJDK21Accessors.class) // - @TargetElement(name = "pageAlignDirectMemory", onlyWith = JDK21OrEarlier.class) // - private static boolean pageAlignDirectMemoryJDK21; } final class DirectMemoryAccessors { @@ -146,9 +142,3 @@ private static void initialize() { initialized = true; } } - -final class PageAlignDirectMemoryJDK21Accessors { - static boolean getPageAlignDirectMemory() { - return PageAlignDirectMemoryAccessors.getPageAlignDirectMemory(); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/substitutions/Target_java_util_ResourceBundle.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/substitutions/Target_java_util_ResourceBundle.java index b38721dff8af..9bd8f8870a1f 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/substitutions/Target_java_util_ResourceBundle.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/substitutions/Target_java_util_ResourceBundle.java @@ -25,7 +25,6 @@ package com.oracle.svm.core.jdk.localization.substitutions; import java.util.Locale; -import java.util.Objects; import java.util.ResourceBundle; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -37,14 +36,11 @@ import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDK21OrEarlier; import com.oracle.svm.core.jdk.localization.LocalizationSupport; import com.oracle.svm.core.jdk.localization.substitutions.modes.OptimizedLocaleMode; import com.oracle.svm.core.jdk.resources.MissingResourceRegistrationUtils; -import com.oracle.svm.util.ReflectionUtil; import jdk.internal.loader.BootLoader; -import sun.security.util.SecurityConstants; @TargetClass(java.util.ResourceBundle.class) @SuppressWarnings({"unused"}) @@ -136,29 +132,6 @@ private static ResourceBundle getBundleImpl(String baseName, return getBundleImpl(callerModule, unnamedModule, baseName, locale, control); } - @Substitute - @SuppressWarnings({"removal", "deprecation"}) - @TargetElement(onlyWith = JDK21OrEarlier.class) - private static ResourceBundle getBundleFromModule(Class caller, - Module module, - String baseName, - Locale locale, - ResourceBundle.Control control) { - Objects.requireNonNull(module); - Module callerModule = getCallerModule(caller); - if (callerModule != module) { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - RuntimePermission getClassLoaderPermission = ReflectionUtil.readField(SecurityConstants.class, "GET_CLASSLOADER_PERMISSION", null); - sm.checkPermission(getClassLoaderPermission); - } - } - if (!ImageSingletons.lookup(LocalizationSupport.class).isRegisteredBundleLookup(baseName, locale, control)) { - MissingResourceRegistrationUtils.missingResourceBundle(baseName); - } - return getBundleImpl(callerModule, module, baseName, locale, control); - } - @Alias private static native Module getCallerModule(Class caller); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/proxy/ProxySubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/proxy/ProxySubstitutions.java index d1098a897a3e..602f441bcda8 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/proxy/ProxySubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/proxy/ProxySubstitutions.java @@ -34,7 +34,6 @@ import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.annotate.TargetElement; import com.oracle.svm.core.hub.DynamicHub; -import com.oracle.svm.core.jdk.JDK21OrEarlier; import com.oracle.svm.core.jdk.JDKLatest; @TargetClass(java.lang.reflect.Proxy.class) @@ -44,20 +43,6 @@ final class Target_java_lang_reflect_Proxy { @Delete // private static Target_jdk_internal_loader_ClassLoaderValue proxyCache; - @Substitute - @SuppressWarnings("unused") - @TargetElement(name = "getProxyConstructor", onlyWith = JDK21OrEarlier.class) - private static Constructor getProxyConstructorJDK21(Class caller, ClassLoader loader, Class... interfaces) { - final Class cl = ImageSingletons.lookup(DynamicProxyRegistry.class).getProxyClass(loader, interfaces); - try { - final Constructor cons = cl.getConstructor(InvocationHandler.class); - cons.setAccessible(true); - return cons; - } catch (NoSuchMethodException e) { - throw new InternalError(e.toString(), e); - } - } - @Substitute @TargetElement(onlyWith = JDKLatest.class) private static Constructor getProxyConstructor(ClassLoader loader, Class... interfaces) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrEventWriterAccess.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrEventWriterAccess.java index aa68d34812fe..feeca8856d82 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrEventWriterAccess.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrEventWriterAccess.java @@ -26,13 +26,12 @@ import java.lang.reflect.Field; -import com.oracle.svm.core.thread.JavaThreads; -import jdk.graal.compiler.serviceprovider.JavaVersionUtil; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.Pointer; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.thread.JavaThreads; import com.oracle.svm.util.ReflectionUtil; import jdk.internal.misc.Unsafe; @@ -55,9 +54,6 @@ public static Target_jdk_jfr_internal_event_EventWriter newEventWriter(JfrBuffer long committedPos = buffer.getCommittedPos().rawValue(); long maxPos = JfrBufferAccess.getDataEnd(buffer).rawValue(); long jfrThreadId = SubstrateJVM.getCurrentThreadId(); - if (JavaVersionUtil.JAVA_SPEC <= 21) { - return new Target_jdk_jfr_internal_event_EventWriter(committedPos, maxPos, jfrThreadId, true, isCurrentThreadExcluded); - } boolean pinVirtualThread = JavaThreads.isCurrentThreadVirtual(); return new Target_jdk_jfr_internal_event_EventWriter(committedPos, maxPos, jfrThreadId, true, pinVirtualThread, isCurrentThreadExcluded); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrJdkCompatibility.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrJdkCompatibility.java index 500ca7a5612d..f1b96741a163 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrJdkCompatibility.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrJdkCompatibility.java @@ -37,7 +37,6 @@ import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.jdk.JDK21OrEarlier; import com.oracle.svm.core.jdk.JDKLatest; import com.oracle.svm.core.util.VMError; import com.oracle.svm.util.ReflectionUtil; @@ -58,19 +57,11 @@ private JfrJdkCompatibility() { } public static String makeFilename(Recording recording) { - if (JavaVersionUtil.JAVA_SPEC >= 22) { - return Target_jdk_jfr_internal_JVMSupport.makeFilename(recording); - } else { - return Target_jdk_jfr_internal_Utils.makeFilename(recording); - } + return Target_jdk_jfr_internal_JVMSupport.makeFilename(recording); } public static String formatTimespan(Duration dValue, String separation) { - if (JavaVersionUtil.JAVA_SPEC >= 22) { - return Target_jdk_jfr_internal_util_ValueFormatter.formatTimespan(dValue, separation); - } else { - return Target_jdk_jfr_internal_Utils.formatTimespan(dValue, separation); - } + return Target_jdk_jfr_internal_util_ValueFormatter.formatTimespan(dValue, separation); } @Platforms(Platform.HOSTED_ONLY.class) @@ -114,20 +105,6 @@ public static JVM getJVMOrNull() throws IllegalAccessException, InvocationTarget } } -@TargetClass(className = "jdk.jfr.internal.Utils", onlyWith = {JDK21OrEarlier.class, HasJfrSupport.class}) -final class Target_jdk_jfr_internal_Utils { - @Substitute - public static String makeFilename(Recording recording) { - return JfrFilenameUtil.makeFilename(recording); - } - - @Alias - public static native String formatTimespan(Duration dValue, String separation); - - @Alias - public static native String formatDateTime(LocalDateTime time); -} - @TargetClass(className = "jdk.jfr.internal.JVMSupport", onlyWith = {JDKLatest.class, HasJfrSupport.class}) final class Target_jdk_jfr_internal_JVMSupport { @Substitute @@ -156,9 +133,6 @@ public static String makeFilename(Recording recording) { private static String getFormatDateTime() { LocalDateTime now = LocalDateTime.now(); - if (JavaVersionUtil.JAVA_SPEC >= 24) { - return Target_jdk_jfr_internal_util_ValueFormatter.formatDateTime(now); - } - return Target_jdk_jfr_internal_Utils.formatDateTime(now); + return Target_jdk_jfr_internal_util_ValueFormatter.formatDateTime(now); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrManager.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrManager.java index e0374af16d49..a83bcebbb805 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrManager.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrManager.java @@ -50,7 +50,6 @@ import com.oracle.svm.core.util.BasedOnJDKFile; import jdk.graal.compiler.api.replacements.Fold; -import jdk.graal.compiler.serviceprovider.JavaVersionUtil; import jdk.jfr.FlightRecorder; import jdk.jfr.internal.LogLevel; import jdk.jfr.internal.LogTag; @@ -148,13 +147,8 @@ private static void parseFlightRecorderOptions() throws JfrArgumentParsingFailed } private static void setRepositoryBasePath(String repositoryPath) throws IOException { - if (JavaVersionUtil.JAVA_SPEC == 21) { - Target_jdk_jfr_internal_SecuritySupport_SafePath_JDK21 repositorySafePath = new Target_jdk_jfr_internal_SecuritySupport_SafePath_JDK21(repositoryPath); - SubstrateUtil.cast(Repository.getRepository(), Target_jdk_jfr_internal_Repository_JDK21.class).setBasePath(repositorySafePath); - } else { - Path path = Paths.get(repositoryPath); - SubstrateUtil.cast(Repository.getRepository(), Target_jdk_jfr_internal_Repository.class).setBasePath(path); - } + Path path = Paths.get(repositoryPath); + SubstrateUtil.cast(Repository.getRepository(), Target_jdk_jfr_internal_Repository.class).setBasePath(path); } public static RuntimeSupport.Hook shutdownHook() { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/SubstrateJVM.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/SubstrateJVM.java index 2d6f977d5a06..5fe55113dc2c 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/SubstrateJVM.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/SubstrateJVM.java @@ -53,7 +53,6 @@ import jdk.graal.compiler.api.replacements.Fold; import jdk.graal.compiler.core.common.NumUtil; -import jdk.graal.compiler.serviceprovider.JavaVersionUtil; import jdk.graal.compiler.word.Word; import jdk.internal.event.Event; import jdk.jfr.Configuration; @@ -597,11 +596,7 @@ public void setDumpPath(String dumpPathText) { */ public String getDumpPath() { if (dumpPath == null) { - if (JavaVersionUtil.JAVA_SPEC == 21) { - dumpPath = Target_jdk_jfr_internal_SecuritySupport_JDK21.getPathInProperty("user.home", null).toString(); - } else { - dumpPath = Target_jdk_jfr_internal_util_Utils.getPathInProperty("user.home", null).toString(); - } + dumpPath = Target_jdk_jfr_internal_util_Utils.getPathInProperty("user.home", null).toString(); } return dumpPath; } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM_ChunkRotationMonitor.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM_ChunkRotationMonitor.java deleted file mode 100644 index 665d350fea39..000000000000 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM_ChunkRotationMonitor.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2023, 2023, Red Hat Inc. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.oracle.svm.core.jfr; - -import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.jdk.JDK21OrEarlier; - -@TargetClass(className = "jdk.jfr.internal.JVM$ChunkRotationMonitor", onlyWith = {HasJfrSupport.class, JDK21OrEarlier.class}) -public final class Target_jdk_jfr_internal_JVM_ChunkRotationMonitor { -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM_JDK21.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM_JDK21.java deleted file mode 100644 index f7f47ef66c78..000000000000 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM_JDK21.java +++ /dev/null @@ -1,370 +0,0 @@ -/* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.svm.core.jfr; - -import java.util.List; - -import com.oracle.svm.core.heap.PhysicalMemory; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.ProcessProperties; - -import com.oracle.svm.core.Uninterruptible; -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.RecomputeFieldValue; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.container.Container; -import com.oracle.svm.core.jdk.JDK21OrEarlier; -import com.oracle.svm.core.jfr.traceid.JfrTraceId; - -import jdk.jfr.internal.JVM; - -@SuppressWarnings({"static-method", "unused"}) -@TargetClass(value = JVM.class, onlyWith = {JDK21OrEarlier.class, HasJfrSupport.class}) -final class Target_jdk_jfr_internal_JVM_JDK21 { - - @Alias // - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) // - private volatile boolean nativeOK; - - @Substitute - public void markChunkFinal() { - SubstrateJVM.get().markChunkFinal(); - } - - /** See {@link JVM#beginRecording}. */ - @Substitute - public void beginRecording() { - SubstrateJVM.get().beginRecording(); - } - - /** See {@link JVM#isRecording}. */ - @Substitute - @Uninterruptible(reason = "Needed for calling SubstrateJVM.isRecording().") - public boolean isRecording() { - return SubstrateJVM.get().isRecording(); - } - - /** See {@link JVM#endRecording}. */ - @Substitute - public void endRecording() { - SubstrateJVM.get().endRecording(); - } - - /** See {@link JVM#emitEvent}. */ - @Substitute - public boolean emitEvent(long eventTypeId, long timestamp, long when) { - return false; - } - - /** See {@link JVM#getAllEventClasses}. */ - @Substitute - public List> getAllEventClasses() { - return JfrJavaEvents.getAllEventClasses(); - } - - /** See {@link JVM#getUnloadedEventClassCount}. */ - @Substitute - public long getUnloadedEventClassCount() { - return 0; - } - - /** See {@link JVM#getPid}. */ - @Substitute - public String getPid() { - long id = ProcessProperties.getProcessID(); - return String.valueOf(id); - } - - /** See {@link JVM#getStackTraceId}. */ - @Substitute - @Uninterruptible(reason = "Needed for SubstrateJVM.getStackTraceId().") - public long getStackTraceId(int skipCount) { - /* - * The result is only valid until the epoch changes but this is fine because EventWriter - * instances are invalidated when the epoch changes. - */ - return SubstrateJVM.get().getStackTraceId(skipCount); - } - - /** See {@link JVM#getThreadId}. */ - @Substitute - public long getThreadId(Thread t) { - return SubstrateJVM.getThreadId(t); - } - - /** See {@link JVM#getTicksFrequency}. */ - @Substitute - public long getTicksFrequency() { - return JfrTicks.getTicksFrequency(); - } - - /** See {@link JVM#retransformClasses}. */ - @Substitute - public synchronized void retransformClasses(Class[] classes) { - // Not supported but this method is called during JFR startup, so we can't throw an error. - } - - /** See {@link JVM#setEnabled}. */ - @Substitute - public void setEnabled(long eventTypeId, boolean enabled) { - SubstrateJVM.get().setEnabled(eventTypeId, enabled); - } - - /** See {@link JVM#setFileNotification}. */ - @Substitute - public void setFileNotification(long delta) { - SubstrateJVM.get().setFileNotification(delta); - } - - /** See {@link JVM#setGlobalBufferCount}. */ - @Substitute - public void setGlobalBufferCount(long count) throws IllegalArgumentException, IllegalStateException { - SubstrateJVM.get().setGlobalBufferCount(count); - } - - /** See {@link JVM#setGlobalBufferSize}. */ - @Substitute - public void setGlobalBufferSize(long size) throws IllegalArgumentException { - SubstrateJVM.get().setGlobalBufferSize(size); - } - - /** See {@link JVM#setMemorySize}. */ - @Substitute - public void setMemorySize(long size) throws IllegalArgumentException { - SubstrateJVM.get().setMemorySize(size); - } - - /** See {@code JVM#setMethodSamplingPeriod}. */ - @Substitute - public void setMethodSamplingPeriod(long type, long intervalMillis) { - SubstrateJVM.get().setMethodSamplingInterval(type, intervalMillis); - } - - /** See {@link JVM#setOutput}. */ - @Substitute - public void setOutput(String file) { - SubstrateJVM.get().setOutput(file); - } - - /** See {@link JVM#setForceInstrumentation}. */ - @Substitute - public void setForceInstrumentation(boolean force) { - } - - /** See {@link JVM#setCompressedIntegers}. */ - @Substitute - public void setCompressedIntegers(boolean compressed) throws IllegalStateException { - SubstrateJVM.get().setCompressedIntegers(compressed); - } - - /** See {@link JVM#setStackDepth}. */ - @Substitute - public void setStackDepth(int depth) throws IllegalArgumentException, IllegalStateException { - SubstrateJVM.get().setStackDepth(depth); - } - - /** See {@link JVM#setStackTraceEnabled}. */ - @Substitute - public void setStackTraceEnabled(long eventTypeId, boolean enabled) { - SubstrateJVM.get().setStackTraceEnabled(eventTypeId, enabled); - } - - /** See {@link JVM#setThreadBufferSize}. */ - @Substitute - public void setThreadBufferSize(long size) throws IllegalArgumentException, IllegalStateException { - SubstrateJVM.get().setThreadBufferSize(size); - } - - /** See {@link JVM#setThreshold}. */ - @Substitute - public boolean setThreshold(long eventTypeId, long ticks) { - return SubstrateJVM.get().setThreshold(eventTypeId, ticks); - } - - /** See {@link JVM#storeMetadataDescriptor}. */ - @Substitute - public void storeMetadataDescriptor(byte[] bytes) { - SubstrateJVM.get().storeMetadataDescriptor(bytes); - } - - /** See {@link JVM#getAllowedToDoEventRetransforms}. */ - @Substitute - public boolean getAllowedToDoEventRetransforms() { - return false; - } - - /** See {@link JVM#createJFR}. */ - @Substitute - private boolean createJFR(boolean simulateFailure) throws IllegalStateException { - return SubstrateJVM.get().createJFR(simulateFailure); - } - - /** See {@link JVM#destroyJFR}. */ - @Substitute - private boolean destroyJFR() { - return SubstrateJVM.get().destroyJFR(); - } - - /** See {@link JVM#isAvailable}. */ - @Substitute - public boolean isAvailable() { - return true; - } - - /** See {@link JVM#getTimeConversionFactor}. */ - @Substitute - public double getTimeConversionFactor() { - return 1; - } - - /** See {@link JVM#getTypeId(Class)}. */ - @Substitute - public long getTypeId(Class clazz) { - return JfrTraceId.getTraceId(clazz); - } - - @Substitute - public void flush() { - SubstrateJVM.get().flush(); - } - - /** See {@link JVM#setRepositoryLocation}. */ - @Substitute - public void setRepositoryLocation(String dirText) { - SubstrateJVM.get().setRepositoryLocation(dirText); - } - - /** See {@code JVM#setDumpPath(String)}. */ - @Substitute - public void setDumpPath(String dumpPathText) { - SubstrateJVM.get().setDumpPath(dumpPathText); - } - - /** See {@code JVM#getDumpPath()}. */ - @Substitute - public String getDumpPath() { - return SubstrateJVM.get().getDumpPath(); - } - - /** See {@link JVM#abort}. */ - @Substitute - public void abort(String errorMsg) { - SubstrateJVM.get().abort(errorMsg); - } - - /** See {@link JVM#uncaughtException}. */ - @Substitute - public void uncaughtException(Thread thread, Throwable t) { - // Would be used to determine the emergency dump filename if an exception happens during - // shutdown. - } - - /** See {@link JVM#setCutoff}. */ - @Substitute - public boolean setCutoff(long eventTypeId, long cutoffTicks) { - return SubstrateJVM.get().setCutoff(eventTypeId, cutoffTicks); - } - - /** See {@link JVM#setThrottle}. */ - @Substitute - public boolean setThrottle(long eventTypeId, long eventSampleSize, long periodMs) { - return SubstrateJVM.get().setThrottle(eventTypeId, eventSampleSize, periodMs); - } - - /** See {@link JVM#emitOldObjectSamples}. */ - @Substitute - public void emitOldObjectSamples(long cutoff, boolean emitAll, boolean skipBFS) { - SubstrateJVM.get().emitOldObjectSamples(cutoff, emitAll, skipBFS); - } - - /** See {@link JVM#shouldRotateDisk}. */ - @Substitute - public boolean shouldRotateDisk() { - return SubstrateJVM.get().shouldRotateDisk(); - } - - @Substitute - public void include(Thread thread) { - JfrThreadLocal.setExcluded(thread, false); - } - - @Substitute - public void exclude(Thread thread) { - JfrThreadLocal.setExcluded(thread, true); - } - - @Substitute - public boolean isExcluded(Thread thread) { - return JfrThreadLocal.isThreadExcluded(thread); - } - - @Substitute - public boolean isExcluded(Class eventClass) { - // Temporarily always include. - return false; - } - - @Substitute - public boolean isInstrumented(Class eventClass) { - // This should check for blessed commit methods in the event class [GR-41200] - return true; - } - - /** See {@link SubstrateJVM#getChunkStartNanos}. */ - @Substitute - public long getChunkStartNanos() { - return SubstrateJVM.get().getChunkStartNanos(); - } - - @Substitute - public boolean setConfiguration(Class eventClass, Target_jdk_jfr_internal_event_EventConfiguration configuration) { - return SubstrateJVM.get().setConfiguration(eventClass, configuration); - } - - @Substitute - public Object getConfiguration(Class eventClass) { - return SubstrateJVM.get().getConfiguration(eventClass); - } - - /** See {@link JVM#getTypeId(String)}. */ - @Substitute - public long getTypeId(String name) { - /* Not implemented at the moment. */ - return -1; - } - - @Substitute - public boolean isContainerized() { - return Container.singleton().isContainerized(); - } - - @Substitute - public long hostTotalMemory() { - // This is intentionally using PhysicalMemorySupport since we are - // interested in the host values (and not the containerized values). - return ImageSingletons.lookup(PhysicalMemory.PhysicalMemorySupport.class).size().rawValue(); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_Repository.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_Repository.java index 58f285bc9892..1c2cce289b87 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_Repository.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_Repository.java @@ -31,7 +31,6 @@ import com.oracle.svm.core.annotate.Delete; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.jdk.JDK21OrEarlier; import com.oracle.svm.core.jdk.JDKLatest; import jdk.jfr.internal.Repository; @@ -60,24 +59,6 @@ synchronized void ensureRepository() throws Exception { } } -@TargetClass(value = Repository.class, onlyWith = {HasJfrSupport.class, JDK21OrEarlier.class}) -@SuppressWarnings("unused") -final class Target_jdk_jfr_internal_Repository_JDK21 { - @Alias // - private Target_jdk_jfr_internal_SecuritySupport_SafePath_JDK21 baseLocation; - - @Alias // - public native void setBasePath(Target_jdk_jfr_internal_SecuritySupport_SafePath_JDK21 baseLocation) throws IOException; - - @Substitute - synchronized void ensureRepository() throws Exception { - if (baseLocation == null) { - Target_jdk_jfr_internal_SecuritySupport_SafePath_JDK21 path = Target_jdk_jfr_internal_SecuritySupport_JDK21.getPathInProperty("java.io.tmpdir", null); - setBasePath(path); - } - } -} - @TargetClass(className = "jdk.jfr.internal.util.Utils", onlyWith = {HasJfrSupport.class, JDKLatest.class}) final class Target_jdk_jfr_internal_util_Utils { @Alias diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_SecuritySupport_JDK21.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_SecuritySupport_JDK21.java deleted file mode 100644 index 33981e303f14..000000000000 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_SecuritySupport_JDK21.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.svm.core.jfr; - -import java.util.List; - -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.jdk.JDK21OrEarlier; -import com.oracle.svm.core.util.VMError; - -@TargetClass(value = jdk.jfr.internal.SecuritySupport.class, onlyWith = {HasJfrSupport.class, JDK21OrEarlier.class}) -@SuppressWarnings("unused") -public final class Target_jdk_jfr_internal_SecuritySupport_JDK21 { - - @Substitute - public static List getPredefinedJFCFiles() { - throw VMError.shouldNotReachHere("Paths from the image build must not be embedded into the Native Image."); - } - - @Alias - static native Target_jdk_jfr_internal_SecuritySupport_SafePath_JDK21 getPathInProperty(String prop, String subPath); -} - -@TargetClass(className = "jdk.jfr.internal.SecuritySupport$SafePath", onlyWith = {HasJfrSupport.class, JDK21OrEarlier.class}) -@SuppressWarnings("unused") -final class Target_jdk_jfr_internal_SecuritySupport_SafePath_JDK21 { - @Alias - Target_jdk_jfr_internal_SecuritySupport_SafePath_JDK21(String path) { - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_StringPool.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_StringPool.java index a60799789441..f541e3647210 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_StringPool.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_StringPool.java @@ -27,17 +27,10 @@ import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDK21OrEarlier; import com.oracle.svm.core.jdk.JDKLatest; @TargetClass(value = jdk.jfr.internal.StringPool.class, onlyWith = HasJfrSupport.class) final class Target_jdk_jfr_internal_StringPool { - @Substitute - @TargetElement(onlyWith = JDK21OrEarlier.class) - public static long addString(@SuppressWarnings("unused") String s) { - // This disables String caching and forces the EventWriter to write strings by value. - return -1; - } @SuppressWarnings("unused") @Substitute diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_dcmd_AbstractDCmd.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_dcmd_AbstractDCmd.java index 253b20af9473..483597251dd7 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_dcmd_AbstractDCmd.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_dcmd_AbstractDCmd.java @@ -27,7 +27,6 @@ import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDK21OrEarlier; import com.oracle.svm.core.jdk.JDKLatest; @TargetClass(className = "jdk.jfr.internal.dcmd.AbstractDCmd") @@ -39,10 +38,6 @@ public final class Target_jdk_jfr_internal_dcmd_AbstractDCmd { @TargetElement(onlyWith = JDKLatest.class) public native String[] getHelp(); - @Alias - @TargetElement(onlyWith = JDK21OrEarlier.class) - public native String[] printHelp(); - @Alias native void logWarning(String message); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_event_EventWriter.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_event_EventWriter.java index 9c8e5cd01667..7302d842b49d 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_event_EventWriter.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_event_EventWriter.java @@ -27,7 +27,6 @@ import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDK21OrEarlier; import com.oracle.svm.core.jdk.JDKLatest; @TargetClass(className = "jdk.jfr.internal.event.EventWriter", onlyWith = HasJfrSupport.class) @@ -45,12 +44,6 @@ public final class Target_jdk_jfr_internal_event_EventWriter { @Alias // long maxPosition; - @Alias - @TargetElement(onlyWith = JDK21OrEarlier.class) - @SuppressWarnings("unused") - Target_jdk_jfr_internal_event_EventWriter(long committedPos, long maxPos, long threadID, boolean valid, boolean excluded) { - } - @Alias @TargetElement(onlyWith = JDKLatest.class) @SuppressWarnings("unused") diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_instrument_JDKEvents.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_instrument_JDKEvents.java index f6cb76b489b2..88255ea4c718 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_instrument_JDKEvents.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_instrument_JDKEvents.java @@ -27,8 +27,6 @@ import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDK21OrEarlier; import jdk.jfr.events.ActiveRecordingEvent; import jdk.jfr.events.ActiveSettingEvent; @@ -42,14 +40,4 @@ final class Target_jdk_jfr_internal_instrument_JDKEvents { ActiveSettingEvent.class, ActiveRecordingEvent.class }; - - // This is a list of the classes with instrumentation code that should be applied. - @Alias // - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias, isFinal = true) // - @TargetElement(onlyWith = JDK21OrEarlier.class) private static Class[] instrumentationClasses = new Class[]{}; - - @Alias // - @TargetElement(onlyWith = JDK21OrEarlier.class) // - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias, isFinal = true) // - private static Class[] mirrorEventClasses = new Class[]{}; } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/events/JavaMonitorWaitEvent.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/events/JavaMonitorWaitEvent.java index a70d09bca7b9..00fa915f4f76 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/events/JavaMonitorWaitEvent.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/events/JavaMonitorWaitEvent.java @@ -34,15 +34,13 @@ import com.oracle.svm.core.jfr.JfrNativeEventWriterDataAccess; import com.oracle.svm.core.jfr.JfrTicks; import com.oracle.svm.core.jfr.SubstrateJVM; -import com.oracle.svm.core.jfr.Target_jdk_jfr_internal_JVM_ChunkRotationMonitor; import com.oracle.svm.core.jfr.Target_jdk_jfr_internal_management_HiddenWait; import jdk.graal.compiler.word.Word; public class JavaMonitorWaitEvent { public static void emit(long startTicks, Object obj, long notifierTid, long timeout, boolean timedOut) { - if (HasJfrSupport.get() && obj != null && !Target_jdk_jfr_internal_JVM_ChunkRotationMonitor.class.equals(obj.getClass()) && - !Target_jdk_jfr_internal_management_HiddenWait.class.equals(obj.getClass())) { + if (HasJfrSupport.get() && obj != null && !Target_jdk_jfr_internal_management_HiddenWait.class.equals(obj.getClass())) { emit0(startTicks, obj, notifierTid, timeout, timedOut); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodHandleNatives.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodHandleNatives.java index 96dbb7a43693..773f3acd1218 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodHandleNatives.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodHandleNatives.java @@ -25,7 +25,6 @@ package com.oracle.svm.core.methodhandles; import static com.oracle.svm.core.util.VMError.shouldNotReachHere; -import static com.oracle.svm.core.util.VMError.unimplemented; import static com.oracle.svm.core.util.VMError.unsupportedFeature; import java.lang.invoke.CallSite; @@ -49,11 +48,9 @@ import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; import com.oracle.svm.core.hub.DynamicHub; import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; import com.oracle.svm.core.invoke.Target_java_lang_invoke_MemberName; -import com.oracle.svm.core.jdk.JDK21OrEarlier; import com.oracle.svm.core.layeredimagesingleton.MultiLayeredImageSingleton; import com.oracle.svm.core.reflect.target.Target_java_lang_reflect_Field; import com.oracle.svm.core.util.VMError; @@ -205,12 +202,6 @@ private static Object getMemberVMInfo(Target_java_lang_invoke_MemberName self) { @Delete private static native void copyOutBootstrapArguments(Class caller, int[] indexInfo, int start, int end, Object[] buf, int pos, boolean resolve, Object ifNotAvailable); - @Substitute - @TargetElement(onlyWith = JDK21OrEarlier.class) - private static void clearCallSiteContext(Target_java_lang_invoke_MethodHandleNatives_CallSiteContext context) { - throw unimplemented("CallSiteContext not supported"); - } - @AnnotateOriginal static native boolean refKindIsMethod(byte refKind); @@ -420,7 +411,3 @@ final class Target_java_lang_invoke_MethodHandleNatives_Constants { @Alias @RecomputeFieldValue(isFinal = true, kind = Kind.None) static byte REF_LIMIT; // Checkstyle: resume } - -@TargetClass(className = "java.lang.invoke.MethodHandleNatives", innerClass = "CallSiteContext", onlyWith = JDK21OrEarlier.class) -final class Target_java_lang_invoke_MethodHandleNatives_CallSiteContext { -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodHandles_Lookup.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodHandles_Lookup.java index dc85613c1fbf..0cbaa2d8b499 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodHandles_Lookup.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodHandles_Lookup.java @@ -35,10 +35,8 @@ import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; import com.oracle.svm.core.hub.DynamicHub; import com.oracle.svm.core.invoke.Target_java_lang_invoke_MemberName; -import com.oracle.svm.core.jdk.JDK21OrEarlier; @TargetClass(value = MethodHandles.class, innerClass = "Lookup") final class Target_java_lang_invoke_MethodHandles_Lookup { @@ -90,11 +88,4 @@ private IllegalAccessException makeAccessException(Class targetClass) { @Delete native MethodHandle linkMethodHandleConstant(byte refKind, Class defc, String name, Object type) throws ReflectiveOperationException; - - /** This call is a noop without the security manager. */ - @SuppressWarnings("unused") - @Substitute - @TargetElement(onlyWith = JDK21OrEarlier.class) - void checkSecurityManager(Class refc) { - } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/monitor/MultiThreadedMonitorSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/monitor/MultiThreadedMonitorSupport.java index 77440bd4ea8c..7d3df34dbd86 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/monitor/MultiThreadedMonitorSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/monitor/MultiThreadedMonitorSupport.java @@ -45,7 +45,6 @@ import com.oracle.svm.core.heap.RestrictHeapAccess.Access; import com.oracle.svm.core.hub.DynamicHub; import com.oracle.svm.core.hub.DynamicHubCompanion; -import com.oracle.svm.core.jdk.JDK21OrEarlier; import com.oracle.svm.core.jdk.JDKLatest; import com.oracle.svm.core.jfr.JfrTicks; import com.oracle.svm.core.jfr.events.JavaMonitorInflateEvent; @@ -380,15 +379,10 @@ protected void doWait(Object obj, long timeoutMillis) throws InterruptedExceptio * too, so we don't have to intercept an InterruptedException from the carrier thread to * clear the virtual thread interrupt. */ - long compensation = -1; boolean attempted = false; boolean pinned = JavaThreads.isCurrentThreadVirtualAndPinned(); if (pinned) { - if (JavaVersionUtil.JAVA_SPEC < 23) { - compensation = Target_jdk_internal_misc_Blocker.beginJDK22(); - } else { - attempted = Target_jdk_internal_misc_Blocker.begin(); - } + attempted = Target_jdk_internal_misc_Blocker.begin(); } try { /* @@ -404,11 +398,7 @@ protected void doWait(Object obj, long timeoutMillis) throws InterruptedExceptio } } finally { if (pinned) { - if (JavaVersionUtil.JAVA_SPEC < 23) { - Target_jdk_internal_misc_Blocker.endJDK22(compensation); - } else { - Target_jdk_internal_misc_Blocker.end(attempted); - } + Target_jdk_internal_misc_Blocker.end(attempted); } } } @@ -537,13 +527,6 @@ protected JavaMonitor newMonitorLock() { @TargetClass(className = "jdk.internal.misc.Blocker") final class Target_jdk_internal_misc_Blocker { - @Alias - @TargetElement(name = "begin", onlyWith = JDK21OrEarlier.class) - public static native long beginJDK22(); - - @Alias - @TargetElement(name = "end", onlyWith = JDK21OrEarlier.class) - public static native void endJDK22(long compensateReturn); @Alias @TargetElement(onlyWith = JDKLatest.class) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_jdk_internal_reflect_AccessorGenerator.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_jdk_internal_reflect_AccessorGenerator.java deleted file mode 100644 index 4d57de30e43e..000000000000 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/Target_jdk_internal_reflect_AccessorGenerator.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.svm.core.reflect.target; - -import java.util.function.Function; - -import com.oracle.svm.core.jdk.JDK21OrEarlier; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.Platform; -import org.graalvm.nativeimage.Platforms; - -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.reflect.serialize.SerializationRegistry; - -import jdk.graal.compiler.serviceprovider.JavaVersionUtil; - -@TargetClass(className = "jdk.internal.reflect.AccessorGenerator", onlyWith = JDK21OrEarlier.class) -final class Target_jdk_internal_reflect_AccessorGenerator { -} - -@TargetClass(classNameProvider = Name_jdk_internal_reflect_SerializationConstructorAccessorGenerator_helper.class, onlyWith = JDK21OrEarlier.class) -final class Target_jdk_internal_reflect_SerializationConstructorAccessorGenerator { - - @Substitute - @SuppressWarnings("static-method") - public Target_jdk_internal_reflect_SerializationConstructorAccessorImpl generateSerializationConstructor(Class declaringClass, - @SuppressWarnings("unused") Class[] parameterTypes, - @SuppressWarnings("unused") int modifiers, - Class targetConstructorClass) { - SerializationRegistry serializationRegistry = ImageSingletons.lookup(SerializationRegistry.class); - Object constructorAccessor = serializationRegistry.getSerializationConstructorAccessor(declaringClass, targetConstructorClass); - return (Target_jdk_internal_reflect_SerializationConstructorAccessorImpl) constructorAccessor; - } -} - -@TargetClass(className = "jdk.internal.reflect.SerializationConstructorAccessorImpl", onlyWith = JDK21OrEarlier.class) -final class Target_jdk_internal_reflect_SerializationConstructorAccessorImpl { -} - -@Platforms(Platform.HOSTED_ONLY.class) -final class Name_jdk_internal_reflect_SerializationConstructorAccessorGenerator_helper implements Function { - - @Override - public String apply(TargetClass annotation) { - if (JavaVersionUtil.JAVA_SPEC >= 22) { - return "jdk.internal.reflect.SerializationConstructorAccessorGenerator"; - } else { - return "jdk.internal.reflect.MethodAccessorGenerator"; - } - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/JavaThreads.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/JavaThreads.java index d1d811858b07..33e94158fc0f 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/JavaThreads.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/JavaThreads.java @@ -27,8 +27,6 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; import java.lang.Thread.UncaughtExceptionHandler; -import java.security.AccessControlContext; -import java.security.AccessController; import java.util.EnumSet; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; @@ -355,14 +353,12 @@ public static void dispatchUncaughtException(Thread thread, Throwable throwable) *
  • No security manager: using the ContextClassLoader of the parent.
  • * */ - @SuppressWarnings({"deprecation", "removal"}) // AccessController is deprecated starting JDK 17 static void initializeNewThread( Target_java_lang_Thread tjlt, ThreadGroup groupArg, Runnable target, String name, long stackSize, - AccessControlContext acc, boolean inheritThreadLocals) { if (name == null) { throw new NullPointerException("The name cannot be null"); @@ -386,10 +382,6 @@ static void initializeNewThread( PlatformThreads.setThreadStatus(fromTarget(tjlt), ThreadStatus.NEW); - if (JavaVersionUtil.JAVA_SPEC == 21) { - tjlt.inheritedAccessControlContext = acc != null ? acc : AccessController.getContext(); - } - initNewThreadLocalsAndLoader(tjlt, inheritThreadLocals, parent); /* Set thread ID */ diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_ScopedValue.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_ScopedValue.java index f142d2c19669..0f55da8d0e18 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_ScopedValue.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_ScopedValue.java @@ -24,14 +24,11 @@ */ package com.oracle.svm.core.thread; -import java.util.concurrent.Callable; - import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDK21OrEarlier; import com.oracle.svm.core.jdk.JDKLatest; @TargetClass(className = "java.lang.ScopedValue") @@ -59,19 +56,6 @@ final class Target_java_lang_ScopedValue_CallableOp { final class Target_java_lang_ScopedValue_Carrier { @Alias int bitmask; - @Substitute - @TargetElement(onlyWith = JDK21OrEarlier.class) - @Uninterruptible(reason = "Ensure no safepoint actions can disrupt reverting scoped value bindings.", calleeMustBe = false) - private R runWith(Target_java_lang_ScopedValue_Snapshot newSnapshot, Callable op) throws Exception { - Target_java_lang_Thread.setScopedValueBindings(newSnapshot); - try { - return Target_jdk_internal_vm_ScopedValueContainer.call(op); - } finally { - Target_java_lang_Thread.setScopedValueBindings(newSnapshot.prev); - Target_java_lang_ScopedValue_Cache.invalidate(bitmask); - } - } - @Substitute @TargetElement(onlyWith = JDKLatest.class) @Uninterruptible(reason = "Ensure no safepoint actions can disrupt reverting scoped value bindings.", calleeMustBe = false) @@ -100,10 +84,6 @@ private void runWith(Target_java_lang_ScopedValue_Snapshot newSnapshot, Runnable @TargetClass(className = "jdk.internal.vm.ScopedValueContainer") final class Target_jdk_internal_vm_ScopedValueContainer { - @Alias - @TargetElement(onlyWith = JDK21OrEarlier.class) - static native V call(Callable op) throws Exception; - @Alias @TargetElement(onlyWith = JDKLatest.class) static native V call(Target_java_lang_ScopedValue_CallableOp op) throws Exception; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_Thread.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_Thread.java index 9c672f7d004a..9bcdcb890d16 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_Thread.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_Thread.java @@ -27,7 +27,6 @@ import static com.oracle.svm.core.thread.ThreadStatus.JVMTI_THREAD_STATE_TERMINATED; import java.lang.Thread.UncaughtExceptionHandler; -import java.security.AccessControlContext; import java.util.Map; import java.util.Objects; @@ -45,14 +44,11 @@ import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDK21OrEarlier; import com.oracle.svm.core.jdk.JDKLatest; import com.oracle.svm.core.monitor.MonitorSupport; -import com.oracle.svm.core.util.VMError; import jdk.graal.compiler.api.directives.GraalDirectives; import jdk.graal.compiler.replacements.ReplacementsUtil; -import jdk.graal.compiler.serviceprovider.JavaVersionUtil; @TargetClass(Thread.class) @SuppressWarnings({"unused"}) @@ -110,15 +106,6 @@ public final class Target_java_lang_Thread { @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = ThreadIdRecomputation.class) // public long tid; - /* - * For unstarted threads created during image generation like the main thread, we do not want to - * inherit a (more or less random) access control context. - */ - @Alias // - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) // - @TargetElement(onlyWith = JDK21OrEarlier.class) // - public AccessControlContext inheritedAccessControlContext; - @Alias // Object interruptLock; @@ -214,29 +201,6 @@ void setCurrentThread(Thread thread) { JavaThreads.setCurrentThread(JavaThreads.fromTarget(this), thread); } - @Substitute - @SuppressWarnings({"unused"}) - @Platforms(InternalPlatform.NATIVE_ONLY.class) - @TargetElement(onlyWith = JDK21OrEarlier.class) - private Target_java_lang_Thread( - ThreadGroup g, - String name, - int characteristics, - Runnable target, - long stackSize, - AccessControlContext acc) { - /* Non-0 instance field initialization. */ - this.interruptLock = new Object(); - /* Injected Target_java_lang_Thread instance field initialization. */ - this.threadData = new ThreadData(); - - String nameLocal = (name != null) ? name : genThreadName(); - boolean inheritThreadLocals = (characteristics & NO_INHERIT_THREAD_LOCALS) == 0; - JavaThreads.initializeNewThread(this, g, target, nameLocal, stackSize, acc, inheritThreadLocals); - - this.scopedValueBindings = NEW_THREAD_BINDINGS; - } - @Substitute @Platforms(InternalPlatform.NATIVE_ONLY.class) @TargetElement(onlyWith = JDKLatest.class) @@ -253,7 +217,7 @@ private Target_java_lang_Thread( String nameLocal = (name != null) ? name : genThreadName(); boolean inheritThreadLocals = (characteristics & NO_INHERIT_THREAD_LOCALS) == 0; - JavaThreads.initializeNewThread(this, g, target, nameLocal, stackSize, null, inheritThreadLocals); + JavaThreads.initializeNewThread(this, g, target, nameLocal, stackSize, inheritThreadLocals); this.scopedValueBindings = NEW_THREAD_BINDINGS; } @@ -276,9 +240,6 @@ private Target_java_lang_Thread(String name, int characteristics, boolean bound) this.name = (name != null) ? name : ""; this.tid = Target_java_lang_Thread_ThreadIdentifiers.next(); - if (JavaVersionUtil.JAVA_SPEC == 21) { - this.inheritedAccessControlContext = Target_java_lang_Thread_Constants.NO_PERMISSIONS_ACC; - } boolean inheritThreadLocals = (characteristics & NO_INHERIT_THREAD_LOCALS) == 0; JavaThreads.initNewThreadLocalsAndLoader(this, inheritThreadLocals, Thread.currentThread()); @@ -365,13 +326,6 @@ void interrupt0() { PlatformThreads.wakeUpVMConditionWaiters(thread); } - @Substitute - @TargetElement(onlyWith = JDK21OrEarlier.class) - @SuppressWarnings({"static-method"}) - private int countStackFrames() { - throw VMError.unsupportedFeature("The deprecated method Thread.countStackFrames is not supported"); - } - /* * We are defensive and also handle private native methods by marking them as deleted. If they * are reachable, the user is certainly doing something wrong. But we do not want to fail with a @@ -398,13 +352,6 @@ private static void yield0() { PlatformThreads.singleton().yieldCurrent(); } - @Substitute - @TargetElement(onlyWith = JDK21OrEarlier.class) - private static void sleep0(long nanos) throws InterruptedException { - // Virtual threads are handled in sleep() - PlatformThreads.sleep(nanos); - } - @Substitute @TargetElement(onlyWith = JDKLatest.class) private static void sleepNanos0(long nanos) throws InterruptedException { @@ -528,12 +475,6 @@ static void setScopedValueBindings(Object bindings) { @Delete static native Object findScopedValueBindings(); - @Substitute - @TargetElement(name = "blockedOn", onlyWith = JDK21OrEarlier.class) - static void blockedOnJDK21(Target_sun_nio_ch_Interruptible b) { - JavaThreads.blockedOn(b); - } - @Alias native Thread.State threadState(); @@ -569,10 +510,6 @@ boolean isTerminated() { @TargetClass(value = Thread.class, innerClass = "Constants") final class Target_java_lang_Thread_Constants { // Checkstyle: stop - @SuppressWarnings("removal") // - @TargetElement(onlyWith = JDK21OrEarlier.class) // - @Alias static AccessControlContext NO_PERMISSIONS_ACC; - @Alias static ThreadGroup VTHREAD_GROUP; // Checkstyle: resume } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_VirtualThread.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_VirtualThread.java index a25f3a86014e..655b2823afa4 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_VirtualThread.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_VirtualThread.java @@ -27,10 +27,8 @@ import static com.oracle.svm.core.thread.VirtualThreadHelper.asTarget; import static com.oracle.svm.core.thread.VirtualThreadHelper.asThread; -import java.util.Locale; import java.util.concurrent.Executor; import java.util.concurrent.ForkJoinPool; -import java.util.concurrent.ScheduledExecutorService; import org.graalvm.nativeimage.hosted.FieldValueTransformer; @@ -45,7 +43,6 @@ import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDK21OrEarlier; import com.oracle.svm.core.jdk.JDKLatest; import com.oracle.svm.core.jfr.HasJfrSupport; import com.oracle.svm.core.jfr.SubstrateJVM; @@ -61,7 +58,6 @@ public final class Target_java_lang_VirtualThread { // Checkstyle: stop @Alias static int NEW; @Alias static int STARTED; - @TargetElement(onlyWith = JDK21OrEarlier.class) @Alias static int RUNNABLE; @Alias static int RUNNING; @Alias static int PARKING; @Alias static int PARKED; @@ -91,15 +87,6 @@ public final class Target_java_lang_VirtualThread { @InjectAccessors(DefaultSchedulerAccessor.class) // public static ForkJoinPool DEFAULT_SCHEDULER; - /** - * (Re)initialize the unparker at runtime so that it does not reference any platform threads of - * the image builder. - */ - @Alias // - @InjectAccessors(UnparkerAccessor.class) // - @TargetElement(onlyWith = JDK21OrEarlier.class) // - private static ScheduledExecutorService UNPARKER; - /** Go through {@link #nondefaultScheduler}. */ @Alias // @InjectAccessors(SchedulerAccessor.class) // @@ -129,10 +116,6 @@ public final class Target_java_lang_VirtualThread { @Alias private static native ForkJoinPool createDefaultScheduler(); - @Alias - @TargetElement(onlyWith = JDK21OrEarlier.class) - private static native ScheduledExecutorService createDelayedTaskScheduler(); - @SuppressWarnings("unused") private static final class AlwaysFalseAccessor { static boolean get(Target_java_lang_VirtualThread vt) { @@ -165,28 +148,6 @@ private static synchronized ForkJoinPool initializeDefaultScheduler() { } } - private static final class UnparkerAccessor { - private static volatile ScheduledExecutorService delayedTaskScheduler; - - @SuppressWarnings("unused") - public static ScheduledExecutorService get() { - ScheduledExecutorService result = delayedTaskScheduler; - if (result == null) { - result = initializeDelayedTaskScheduler(); - } - return result; - } - - private static synchronized ScheduledExecutorService initializeDelayedTaskScheduler() { - ScheduledExecutorService result = delayedTaskScheduler; - if (result == null) { - result = createDelayedTaskScheduler(); - delayedTaskScheduler = result; - } - return result; - } - } - @SuppressWarnings("unused") private static final class SchedulerAccessor { static Executor get(Target_java_lang_VirtualThread self) { @@ -242,13 +203,6 @@ private void notifyJvmtiUnmount(boolean hide) { // unimplemented (GR-45392) } - @Substitute - @TargetElement(name = "notifyJvmtiHideFrames", onlyWith = JDK21OrEarlier.class) - @SuppressWarnings({"static-method", "unused"}) - private void notifyJvmtiHideFramesJDK22(boolean hide) { - // unimplemented (GR-45392) - } - @Substitute @SuppressWarnings({"static-method", "unused"}) @TargetElement(onlyWith = JDKLatest.class) @@ -277,23 +231,6 @@ private static void postPinnedEvent(String op) { @Alias native StackTraceElement[] tryGetStackTrace(); - @Substitute // not needed on newer JDKs that use safe disableSuspendAndPreempt() - @TargetElement(name = "getAndClearInterrupt", onlyWith = JDK21OrEarlier.class) - boolean getAndClearInterruptJDK21() { - assert Thread.currentThread() == SubstrateUtil.cast(this, Object.class); - boolean oldValue = interrupted; - if (oldValue) { - Object token = VirtualThreadHelper.acquireInterruptLockMaybeSwitch(this); - try { - interrupted = false; - asTarget(carrierThread).clearInterrupt(); - } finally { - VirtualThreadHelper.releaseInterruptLockMaybeSwitchBack(this, token); - } - } - return oldValue; - } - @Alias @TargetElement(onlyWith = JDKLatest.class) native void disableSuspendAndPreempt(); @@ -336,21 +273,6 @@ void mount() { } } - @Substitute // not needed on newer JDKs that use safe disableSuspendAndPreempt() - @TargetElement(name = "unmount", onlyWith = JDK21OrEarlier.class) - void unmountJDK21() { - Target_java_lang_Thread carrier = asTarget(this.carrierThread); - carrier.setCurrentThread(asThread(carrier)); - - Object token = VirtualThreadHelper.acquireInterruptLockMaybeSwitch(this); - try { - setCarrierThread(null); - } finally { - VirtualThreadHelper.releaseInterruptLockMaybeSwitchBack(this, token); - } - carrier.clearInterrupt(); - } - @Alias native int state(); @@ -433,91 +355,10 @@ Thread.State threadState() { throw new InternalError(); } - /** Needed because {@link #disableSuspendAndPreempt()} does not exist on JDK 21. */ - @Substitute - @TargetElement(name = "threadState", onlyWith = JDK21OrEarlier.class) - @SuppressWarnings("hiding") - Thread.State threadStateJDK21() { - int state = state() & ~SUSPENDED; - if (state == NEW) { - return Thread.State.NEW; - } else if (state == STARTED) { - if (asTarget(this).threadContainer() == null) { - return Thread.State.NEW; - } else { - return Thread.State.RUNNABLE; - } - } else if (state == RUNNABLE) { - return Thread.State.RUNNABLE; - } else if (state == RUNNING) { - Object token = VirtualThreadHelper.acquireInterruptLockMaybeSwitch(this); - try { - Thread carrier = this.carrierThread; - if (carrier != null) { - return asTarget(carrier).threadState(); - } - } finally { - VirtualThreadHelper.releaseInterruptLockMaybeSwitchBack(this, token); - } - return Thread.State.RUNNABLE; - } else if (state == PARKING || state == YIELDING) { - return Thread.State.RUNNABLE; - } else if (state == PARKED || state == PINNED) { - int parkedThreadStatus = MonitorSupport.singleton().getParkedThreadStatus(asThread(this), false); - switch (parkedThreadStatus) { - case ThreadStatus.BLOCKED_ON_MONITOR_ENTER: - return Thread.State.BLOCKED; - case ThreadStatus.PARKED: - case ThreadStatus.IN_OBJECT_WAIT: - return Thread.State.WAITING; - default: - throw VMError.shouldNotReachHereUnexpectedInput(parkedThreadStatus); // ExcludeFromJacocoGeneratedReport - } - } else if (state == TERMINATED) { - return Thread.State.TERMINATED; - } - throw new InternalError(); - } - @AnnotateOriginal @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) native boolean isTerminated(); - @Substitute // not needed on newer JDKs that use safe disableSuspendAndPreempt() - @TargetElement(name = "toString", onlyWith = JDK21OrEarlier.class) - public String toStringJDK21() { - StringBuilder sb = new StringBuilder("VirtualThread[#"); - sb.append(asTarget(this).threadId()); - String name = asThread(this).getName(); - if (!name.isEmpty()) { - sb.append(","); - sb.append(name); - } - sb.append("]/"); - Thread carrier = carrierThread; - if (carrier != null) { - // include the carrier thread state and name when mounted - Object token = VirtualThreadHelper.acquireInterruptLockMaybeSwitch(this); - try { - carrier = carrierThread; - if (carrier != null) { - String stateAsString = asTarget(carrier).threadState().toString(); - sb.append(stateAsString.toLowerCase(Locale.ROOT)); - sb.append('@'); - sb.append(carrier.getName()); - } - } finally { - VirtualThreadHelper.releaseInterruptLockMaybeSwitchBack(this, token); - } - } - // include virtual thread state when not mounted - if (carrier == null) { - String stateAsString = threadStateJDK21().toString(); - sb.append(stateAsString.toLowerCase(Locale.ROOT)); - } - return sb.toString(); - } - /** * Only uses the interrupt lock when called from a different thread, therefore does not need to * be substituted to use {@link VirtualThreadHelper#acquireInterruptLockMaybeSwitch}. From 230116f92aa866a92b9b966dc89674795f528584 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Thu, 8 May 2025 13:26:54 +0200 Subject: [PATCH 3/4] svm: deprecate the JDKLatest predicate since it is now always valid --- .../src/com/oracle/svm/core/jdk/JDKLatest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JDKLatest.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JDKLatest.java index f8dbb84a8068..08b5ecc158df 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JDKLatest.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JDKLatest.java @@ -31,7 +31,10 @@ /** * Denotes the latest supported JDK version. It corresponds to the highest key in the * {@code JVMCI_MIN_VERSIONS} map in {@link jdk.graal.compiler.hotspot.JVMCIVersionCheck}. + * + * @deprecated SVM only supports a single JDK version, so this predicate is no longer useful. */ +@Deprecated(since = "25.0.0", forRemoval = true) public class JDKLatest implements BooleanSupplier { @Override public boolean getAsBoolean() { From 8d36b5f6c0190172c56b149d1db994a807de1159 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Thu, 8 May 2025 13:27:29 +0200 Subject: [PATCH 4/4] svm: remove usages of the JDKLatest predicate --- ...k_internal_foreign_Utils_BaseAndScale.java | 3 +- ..._jdk_internal_misc_ScopedMemoryAccess.java | 9 +-- ...Target_java_lang_ref_PhantomReference.java | 3 - .../heap/Target_java_lang_ref_Reference.java | 3 - .../Target_java_lang_ref_ReferenceQueue.java | 3 - .../heap/Target_jdk_internal_ref_Cleaner.java | 10 ++- .../com/oracle/svm/core/hub/DynamicHub.java | 8 --- .../jdk/ForeignDisabledSubstitutions.java | 9 +-- .../svm/core/jdk/JavaLangSubstitutions.java | 1 - .../oracle/svm/core/jdk/RecomputedFields.java | 2 - .../svm/core/jdk/SecuritySubstitutions.java | 1 - .../svm/core/jdk/SunMiscSubstitutions.java | 2 +- .../svm/core/jdk/Target_java_lang_Module.java | 1 - ...ava_util_concurrent_CompletableFuture.java | 2 +- ...get_java_util_concurrent_ForkJoinTask.java | 10 ++- .../core/jdk/Target_jdk_internal_misc_VM.java | 2 - ...arget_jdk_internal_reflect_Reflection.java | 2 - ...rget_jdk_internal_util_StaticProperty.java | 23 ------- ..._jdk_internal_vm_vector_VectorSupport.java | 1 - .../oracle/svm/core/jdk/VarHandleSupport.java | 2 +- .../core/jdk/proxy/ProxySubstitutions.java | 2 - .../Target_jdk_xml_internal_JdkCatalog.java | 5 +- .../svm/core/jfr/JfrJdkCompatibility.java | 5 +- .../core/jfr/Target_jdk_jfr_internal_JVM.java | 61 ------------------- .../Target_jdk_jfr_internal_Repository.java | 5 +- .../Target_jdk_jfr_internal_StringPool.java | 3 - ...et_jdk_jfr_internal_dcmd_AbstractDCmd.java | 3 - ...et_jdk_jfr_internal_event_EventWriter.java | 3 - .../jfr/Target_jdk_jfr_internal_jfc_JFC.java | 3 - ...dk_jfr_internal_management_HiddenWait.java | 3 +- .../core/jvmti/headers/JvmtiInterface.java | 5 -- ...arget_java_lang_invoke_MethodTypeForm.java | 3 - .../monitor/MultiThreadedMonitorSupport.java | 4 -- .../thread/Target_java_lang_ScopedValue.java | 6 +- .../core/thread/Target_java_lang_Thread.java | 4 -- .../Target_java_lang_VirtualThread.java | 46 ++++++-------- 36 files changed, 41 insertions(+), 217 deletions(-) diff --git a/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_foreign_Utils_BaseAndScale.java b/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_foreign_Utils_BaseAndScale.java index 549a1cd437f9..58124feb47da 100644 --- a/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_foreign_Utils_BaseAndScale.java +++ b/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_foreign_Utils_BaseAndScale.java @@ -30,14 +30,13 @@ import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.config.ConfigurationValues; -import com.oracle.svm.core.jdk.JDKLatest; import com.oracle.svm.core.util.VMError; import jdk.graal.compiler.serviceprovider.JavaVersionUtil; import jdk.internal.foreign.Utils; import jdk.vm.ci.meta.JavaKind; -@TargetClass(className = "jdk.internal.foreign.Utils", innerClass = "BaseAndScale", onlyWith = {ForeignAPIPredicates.Enabled.class, JDKLatest.class}) +@TargetClass(className = "jdk.internal.foreign.Utils", innerClass = "BaseAndScale", onlyWith = ForeignAPIPredicates.Enabled.class) final class Target_jdk_internal_foreign_Utils_BaseAndScale { @Alias // @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = BaseFieldRecomputer.class) // diff --git a/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_misc_ScopedMemoryAccess.java b/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_misc_ScopedMemoryAccess.java index f1f9cd468a19..50e3ba140f54 100644 --- a/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_misc_ScopedMemoryAccess.java +++ b/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_misc_ScopedMemoryAccess.java @@ -33,8 +33,6 @@ import com.oracle.svm.core.ArenaIntrinsics; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDKLatest; import com.oracle.svm.core.nodes.foreign.MemoryArenaValidInScopeNode; import com.oracle.svm.core.util.BasedOnJDKFile; @@ -98,7 +96,6 @@ static void registerNatives() { @SuppressWarnings("static-method") @Substitute @Target_jdk_internal_misc_ScopedMemoryAccess_Scoped - @TargetElement(onlyWith = JDKLatest.class) @AlwaysInline("Safepoints must be visible in caller") public void loadInternal(MemorySessionImpl session, MappedMemoryUtilsProxy mappedUtils, long address, boolean isSync, long size) { SubstrateForeignUtil.checkIdentity(mappedUtils, Target_java_nio_MappedMemoryUtils.PROXY); @@ -119,7 +116,6 @@ public void loadInternal(MemorySessionImpl session, MappedMemoryUtilsProxy mappe @SuppressWarnings("static-method") @Substitute @Target_jdk_internal_misc_ScopedMemoryAccess_Scoped - @TargetElement(onlyWith = JDKLatest.class) @AlwaysInline("Safepoints must be visible in caller") public boolean isLoadedInternal(MemorySessionImpl session, MappedMemoryUtilsProxy mappedUtils, long address, boolean isSync, long size) { SubstrateForeignUtil.checkIdentity(mappedUtils, Target_java_nio_MappedMemoryUtils.PROXY); @@ -141,7 +137,6 @@ public boolean isLoadedInternal(MemorySessionImpl session, MappedMemoryUtilsProx @SuppressWarnings("static-method") @Substitute @Target_jdk_internal_misc_ScopedMemoryAccess_Scoped - @TargetElement(onlyWith = JDKLatest.class) @AlwaysInline("Safepoints must be visible in caller") public void unloadInternal(MemorySessionImpl session, MappedMemoryUtilsProxy mappedUtils, long address, boolean isSync, long size) { SubstrateForeignUtil.checkIdentity(mappedUtils, Target_java_nio_MappedMemoryUtils.PROXY); @@ -164,7 +159,6 @@ public void unloadInternal(MemorySessionImpl session, MappedMemoryUtilsProxy map @SuppressWarnings("static-method") @Substitute @Target_jdk_internal_misc_ScopedMemoryAccess_Scoped - @TargetElement(onlyWith = JDKLatest.class) @AlwaysInline("Safepoints must be visible in caller") public void forceInternal(MemorySessionImpl session, MappedMemoryUtilsProxy mappedUtils, FileDescriptor fd, long address, boolean isSync, long index, long length) { SubstrateForeignUtil.checkIdentity(mappedUtils, Target_java_nio_MappedMemoryUtils.PROXY); @@ -201,14 +195,13 @@ public void forceInternal(MemorySessionImpl session, MappedMemoryUtilsProxy mapp @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+20/src/hotspot/share/prims/scopedMemoryAccess.cpp#L215-L218") @SuppressWarnings("static-method") @Substitute - @TargetElement(onlyWith = JDKLatest.class) void closeScope0(Target_jdk_internal_foreign_MemorySessionImpl session, @SuppressWarnings("unused") Target_jdk_internal_misc_ScopedMemoryAccess_ScopedAccessError error) { new SyncCloseScopeOperation(session).enqueue(); } } @Retention(RetentionPolicy.RUNTIME) -@TargetClass(className = "jdk.internal.misc.ScopedMemoryAccess$Scoped", onlyWith = {JDKLatest.class, ForeignAPIPredicates.Enabled.class}) +@TargetClass(className = "jdk.internal.misc.ScopedMemoryAccess$Scoped", onlyWith = ForeignAPIPredicates.Enabled.class) @interface Target_jdk_internal_misc_ScopedMemoryAccess_Scoped { } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_PhantomReference.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_PhantomReference.java index 6f046af09657..f527393b027c 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_PhantomReference.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_PhantomReference.java @@ -29,8 +29,6 @@ import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDKLatest; @TargetClass(PhantomReference.class) public final class Target_java_lang_ref_PhantomReference { @@ -40,7 +38,6 @@ boolean refersTo0(Object obj) { } @Substitute - @TargetElement(onlyWith = JDKLatest.class) private void clear0() { ReferenceInternals.clear(SubstrateUtil.cast(this, PhantomReference.class)); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_Reference.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_Reference.java index aa449e624ed3..d155b37f2c66 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_Reference.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_Reference.java @@ -43,8 +43,6 @@ import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDKLatest; import com.oracle.svm.core.util.VMError; import com.oracle.svm.util.ReflectionUtil; @@ -133,7 +131,6 @@ private void clear0() { ReferenceInternals.clear(SubstrateUtil.cast(this, Reference.class)); } - @TargetElement(onlyWith = JDKLatest.class) @KeepOriginal native void clearImpl(); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_ReferenceQueue.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_ReferenceQueue.java index d7145888cdff..d52851ffbb78 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_ReferenceQueue.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_ReferenceQueue.java @@ -30,14 +30,11 @@ import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDKLatest; @TargetClass(ReferenceQueue.class) final class Target_java_lang_ref_ReferenceQueue { // Checkstyle: stop @Alias // - @TargetElement(onlyWith = JDKLatest.class) // static Target_java_lang_ref_ReferenceQueue NULL_QUEUE; // CheckStyle: resume diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_jdk_internal_ref_Cleaner.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_jdk_internal_ref_Cleaner.java index 6193ef886eb1..3beb6cee16d6 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_jdk_internal_ref_Cleaner.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_jdk_internal_ref_Cleaner.java @@ -36,7 +36,6 @@ import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDKLatest; import com.oracle.svm.core.thread.VMThreads; import com.oracle.svm.util.ReflectionUtil; @@ -78,14 +77,13 @@ final class Target_java_lang_ref_Cleaner_Cleanable { @TargetClass(className = "jdk.internal.ref.CleanerImpl") final class Target_jdk_internal_ref_CleanerImpl { - @TargetElement(onlyWith = JDKLatest.class)// @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClassName = "jdk.internal.ref.CleanerImpl$CleanableList")// Target_jdk_internal_ref_CleanerImpl_CleanableList activeList; @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClassName = "java.lang.ref.ReferenceQueue")// public ReferenceQueue queue; - @TargetElement(name = "run", onlyWith = JDKLatest.class) + @TargetElement(name = "run") @Substitute public void run() { Thread t = Thread.currentThread(); @@ -108,7 +106,7 @@ public void run() { } } -@TargetClass(className = "jdk.internal.ref.PhantomCleanable", onlyWith = JDKLatest.class) +@TargetClass(className = "jdk.internal.ref.PhantomCleanable") final class Target_jdk_internal_ref_PhantomCleanable { @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = GetCleanableListSingletonTransformer.class) // Target_jdk_internal_ref_CleanerImpl_CleanableList list; @@ -122,7 +120,7 @@ final class Target_jdk_internal_ref_PhantomCleanable { /* final */ native void clean(); } -@TargetClass(className = "jdk.internal.ref.CleanerImpl$CleanableList", onlyWith = JDKLatest.class) +@TargetClass(className = "jdk.internal.ref.CleanerImpl$CleanableList") final class Target_jdk_internal_ref_CleanerImpl_CleanableList { @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClassName = "jdk.internal.ref.CleanerImpl$CleanableList$Node") // @@ -136,7 +134,7 @@ final class Target_jdk_internal_ref_CleanerImpl_CleanableList { } -@TargetClass(className = "jdk.internal.ref.CleanerImpl$CleanableList$Node", onlyWith = JDKLatest.class) +@TargetClass(className = "jdk.internal.ref.CleanerImpl$CleanableList$Node") final class Target_jdk_internal_ref_CleanerImpl_CleanableList_Node { } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHub.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHub.java index c86b2987bff2..ca505f803539 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHub.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHub.java @@ -102,7 +102,6 @@ import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; import com.oracle.svm.core.classinitialization.ClassInitializationInfo; import com.oracle.svm.core.classinitialization.EnsureClassInitializedNode; import com.oracle.svm.core.config.ConfigurationValues; @@ -114,7 +113,6 @@ import com.oracle.svm.core.heap.UnknownPrimitiveField; import com.oracle.svm.core.imagelayer.DynamicImageLayerInfo; import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; -import com.oracle.svm.core.jdk.JDKLatest; import com.oracle.svm.core.jdk.ProtectionDomainSupport; import com.oracle.svm.core.jdk.Resources; import com.oracle.svm.core.meta.SharedType; @@ -1647,7 +1645,6 @@ private static Class forName(String name, boolean initialize, ClassLoader loa } @KeepOriginal - @TargetElement(onlyWith = JDKLatest.class) public static native Class forPrimitiveName(String primitiveName); @KeepOriginal @@ -1705,11 +1702,9 @@ public String toString() { public native String toGenericString(); @KeepOriginal - @TargetElement(onlyWith = JDKLatest.class) private native void addSealingInfo(int modifiersParam, StringBuilder sb); @KeepOriginal - @TargetElement(onlyWith = JDKLatest.class) private native boolean hasSealedAncestor(Class clazz); @KeepOriginal @@ -2054,7 +2049,6 @@ private Class[] getPermittedSubclasses0() { private native GenericsFactory getFactory(); @KeepOriginal - @TargetElement(onlyWith = JDKLatest.class) native Method findMethod(boolean publicOnly, String nameParam, Class... parameterTypes); @KeepOriginal @@ -2064,7 +2058,6 @@ private Class[] getPermittedSubclasses0() { private static native void addAll(Collection c, Field[] o); @KeepOriginal - @TargetElement(onlyWith = JDKLatest.class) private native Target_java_lang_PublicMethods_MethodList getMethodsRecursive(String methodName, Class[] parameterTypes, boolean includeStatic, boolean publicOnly); @KeepOriginal @@ -2342,7 +2335,6 @@ public FieldAccessor newFieldAccessor(Field field0, boolean override) { } @Substitute - @TargetElement(onlyWith = JDKLatest.class) private Constructor generateConstructor(Class cl, Constructor constructorToCall) { SerializationRegistry serializationRegistry = ImageSingletons.lookup(SerializationRegistry.class); ConstructorAccessor acc = (ConstructorAccessor) serializationRegistry.getSerializationConstructorAccessor(cl, constructorToCall.getDeclaringClass()); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ForeignDisabledSubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ForeignDisabledSubstitutions.java index 99e9a956c262..36154d80724e 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ForeignDisabledSubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ForeignDisabledSubstitutions.java @@ -37,7 +37,6 @@ import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; import com.oracle.svm.core.option.SubstrateOptionsParser; import com.oracle.svm.core.util.VMError; @@ -54,7 +53,6 @@ public boolean getAsBoolean() { final class Target_jdk_internal_foreign_MemorySessionImpl { @Substitute @SuppressWarnings("static-method") - @TargetElement(onlyWith = JDKLatest.class) Target_jdk_internal_foreign_ArenaImpl asArena() { throw ForeignDisabledSubstitutions.fail(); } @@ -64,7 +62,7 @@ Target_jdk_internal_foreign_ArenaImpl asArena() { final class Target_java_lang_foreign_Arena { } -@TargetClass(className = "jdk.internal.foreign.ArenaImpl", onlyWith = {ForeignDisabled.class, JDKLatest.class}) +@TargetClass(className = "jdk.internal.foreign.ArenaImpl", onlyWith = {ForeignDisabled.class}) final class Target_jdk_internal_foreign_ArenaImpl { } @@ -122,7 +120,7 @@ final class Target_jdk_internal_foreign_FunctionDescriptorImpl { final class Target_java_lang_foreign_FunctionDescriptor { } -@TargetClass(className = "jdk.internal.foreign.SegmentFactories", onlyWith = {ForeignDisabled.class, JDKLatest.class}) +@TargetClass(className = "jdk.internal.foreign.SegmentFactories", onlyWith = {ForeignDisabled.class}) final class Target_jdk_internal_foreign_SegmentFactories { @Substitute @AlwaysInline("Make remaining code in callers unreachable.") @@ -148,7 +146,7 @@ final class Target_jdk_internal_foreign_LayoutPath { final class Target_java_lang_foreign_MemoryLayout_PathElement { } -@TargetClass(className = "jdk.internal.foreign.layout.AbstractLayout", onlyWith = {ForeignDisabled.class, JDKLatest.class}) +@TargetClass(className = "jdk.internal.foreign.layout.AbstractLayout", onlyWith = {ForeignDisabled.class}) final class Target_jdk_internal_foreign_layout_AbstractLayout { @Substitute @AlwaysInline("Make remaining code in callers unreachable.") @@ -158,7 +156,6 @@ VarHandle varHandle(Target_java_lang_foreign_MemoryLayout_PathElement... element } @Substitute - @TargetElement(onlyWith = JDKLatest.class) @SuppressWarnings({"unused", "static-method"}) VarHandle varHandleInternal(Target_java_lang_foreign_MemoryLayout_PathElement... elements) { throw ForeignDisabledSubstitutions.fail(); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaLangSubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaLangSubstitutions.java index 5cbd61ea5c27..17b437d3ae65 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaLangSubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaLangSubstitutions.java @@ -215,7 +215,6 @@ final class Target_java_lang_StringUTF16 { final class Target_java_lang_Throwable { @Alias // - @TargetElement(onlyWith = JDKLatest.class) // @RecomputeFieldValue(kind = Kind.FromAlias, isFinal = true) // static boolean jfrTracing = false; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RecomputedFields.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RecomputedFields.java index 62dd4a3bab4f..721b4867c78e 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RecomputedFields.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RecomputedFields.java @@ -46,7 +46,6 @@ import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.util.BasedOnJDKFile; @@ -227,7 +226,6 @@ public static int getCommonPoolParallelism() { } @Alias // - @TargetElement(onlyWith = JDKLatest.class) public static native ForkJoinPool asyncCommonPool(); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SecuritySubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SecuritySubstitutions.java index 6a09fa07222a..f023a02fcc7c 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SecuritySubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SecuritySubstitutions.java @@ -110,7 +110,6 @@ final class Target_java_security_Provider_ServiceKey { final class Target_java_security_Provider { @Alias // @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = ThreadLocalServiceKeyComputer.class) // - @TargetElement(onlyWith = JDKLatest.class) // private static Target_java_lang_ThreadLocal previousKey; } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SunMiscSubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SunMiscSubstitutions.java index c08b22dcf9bd..78b18292e05d 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SunMiscSubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SunMiscSubstitutions.java @@ -98,7 +98,7 @@ int pageSize() { } @Substitute - @TargetElement(name = "arrayBaseOffset", onlyWith = JDKLatest.class) + @TargetElement(name = "arrayBaseOffset") public long arrayBaseOffset(Class clazz) { return LayoutEncoding.getArrayBaseOffset(DynamicHub.fromClass(clazz).getLayoutEncoding()).rawValue(); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_Module.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_Module.java index 2ab7d07bacd9..93b6e5588409 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_Module.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_Module.java @@ -62,7 +62,6 @@ public boolean isNativeAccessEnabled() { } @Alias - @TargetElement(onlyWith = JDKLatest.class) public native void ensureNativeAccess(Class owner, String methodName, Class currentClass, boolean jni); @Substitute diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_util_concurrent_CompletableFuture.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_util_concurrent_CompletableFuture.java index 64368a6328a5..8482c516df11 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_util_concurrent_CompletableFuture.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_util_concurrent_CompletableFuture.java @@ -44,7 +44,7 @@ final class Target_java_util_concurrent_CompletableFuture { // Checkstyle: resume } -@TargetClass(className = "java.util.concurrent.DelayScheduler", onlyWith = JDKLatest.class) +@TargetClass(className = "java.util.concurrent.DelayScheduler") final class Target_java_util_concurrent_DelayScheduler { @Alias @InjectAccessors(DelaySchedulerNanoTimeOffsetAccessor.class) // private static long nanoTimeOffset; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_util_concurrent_ForkJoinTask.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_util_concurrent_ForkJoinTask.java index d8e6be663199..4a53207d6b00 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_util_concurrent_ForkJoinTask.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_util_concurrent_ForkJoinTask.java @@ -30,7 +30,6 @@ import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; import jdk.graal.compiler.core.common.SuppressFBWarnings; @@ -38,9 +37,9 @@ final class Target_java_util_concurrent_ForkJoinTask { @Alias private transient volatile Target_java_util_concurrent_ForkJoinTask_Aux aux; - @Alias @TargetElement(onlyWith = JDKLatest.class) volatile int status; - @Alias @TargetElement(onlyWith = JDKLatest.class) static int ABNORMAL; - @Alias @TargetElement(onlyWith = JDKLatest.class) static int THROWN; + @Alias volatile int status; + @Alias static int ABNORMAL; + @Alias static int THROWN; /** * Returns a rethrowable exception for this task, if available. The original method may attempt @@ -52,7 +51,6 @@ final class Target_java_util_concurrent_ForkJoinTask { * by the original method. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) @SuppressWarnings("all") @SuppressFBWarnings(value = "BC_IMPOSSIBLE_INSTANCEOF", justification = "Check for @TargetClass") private Throwable getException(boolean asExecutionException) { @@ -77,6 +75,6 @@ final class Target_java_util_concurrent_ForkJoinTask_Aux { @Alias Throwable ex; } -@TargetClass(value = java.util.concurrent.ForkJoinTask.class, innerClass = "InterruptibleTask", onlyWith = JDKLatest.class) +@TargetClass(value = java.util.concurrent.ForkJoinTask.class, innerClass = "InterruptibleTask") final class Target_java_util_concurrent_ForkJoinTask_InterruptibleTask { } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_misc_VM.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_misc_VM.java index 00accd83255e..15d7613a9cdf 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_misc_VM.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_misc_VM.java @@ -35,7 +35,6 @@ import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; import com.oracle.svm.core.snippets.KnownIntrinsics; import jdk.internal.misc.Unsafe; @@ -69,7 +68,6 @@ public static ClassLoader latestUserDefinedLoader0() { @Alias @InjectAccessors(DirectMemoryAccessors.class) // private static long directMemory; @Alias @InjectAccessors(PageAlignDirectMemoryAccessors.class) // - @TargetElement(onlyWith = JDKLatest.class) // private static Boolean pageAlignDirectMemory; } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_reflect_Reflection.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_reflect_Reflection.java index f0f3a64c0ae4..76e39f35971d 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_reflect_Reflection.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_reflect_Reflection.java @@ -31,7 +31,6 @@ import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; import com.oracle.svm.core.hub.DynamicHub; import com.oracle.svm.core.snippets.KnownIntrinsics; @@ -56,6 +55,5 @@ private static boolean areNestMates(Class currentClass, Class memberClass) } @Alias - @TargetElement(onlyWith = JDKLatest.class) public static native void ensureNativeAccess(Class currentClass, Class owner, String methodName, boolean jni); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_util_StaticProperty.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_util_StaticProperty.java index c20e6c113737..c36e407a1db9 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_util_StaticProperty.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_util_StaticProperty.java @@ -32,7 +32,6 @@ import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; import jdk.graal.compiler.serviceprovider.JavaVersionUtil; @@ -108,95 +107,76 @@ final class Target_jdk_internal_util_StaticProperty { private static String JAVA_LOCALE_USE_OLD_ISO_CODES; @Delete// - @TargetElement(onlyWith = JDKLatest.class)// private static String OS_NAME; @Alias// - @TargetElement(onlyWith = JDKLatest.class)// @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// private static String OS_ARCH; @Delete// - @TargetElement(onlyWith = JDKLatest.class)// private static String OS_VERSION; @Alias// - @TargetElement(onlyWith = JDKLatest.class)// @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// public static String USER_LANGUAGE; @Alias// - @TargetElement(onlyWith = JDKLatest.class)// @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// public static String USER_LANGUAGE_DISPLAY; @Alias// - @TargetElement(onlyWith = JDKLatest.class)// @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// public static String USER_LANGUAGE_FORMAT; @Alias// - @TargetElement(onlyWith = JDKLatest.class)// @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// public static String USER_SCRIPT; @Alias// - @TargetElement(onlyWith = JDKLatest.class)// @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// public static String USER_SCRIPT_DISPLAY; @Alias// - @TargetElement(onlyWith = JDKLatest.class)// @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// public static String USER_SCRIPT_FORMAT; @Alias// - @TargetElement(onlyWith = JDKLatest.class)// @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// public static String USER_COUNTRY; @Alias// - @TargetElement(onlyWith = JDKLatest.class)// @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// public static String USER_COUNTRY_DISPLAY; @Alias// - @TargetElement(onlyWith = JDKLatest.class)// @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// public static String USER_COUNTRY_FORMAT; @Alias// - @TargetElement(onlyWith = JDKLatest.class)// @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// public static String USER_VARIANT; @Alias// - @TargetElement(onlyWith = JDKLatest.class)// @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// public static String USER_VARIANT_DISPLAY; @Alias// - @TargetElement(onlyWith = JDKLatest.class)// @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// public static String USER_VARIANT_FORMAT; @Alias// - @TargetElement(onlyWith = JDKLatest.class)// @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// public static String USER_EXTENSIONS; @Alias// - @TargetElement(onlyWith = JDKLatest.class)// @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// public static String USER_EXTENSIONS_DISPLAY; @Alias// - @TargetElement(onlyWith = JDKLatest.class)// @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// public static String USER_EXTENSIONS_FORMAT; @Alias// - @TargetElement(onlyWith = JDKLatest.class)// @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)// public static String USER_REGION; // Checkstyle: resume @@ -334,20 +314,17 @@ public static String javaLocaleUseOldISOCodes() { } @Substitute - @TargetElement(onlyWith = JDKLatest.class)// public static String osName() { return SystemPropertiesSupport.singleton().getInitialProperty("os.name"); } @Substitute - @TargetElement(onlyWith = JDKLatest.class)// public static String osArch() { assert Objects.equals(OS_ARCH, SystemPropertiesSupport.singleton().getInitialProperty("os.arch")); return OS_ARCH; } @Substitute - @TargetElement(onlyWith = JDKLatest.class)// public static String osVersion() { return SystemPropertiesSupport.singleton().getInitialProperty("os.version"); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_vm_vector_VectorSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_vm_vector_VectorSupport.java index e3600a9cc5c1..3b8e4e2cdebf 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_vm_vector_VectorSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_vm_vector_VectorSupport.java @@ -56,7 +56,6 @@ private static int getMaxLaneCount(Class etype) { * Substitutes the native method with a constant string defined at build time. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static String getCPUFeatures() { return Helper_jdk_internal_vm_vector_VectorSupport.getCPUFeatures(); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/VarHandleSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/VarHandleSupport.java index b28f962f01d8..356e5ccefd53 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/VarHandleSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/VarHandleSupport.java @@ -378,7 +378,7 @@ final class Target_java_lang_invoke_DirectMethodHandle_StaticAccessor { long staticOffset; } -@TargetClass(className = "java.lang.invoke.LazyInitializingVarHandle", onlyWith = JDKLatest.class) +@TargetClass(className = "java.lang.invoke.LazyInitializingVarHandle") final class Target_java_lang_invoke_LazyInitializingVarHandle { @Alias @RecomputeFieldValue(isFinal = true, kind = RecomputeFieldValue.Kind.None) // Class refc; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/proxy/ProxySubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/proxy/ProxySubstitutions.java index 602f441bcda8..9459f3041918 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/proxy/ProxySubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/proxy/ProxySubstitutions.java @@ -34,7 +34,6 @@ import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.annotate.TargetElement; import com.oracle.svm.core.hub.DynamicHub; -import com.oracle.svm.core.jdk.JDKLatest; @TargetClass(java.lang.reflect.Proxy.class) final class Target_java_lang_reflect_Proxy { @@ -44,7 +43,6 @@ final class Target_java_lang_reflect_Proxy { private static Target_jdk_internal_loader_ClassLoaderValue proxyCache; @Substitute - @TargetElement(onlyWith = JDKLatest.class) private static Constructor getProxyConstructor(ClassLoader loader, Class... interfaces) { final Class cl = ImageSingletons.lookup(DynamicProxyRegistry.class).getProxyClass(loader, interfaces); try { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/xml/Target_jdk_xml_internal_JdkCatalog.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/xml/Target_jdk_xml_internal_JdkCatalog.java index eec7075c8d9d..0dda229533c4 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/xml/Target_jdk_xml_internal_JdkCatalog.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/xml/Target_jdk_xml_internal_JdkCatalog.java @@ -32,7 +32,6 @@ import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.jdk.JDKLatest; /** * Substitution to initialize {@link #catalog} at build time. @@ -45,7 +44,7 @@ * Ideally, we would initialize all of {@code jdk.xml} at run time, but that is too intrusive at the * current point in time (GR-50683). */ -@TargetClass(className = "jdk.xml.internal.JdkCatalog", onlyWith = JDKLatest.class) +@TargetClass(className = "jdk.xml.internal.JdkCatalog") public final class Target_jdk_xml_internal_JdkCatalog { @Alias // @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = JdkCatalogSupplier.class, isFinal = true) // @@ -58,7 +57,7 @@ public static void init(String resolve) { } } -@TargetClass(className = "javax.xml.catalog.Catalog", onlyWith = JDKLatest.class) +@TargetClass(className = "javax.xml.catalog.Catalog") final class Target_javax_xml_catalog_Catalog { } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrJdkCompatibility.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrJdkCompatibility.java index f1b96741a163..c0d35b3ba7af 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrJdkCompatibility.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrJdkCompatibility.java @@ -37,7 +37,6 @@ import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.jdk.JDKLatest; import com.oracle.svm.core.util.VMError; import com.oracle.svm.util.ReflectionUtil; @@ -105,7 +104,7 @@ public static JVM getJVMOrNull() throws IllegalAccessException, InvocationTarget } } -@TargetClass(className = "jdk.jfr.internal.JVMSupport", onlyWith = {JDKLatest.class, HasJfrSupport.class}) +@TargetClass(className = "jdk.jfr.internal.JVMSupport", onlyWith = HasJfrSupport.class) final class Target_jdk_jfr_internal_JVMSupport { @Substitute public static String makeFilename(Recording recording) { @@ -113,7 +112,7 @@ public static String makeFilename(Recording recording) { } } -@TargetClass(className = "jdk.jfr.internal.util.ValueFormatter", onlyWith = {JDKLatest.class, HasJfrSupport.class}) +@TargetClass(className = "jdk.jfr.internal.util.ValueFormatter", onlyWith = HasJfrSupport.class) final class Target_jdk_jfr_internal_util_ValueFormatter { @Alias public static native String formatTimespan(Duration dValue, String separation); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM.java index 7e0f9e040471..62ea29711c24 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM.java @@ -39,7 +39,6 @@ import com.oracle.svm.core.annotate.TargetElement; import com.oracle.svm.core.container.Container; import com.oracle.svm.core.container.OperatingSystem; -import com.oracle.svm.core.jdk.JDKLatest; import com.oracle.svm.core.jfr.traceid.JfrTraceId; import com.oracle.svm.core.util.PlatformTimeUtils; import com.oracle.svm.core.util.VMError; @@ -64,7 +63,6 @@ public final class Target_jdk_jfr_internal_JVM { @Alias // @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) // - @TargetElement(onlyWith = JDKLatest.class) // private static volatile boolean nativeOK; /** See {@link JVM#registerNatives}. */ @@ -73,14 +71,12 @@ private static void registerNatives() { } @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void markChunkFinal() { SubstrateJVM.get().markChunkFinal(); } /** See {@link JVM#beginRecording}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void beginRecording() { SubstrateJVM.get().beginRecording(); } @@ -88,14 +84,12 @@ public static void beginRecording() { /** See {@link JVM#isRecording}. */ @Substitute @Uninterruptible(reason = "Needed for calling SubstrateJVM.isRecording().") - @TargetElement(onlyWith = JDKLatest.class) public static boolean isRecording() { return SubstrateJVM.get().isRecording(); } /** See {@link JVM#endRecording}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void endRecording() { SubstrateJVM.get().endRecording(); } @@ -108,21 +102,18 @@ public static long counterTime() { /** See {@link JVM#emitEvent}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static boolean emitEvent(long eventTypeId, long timestamp, long when) { return false; } /** See {@link JVM#getAllEventClasses}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static List> getAllEventClasses() { return JfrJavaEvents.getAllEventClasses(); } /** See {@link JVM#getUnloadedEventClassCount}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static long getUnloadedEventClassCount() { return 0; } @@ -140,7 +131,6 @@ public static long getClassId(Class clazz) { /** See {@link JVM#getPid}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static String getPid() { long id = ProcessProperties.getProcessID(); return String.valueOf(id); @@ -149,7 +139,6 @@ public static String getPid() { /** See {@link JVM#getStackTraceId}. */ @Substitute @Uninterruptible(reason = "Needed for SubstrateJVM.getStackTraceId().") - @TargetElement(onlyWith = JDKLatest.class) public static long getStackTraceId(int skipCount, long stackFilterId) { /* * The result is only valid until the epoch changes but this is fine because EventWriter @@ -159,13 +148,11 @@ public static long getStackTraceId(int skipCount, long stackFilterId) { } @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static long registerStackFilter(String[] classes, String[] methods) { throw VMError.unimplemented("JFR StackFilters are not yet supported."); } @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void unregisterStackFilter(long stackFilterId) { throw VMError.unimplemented("JFR StackFilters are not yet supported."); } @@ -175,28 +162,24 @@ public static void unregisterStackFilter(long stackFilterId) { * for @Deprecated events. Note that this method is called during JFR startup. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void setMiscellaneous(long eventTypeId, long value) { /* Ignore the call and don't throw an exception (would result in an unspecific warning). */ } /** See {@link JVM#getThreadId}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static long getThreadId(Thread t) { return SubstrateJVM.getThreadId(t); } /** See {@link JVM#getTicksFrequency}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static long getTicksFrequency() { return JfrTicks.getTicksFrequency(); } /** See {@code JVM#nanosNow}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static long nanosNow() { return PlatformTimeUtils.singleton().nanosNow(); } @@ -221,146 +204,125 @@ public static void subscribeLogLevel(LogTag lt, int tagSetId) { /** See {@link JVM#retransformClasses}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static synchronized void retransformClasses(Class[] classes) { // Not supported but this method is called during JFR startup, so we can't throw an error. } /** See {@link JVM#setEnabled}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void setEnabled(long eventTypeId, boolean enabled) { SubstrateJVM.get().setEnabled(eventTypeId, enabled); } /** See {@link JVM#setFileNotification}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void setFileNotification(long delta) { SubstrateJVM.get().setFileNotification(delta); } /** See {@link JVM#setGlobalBufferCount}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void setGlobalBufferCount(long count) throws IllegalArgumentException, IllegalStateException { SubstrateJVM.get().setGlobalBufferCount(count); } /** See {@link JVM#setGlobalBufferSize}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void setGlobalBufferSize(long size) throws IllegalArgumentException { SubstrateJVM.get().setGlobalBufferSize(size); } /** See {@link JVM#setMemorySize}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void setMemorySize(long size) throws IllegalArgumentException { SubstrateJVM.get().setMemorySize(size); } /** See {@code JVM#setMethodSamplingPeriod}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void setMethodSamplingPeriod(long type, long intervalMillis) { SubstrateJVM.get().setMethodSamplingInterval(type, intervalMillis); } /** See {@link JVM#setOutput}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void setOutput(String file) { SubstrateJVM.get().setOutput(file); } /** See {@link JVM#setForceInstrumentation}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void setForceInstrumentation(boolean force) { } /** See {@link JVM#setCompressedIntegers}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void setCompressedIntegers(boolean compressed) throws IllegalStateException { SubstrateJVM.get().setCompressedIntegers(compressed); } /** See {@link JVM#setStackDepth}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void setStackDepth(int depth) throws IllegalArgumentException, IllegalStateException { SubstrateJVM.get().setStackDepth(depth); } /** See {@link JVM#setStackTraceEnabled}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void setStackTraceEnabled(long eventTypeId, boolean enabled) { SubstrateJVM.get().setStackTraceEnabled(eventTypeId, enabled); } /** See {@link JVM#setThreadBufferSize}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void setThreadBufferSize(long size) throws IllegalArgumentException, IllegalStateException { SubstrateJVM.get().setThreadBufferSize(size); } /** See {@link JVM#setThreshold}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static boolean setThreshold(long eventTypeId, long ticks) { return SubstrateJVM.get().setThreshold(eventTypeId, ticks); } /** See {@link JVM#storeMetadataDescriptor}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void storeMetadataDescriptor(byte[] bytes) { SubstrateJVM.get().storeMetadataDescriptor(bytes); } /** See {@link JVM#getAllowedToDoEventRetransforms}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static boolean getAllowedToDoEventRetransforms() { return false; } /** See {@link JVM#createJFR}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) private static boolean createJFR(boolean simulateFailure) throws IllegalStateException { return SubstrateJVM.get().createJFR(simulateFailure); } /** See {@link JVM#destroyJFR}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) private static boolean destroyJFR() { return SubstrateJVM.get().destroyJFR(); } /** See {@link JVM#isAvailable}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static boolean isAvailable() { return true; } /** See {@link JVM#getTimeConversionFactor}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static double getTimeConversionFactor() { return 1; } /** See {@link JVM#getTypeId(Class)}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static long getTypeId(Class clazz) { return JfrTraceId.getTraceId(clazz); } @@ -384,7 +346,6 @@ public static void flush(Target_jdk_jfr_internal_event_EventWriter writer, int u } @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void flush() { SubstrateJVM.get().flush(); } @@ -396,28 +357,24 @@ public static long commit(long nextPosition) { /** See {@link JVM#setRepositoryLocation}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void setRepositoryLocation(String dirText) { SubstrateJVM.get().setRepositoryLocation(dirText); } /** See {@code JVM#setDumpPath(String)}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void setDumpPath(String dumpPathText) { SubstrateJVM.get().setDumpPath(dumpPathText); } /** See {@code JVM#getDumpPath()}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static String getDumpPath() { return SubstrateJVM.get().getDumpPath(); } /** See {@link JVM#abort}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void abort(String errorMsg) { SubstrateJVM.get().abort(errorMsg); } @@ -430,7 +387,6 @@ public static boolean addStringConstant(long id, String s) { /** See {@link JVM#uncaughtException}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void uncaughtException(Thread thread, Throwable t) { // Would be used to determine the emergency dump filename if an exception happens during // shutdown. @@ -438,59 +394,50 @@ public static void uncaughtException(Thread thread, Throwable t) { /** See {@link JVM#setCutoff}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static boolean setCutoff(long eventTypeId, long cutoffTicks) { return SubstrateJVM.get().setCutoff(eventTypeId, cutoffTicks); } /** See {@link JVM#setThrottle}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static boolean setThrottle(long eventTypeId, long eventSampleSize, long periodMs) { return SubstrateJVM.get().setThrottle(eventTypeId, eventSampleSize, periodMs); } /** See {@link JVM#emitOldObjectSamples}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void emitOldObjectSamples(long cutoff, boolean emitAll, boolean skipBFS) { SubstrateJVM.get().emitOldObjectSamples(cutoff, emitAll, skipBFS); } /** See {@link JVM#shouldRotateDisk}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static boolean shouldRotateDisk() { return SubstrateJVM.get().shouldRotateDisk(); } @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void include(Thread thread) { JfrThreadLocal.setExcluded(thread, false); } @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static void exclude(Thread thread) { JfrThreadLocal.setExcluded(thread, true); } @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static boolean isExcluded(Thread thread) { return JfrThreadLocal.isThreadExcluded(thread); } @Substitute - @TargetElement(onlyWith = JDKLatest.class) // public static boolean isExcluded(Class eventClass) { // Temporarily always include. return false; } @Substitute - @TargetElement(onlyWith = JDKLatest.class) // public static boolean isInstrumented(Class eventClass) { // This should check for blessed commit methods in the event class [GR-41200] return true; @@ -498,33 +445,28 @@ public static boolean isInstrumented(Class e /** See {@link SubstrateJVM#getChunkStartNanos}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static long getChunkStartNanos() { return SubstrateJVM.get().getChunkStartNanos(); } @Substitute - @TargetElement(onlyWith = JDKLatest.class) // public static boolean setConfiguration(Class eventClass, Target_jdk_jfr_internal_event_EventConfiguration configuration) { return SubstrateJVM.get().setConfiguration(eventClass, configuration); } @Substitute - @TargetElement(onlyWith = JDKLatest.class) // public static Object getConfiguration(Class eventClass) { return SubstrateJVM.get().getConfiguration(eventClass); } /** See {@link JVM#getTypeId(String)}. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static long getTypeId(String name) { /* Not implemented at the moment. */ return -1; } @Substitute - @TargetElement(onlyWith = JDKLatest.class) // public static boolean isContainerized() { return Container.singleton().isContainerized(); } @@ -536,20 +478,17 @@ public static boolean isContainerized() { * interested in the host values (and not the containerized values). */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) // public static long hostTotalMemory() { return OperatingSystem.singleton().getPhysicalMemorySize().rawValue(); } @Substitute - @TargetElement(onlyWith = JDKLatest.class) // public static long hostTotalSwapMemory() { /* Not implemented at the moment. */ return -1; } @Substitute - @TargetElement(onlyWith = JDKLatest.class) // public static boolean isProduct() { /* * Currently only used for jdk.jfr.internal.tool.Command, which is not relevant for us. We diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_Repository.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_Repository.java index 1c2cce289b87..b8bdd4f79c59 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_Repository.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_Repository.java @@ -31,11 +31,10 @@ import com.oracle.svm.core.annotate.Delete; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.jdk.JDKLatest; import jdk.jfr.internal.Repository; -@TargetClass(value = Repository.class, onlyWith = {HasJfrSupport.class, JDKLatest.class}) +@TargetClass(value = Repository.class, onlyWith = HasJfrSupport.class) @SuppressWarnings("unused") public final class Target_jdk_jfr_internal_Repository { @@ -59,7 +58,7 @@ synchronized void ensureRepository() throws Exception { } } -@TargetClass(className = "jdk.jfr.internal.util.Utils", onlyWith = {HasJfrSupport.class, JDKLatest.class}) +@TargetClass(className = "jdk.jfr.internal.util.Utils", onlyWith = HasJfrSupport.class) final class Target_jdk_jfr_internal_util_Utils { @Alias public static native Path getPathInProperty(String prop, String subPath); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_StringPool.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_StringPool.java index f541e3647210..88a049180149 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_StringPool.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_StringPool.java @@ -26,15 +26,12 @@ import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDKLatest; @TargetClass(value = jdk.jfr.internal.StringPool.class, onlyWith = HasJfrSupport.class) final class Target_jdk_jfr_internal_StringPool { @SuppressWarnings("unused") @Substitute - @TargetElement(onlyWith = JDKLatest.class) public static long addString(String s, boolean pinVirtualThread) { // This disables String caching and forces the EventWriter to write strings by value. return -1; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_dcmd_AbstractDCmd.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_dcmd_AbstractDCmd.java index 483597251dd7..291dc343c035 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_dcmd_AbstractDCmd.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_dcmd_AbstractDCmd.java @@ -26,8 +26,6 @@ import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDKLatest; @TargetClass(className = "jdk.jfr.internal.dcmd.AbstractDCmd") public final class Target_jdk_jfr_internal_dcmd_AbstractDCmd { @@ -35,7 +33,6 @@ public final class Target_jdk_jfr_internal_dcmd_AbstractDCmd { public native String[] execute(String source, String arg, char delimiter); @Alias - @TargetElement(onlyWith = JDKLatest.class) public native String[] getHelp(); @Alias diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_event_EventWriter.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_event_EventWriter.java index 7302d842b49d..a33fb810f7cf 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_event_EventWriter.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_event_EventWriter.java @@ -26,8 +26,6 @@ import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDKLatest; @TargetClass(className = "jdk.jfr.internal.event.EventWriter", onlyWith = HasJfrSupport.class) public final class Target_jdk_jfr_internal_event_EventWriter { @@ -45,7 +43,6 @@ public final class Target_jdk_jfr_internal_event_EventWriter { long maxPosition; @Alias - @TargetElement(onlyWith = JDKLatest.class) @SuppressWarnings("unused") Target_jdk_jfr_internal_event_EventWriter(long startPos, long maxPos, long threadID, boolean valid, boolean pinVirtualThread, boolean excluded) { } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_jfc_JFC.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_jfc_JFC.java index b6a970a70d06..214ae2f175f2 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_jfc_JFC.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_jfc_JFC.java @@ -37,8 +37,6 @@ import com.oracle.svm.core.annotate.Delete; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDKLatest; import jdk.jfr.Configuration; import jdk.jfr.internal.jfc.JFC; @@ -49,7 +47,6 @@ public final class Target_jdk_jfr_internal_jfc_JFC { // Checkstyle: stop @Delete // - @TargetElement(onlyWith = JDKLatest.class) // private static Path JFC_DIRECTORY; // Checkstyle: resume diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_management_HiddenWait.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_management_HiddenWait.java index 0cf3b0862e0d..87e5dee32c33 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_management_HiddenWait.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_management_HiddenWait.java @@ -27,8 +27,7 @@ package com.oracle.svm.core.jfr; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.jdk.JDKLatest; -@TargetClass(className = "jdk.jfr.internal.management.HiddenWait", onlyWith = {HasJfrSupport.class, JDKLatest.class}) +@TargetClass(className = "jdk.jfr.internal.management.HiddenWait", onlyWith = HasJfrSupport.class) public final class Target_jdk_jfr_internal_management_HiddenWait { } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiInterface.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiInterface.java index 0d069019c298..726e19ef94b8 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiInterface.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmti/headers/JvmtiInterface.java @@ -31,9 +31,6 @@ import org.graalvm.nativeimage.c.type.VoidPointer; import org.graalvm.word.PointerBase; -import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDKLatest; - @CContext(JvmtiDirectives.class) @CStruct(value = "jvmtiInterface_1_", addStructKeyword = true) public interface JvmtiInterface extends PointerBase { @@ -431,11 +428,9 @@ public interface JvmtiInterface extends PointerBase { void setGetMethodModifiers(CFunctionPointer value); @CField - @TargetElement(onlyWith = JDKLatest.class) CFunctionPointer getClearAllFramePops(); @CField - @TargetElement(onlyWith = JDKLatest.class) void setClearAllFramePops(CFunctionPointer value); @CField diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodTypeForm.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodTypeForm.java index e8c25d3cf7ae..cca2c3dd80ac 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodTypeForm.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodTypeForm.java @@ -30,10 +30,8 @@ import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; import com.oracle.svm.core.fieldvaluetransformer.NewEmptyArrayFieldValueTransformer; import com.oracle.svm.core.invoke.Target_java_lang_invoke_MemberName; -import com.oracle.svm.core.jdk.JDKLatest; @TargetClass(className = "java.lang.invoke.MethodTypeForm") final class Target_java_lang_invoke_MethodTypeForm { @@ -49,6 +47,5 @@ final class Target_java_lang_invoke_MethodTypeForm { private SoftReference[] lambdaForms; @Alias @RecomputeFieldValue(kind = Kind.Reset) // - @TargetElement(onlyWith = JDKLatest.class) // private SoftReference interpretEntry; } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/monitor/MultiThreadedMonitorSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/monitor/MultiThreadedMonitorSupport.java index 7d3df34dbd86..ec98c22df2d1 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/monitor/MultiThreadedMonitorSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/monitor/MultiThreadedMonitorSupport.java @@ -40,12 +40,10 @@ import com.oracle.svm.core.WeakIdentityHashMap; import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; import com.oracle.svm.core.heap.RestrictHeapAccess; import com.oracle.svm.core.heap.RestrictHeapAccess.Access; import com.oracle.svm.core.hub.DynamicHub; import com.oracle.svm.core.hub.DynamicHubCompanion; -import com.oracle.svm.core.jdk.JDKLatest; import com.oracle.svm.core.jfr.JfrTicks; import com.oracle.svm.core.jfr.events.JavaMonitorInflateEvent; import com.oracle.svm.core.monitor.JavaMonitorQueuedSynchronizer.JavaMonitorConditionObject; @@ -529,10 +527,8 @@ protected JavaMonitor newMonitorLock() { final class Target_jdk_internal_misc_Blocker { @Alias - @TargetElement(onlyWith = JDKLatest.class) public static native boolean begin(); @Alias - @TargetElement(onlyWith = JDKLatest.class) public static native void end(boolean attempted); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_ScopedValue.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_ScopedValue.java index 0f55da8d0e18..985ff2f0e1b2 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_ScopedValue.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_ScopedValue.java @@ -28,8 +28,6 @@ import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDKLatest; @TargetClass(className = "java.lang.ScopedValue") final class Target_java_lang_ScopedValue { @@ -44,7 +42,7 @@ static Target_java_lang_ScopedValue_Snapshot scopedValueBindings() { } } -@TargetClass(className = "java.lang.ScopedValue", innerClass = "CallableOp", onlyWith = JDKLatest.class) +@TargetClass(className = "java.lang.ScopedValue", innerClass = "CallableOp") final class Target_java_lang_ScopedValue_CallableOp { } @@ -57,7 +55,6 @@ final class Target_java_lang_ScopedValue_Carrier { @Alias int bitmask; @Substitute - @TargetElement(onlyWith = JDKLatest.class) @Uninterruptible(reason = "Ensure no safepoint actions can disrupt reverting scoped value bindings.", calleeMustBe = false) private R runWith(Target_java_lang_ScopedValue_Snapshot newSnapshot, Target_java_lang_ScopedValue_CallableOp op) throws Exception { Target_java_lang_Thread.setScopedValueBindings(newSnapshot); @@ -85,7 +82,6 @@ private void runWith(Target_java_lang_ScopedValue_Snapshot newSnapshot, Runnable @TargetClass(className = "jdk.internal.vm.ScopedValueContainer") final class Target_jdk_internal_vm_ScopedValueContainer { @Alias - @TargetElement(onlyWith = JDKLatest.class) static native V call(Target_java_lang_ScopedValue_CallableOp op) throws Exception; @Alias diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_Thread.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_Thread.java index 9bcdcb890d16..cedc61ce33b7 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_Thread.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_Thread.java @@ -43,8 +43,6 @@ import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDKLatest; import com.oracle.svm.core.monitor.MonitorSupport; import jdk.graal.compiler.api.directives.GraalDirectives; @@ -203,7 +201,6 @@ void setCurrentThread(Thread thread) { @Substitute @Platforms(InternalPlatform.NATIVE_ONLY.class) - @TargetElement(onlyWith = JDKLatest.class) private Target_java_lang_Thread( ThreadGroup g, String name, @@ -353,7 +350,6 @@ private static void yield0() { } @Substitute - @TargetElement(onlyWith = JDKLatest.class) private static void sleepNanos0(long nanos) throws InterruptedException { // Virtual threads are handled in sleep() PlatformThreads.sleep(nanos); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_VirtualThread.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_VirtualThread.java index 655b2823afa4..e4cb29b1555d 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_VirtualThread.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_VirtualThread.java @@ -42,8 +42,6 @@ import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.annotate.TargetElement; -import com.oracle.svm.core.jdk.JDKLatest; import com.oracle.svm.core.jfr.HasJfrSupport; import com.oracle.svm.core.jfr.SubstrateJVM; import com.oracle.svm.core.monitor.MonitorInflationCause; @@ -63,20 +61,20 @@ public final class Target_java_lang_VirtualThread { @Alias static int PARKED; @Alias static int PINNED; @Alias static int YIELDING; - @TargetElement(onlyWith = JDKLatest.class) @Alias static int YIELDED; + @Alias static int YIELDED; @Alias static int TERMINATED; @Alias static int SUSPENDED; - @TargetElement(onlyWith = JDKLatest.class) @Alias static int TIMED_PARKING; - @TargetElement(onlyWith = JDKLatest.class) @Alias static int TIMED_PARKED; - @TargetElement(onlyWith = JDKLatest.class) @Alias static int TIMED_PINNED; - @TargetElement(onlyWith = JDKLatest.class) @Alias static int UNPARKED; - @TargetElement(onlyWith = JDKLatest.class) @Alias static int BLOCKING; - @TargetElement(onlyWith = JDKLatest.class) @Alias static int BLOCKED; - @TargetElement(onlyWith = JDKLatest.class) @Alias static int UNBLOCKED; - @TargetElement(onlyWith = JDKLatest.class) @Alias static int WAITING; - @TargetElement(onlyWith = JDKLatest.class) @Alias static int WAIT; - @TargetElement(onlyWith = JDKLatest.class) @Alias static int TIMED_WAITING; - @TargetElement(onlyWith = JDKLatest.class) @Alias static int TIMED_WAIT; + @Alias static int TIMED_PARKING; + @Alias static int TIMED_PARKED; + @Alias static int TIMED_PINNED; + @Alias static int UNPARKED; + @Alias static int BLOCKING; + @Alias static int BLOCKED; + @Alias static int UNBLOCKED; + @Alias static int WAITING; + @Alias static int WAIT; + @Alias static int TIMED_WAITING; + @Alias static int TIMED_WAIT; @Alias static Target_jdk_internal_vm_ContinuationScope VTHREAD_SCOPE; /** @@ -100,13 +98,13 @@ public final class Target_java_lang_VirtualThread { @Inject @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = NondefaultSchedulerSupplier.class) // private Executor nondefaultScheduler; - @TargetElement(onlyWith = JDKLatest.class) @Alias volatile int state; + @Alias volatile int state; // With our monitor implementation, we do not use these fields. - @TargetElement(onlyWith = JDKLatest.class) @Delete volatile Target_java_lang_VirtualThread next; - @TargetElement(onlyWith = JDKLatest.class) @Alias @InjectAccessors(AlwaysFalseAccessor.class) boolean blockPermit; - @TargetElement(onlyWith = JDKLatest.class) @Alias @InjectAccessors(AlwaysFalseAccessor.class) boolean onWaitingList; - @TargetElement(onlyWith = JDKLatest.class) @Alias @InjectAccessors(AlwaysFalseAccessor.class) boolean notified; + @Delete volatile Target_java_lang_VirtualThread next; + @Alias @InjectAccessors(AlwaysFalseAccessor.class) boolean blockPermit; + @Alias @InjectAccessors(AlwaysFalseAccessor.class) boolean onWaitingList; + @Alias @InjectAccessors(AlwaysFalseAccessor.class) boolean notified; // Checkstyle: resume @Inject // @@ -205,14 +203,12 @@ private void notifyJvmtiUnmount(boolean hide) { @Substitute @SuppressWarnings({"static-method", "unused"}) - @TargetElement(onlyWith = JDKLatest.class) private static void notifyJvmtiDisableSuspend(boolean enter) { // unimplemented (GR-51158) } @Substitute @SuppressWarnings("unused") - @TargetElement(onlyWith = JDKLatest.class) private static void postPinnedEvent(String op) { } @@ -232,15 +228,12 @@ private static void postPinnedEvent(String op) { native StackTraceElement[] tryGetStackTrace(); @Alias - @TargetElement(onlyWith = JDKLatest.class) native void disableSuspendAndPreempt(); @Alias - @TargetElement(onlyWith = JDKLatest.class) native void enableSuspendAndPreempt(); @Alias - @TargetElement(onlyWith = JDKLatest.class) native Object carrierThreadAccessLock(); @Alias @@ -277,7 +270,6 @@ void mount() { native int state(); @Substitute - @TargetElement(onlyWith = JDKLatest.class) void setState(int s) { assert s != BLOCKING && s != BLOCKED && s != UNBLOCKED && s != WAITING && s != WAIT && s != TIMED_WAIT && s != TIMED_WAITING // : "states should never be reached with our monitor implementation"; @@ -285,23 +277,19 @@ void setState(int s) { } @Substitute - @TargetElement(onlyWith = JDKLatest.class) @SuppressWarnings({"static-method", "unused"}) void waitTimeoutExpired(byte seqNo) { throw VMError.shouldNotReachHere("not used in our monitor implementation"); } @Delete - @TargetElement(onlyWith = JDKLatest.class) static native void unblockVirtualThreads(); @Delete - @TargetElement(onlyWith = JDKLatest.class) private static native Target_java_lang_VirtualThread takeVirtualThreadListToUnblock(); /** Needed for handling monitor-specific states. */ @Substitute - @TargetElement(onlyWith = JDKLatest.class) @SuppressWarnings("hiding") Thread.State threadState() { int state = state() & ~SUSPENDED;