Skip to content

Commit 5fcf5a2

Browse files
committed
svm: remove JDK 21 substitutions
1 parent 3723281 commit 5fcf5a2

File tree

47 files changed

+23
-1610
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+23
-1610
lines changed

substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_java_lang_foreign_SymbolLookup.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
import com.oracle.svm.core.jdk.Target_java_lang_Module;
5151
import com.oracle.svm.core.snippets.KnownIntrinsics;
5252

53-
import jdk.graal.compiler.serviceprovider.JavaVersionUtil;
5453
import jdk.internal.foreign.MemorySessionImpl;
5554
import jdk.internal.foreign.Utils;
5655
import jdk.internal.loader.NativeLibrary;
@@ -139,11 +138,7 @@ static void ensureNativeAccess(Class<?> currentClass, Class<?> owner, String met
139138
*/
140139
Target_java_lang_Module module = SubstrateUtil.cast(currentClass != null ? currentClass.getModule() : ClassLoader.getSystemClassLoader().getUnnamedModule(),
141140
Target_java_lang_Module.class);
142-
if (JavaVersionUtil.JAVA_SPEC <= 21) {
143-
module.ensureNativeAccess(owner, methodName);
144-
} else {
145-
module.ensureNativeAccess(owner, methodName, currentClass, false);
146-
}
141+
module.ensureNativeAccess(owner, methodName, currentClass, false);
147142

148143
}
149144

substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_foreign_Utils_BaseAndScale.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import com.oracle.svm.core.annotate.RecomputeFieldValue;
3131
import com.oracle.svm.core.annotate.TargetClass;
3232
import com.oracle.svm.core.config.ConfigurationValues;
33-
import com.oracle.svm.core.jdk.JDK21OrEarlier;
3433
import com.oracle.svm.core.jdk.JDKLatest;
3534
import com.oracle.svm.core.util.VMError;
3635

@@ -45,13 +44,6 @@ final class Target_jdk_internal_foreign_Utils_BaseAndScale {
4544
long base;
4645
}
4746

48-
@TargetClass(className = "jdk.internal.foreign.Utils", innerClass = "BaseAndScale", onlyWith = {ForeignAPIPredicates.Enabled.class, JDK21OrEarlier.class})
49-
final class Target_jdk_internal_foreign_Utils_BaseAndScale_JDK21 {
50-
@Alias //
51-
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = BaseFieldRecomputer.class) //
52-
int base;
53-
}
54-
5547
final class BaseFieldRecomputer implements FieldValueTransformer {
5648

5749
@Override

substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_jdk_internal_misc_ScopedMemoryAccess.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import com.oracle.svm.core.annotate.Substitute;
3535
import com.oracle.svm.core.annotate.TargetClass;
3636
import com.oracle.svm.core.annotate.TargetElement;
37-
import com.oracle.svm.core.jdk.JDK21OrEarlier;
3837
import com.oracle.svm.core.jdk.JDKLatest;
3938
import com.oracle.svm.core.nodes.foreign.MemoryArenaValidInScopeNode;
4039
import com.oracle.svm.core.util.BasedOnJDKFile;
@@ -206,14 +205,6 @@ public void forceInternal(MemorySessionImpl session, MappedMemoryUtilsProxy mapp
206205
void closeScope0(Target_jdk_internal_foreign_MemorySessionImpl session, @SuppressWarnings("unused") Target_jdk_internal_misc_ScopedMemoryAccess_ScopedAccessError error) {
207206
new SyncCloseScopeOperation(session).enqueue();
208207
}
209-
210-
@SuppressWarnings("static-method")
211-
@Substitute
212-
@TargetElement(onlyWith = JDK21OrEarlier.class)
213-
boolean closeScope0(Target_jdk_internal_foreign_MemorySessionImpl session) {
214-
new SyncCloseScopeOperation(session).enqueue();
215-
return true;
216-
}
217208
}
218209

219210
@Retention(RetentionPolicy.RUNTIME)

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/dcmd/AbstractJfrDCmd.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
import com.oracle.svm.core.jfr.Target_jdk_jfr_internal_dcmd_AbstractDCmd;
2929
import com.oracle.svm.core.util.VMError;
3030

31-
import jdk.graal.compiler.serviceprovider.JavaVersionUtil;
32-
3331
/**
3432
* Base class for JFR-related diagnostic commands. Note that the JDK already implements those
3533
* diagnostic commands, so we wrap and reuse the JDK implementations.
@@ -57,16 +55,9 @@ protected String execute(DCmdArguments args) throws Throwable {
5755
@Override
5856
protected String getSyntaxAndExamples() {
5957
Target_jdk_jfr_internal_dcmd_AbstractDCmd cmd = createDCmd();
60-
String[] lines = getHelp(cmd);
58+
String[] lines = cmd.getHelp();
6159
return String.join(System.lineSeparator(), lines);
6260
}
6361

64-
private static String[] getHelp(Target_jdk_jfr_internal_dcmd_AbstractDCmd cmd) {
65-
if (JavaVersionUtil.JAVA_SPEC <= 21) {
66-
return cmd.printHelp();
67-
}
68-
return cmd.getHelp();
69-
}
70-
7162
protected abstract Target_jdk_jfr_internal_dcmd_AbstractDCmd createDCmd();
7263
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceInternals.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import java.lang.ref.Reference;
3131
import java.lang.ref.SoftReference;
3232

33-
import jdk.graal.compiler.serviceprovider.JavaVersionUtil;
3433
import org.graalvm.word.Pointer;
3534

3635
import com.oracle.svm.core.NeverInline;
@@ -162,8 +161,7 @@ public static <T> void setNextDiscovered(Reference<T> instance, Reference<?> new
162161
}
163162

164163
public static boolean hasQueue(Reference<?> instance) {
165-
return cast(instance).queue != (JavaVersionUtil.JAVA_SPEC > 21 ? Target_java_lang_ref_ReferenceQueue.NULL_QUEUE
166-
: Target_java_lang_ref_ReferenceQueue.NULL);
164+
return cast(instance).queue != Target_java_lang_ref_ReferenceQueue.NULL_QUEUE;
167165
}
168166

169167
/*
@@ -231,8 +229,7 @@ public static void processPendingReferences() {
231229
} else {
232230
@SuppressWarnings("unchecked")
233231
Target_java_lang_ref_ReferenceQueue<? super Object> queue = SubstrateUtil.cast(ref.queue, Target_java_lang_ref_ReferenceQueue.class);
234-
if (queue != (JavaVersionUtil.JAVA_SPEC > 21 ? Target_java_lang_ref_ReferenceQueue.NULL_QUEUE
235-
: Target_java_lang_ref_ReferenceQueue.NULL)) {
232+
if (queue != Target_java_lang_ref_ReferenceQueue.NULL_QUEUE) {
236233
// Enqueues, avoiding the potentially overridden Reference.enqueue().
237234
queue.enqueue(ref);
238235
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_Reference.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.lang.reflect.Field;
3030
import java.util.function.BooleanSupplier;
3131

32-
import jdk.graal.compiler.serviceprovider.JavaVersionUtil;
3332
import org.graalvm.nativeimage.Platform;
3433
import org.graalvm.nativeimage.Platforms;
3534
import org.graalvm.nativeimage.hosted.FieldValueTransformer;
@@ -120,8 +119,7 @@ public final class Target_java_lang_ref_Reference<T> {
120119
@Uninterruptible(reason = "The initialization of the fields must be atomic with respect to collection.")
121120
Target_java_lang_ref_Reference(T referent, Target_java_lang_ref_ReferenceQueue<? super T> queue) {
122121
this.referent = referent;
123-
this.queue = (queue == null) ? (JavaVersionUtil.JAVA_SPEC > 21 ? Target_java_lang_ref_ReferenceQueue.NULL_QUEUE
124-
: Target_java_lang_ref_ReferenceQueue.NULL) : queue;
122+
this.queue = (queue == null) ? Target_java_lang_ref_ReferenceQueue.NULL_QUEUE : queue;
125123
}
126124

127125
@KeepOriginal

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_ReferenceQueue.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import com.oracle.svm.core.annotate.RecomputeFieldValue;
3232
import com.oracle.svm.core.annotate.TargetClass;
3333
import com.oracle.svm.core.annotate.TargetElement;
34-
import com.oracle.svm.core.jdk.JDK21OrEarlier;
3534
import com.oracle.svm.core.jdk.JDKLatest;
3635

3736
@TargetClass(ReferenceQueue.class)
@@ -42,10 +41,6 @@ final class Target_java_lang_ref_ReferenceQueue<T> {
4241
static Target_java_lang_ref_ReferenceQueue<Object> NULL_QUEUE;
4342
// CheckStyle: resume
4443

45-
@Alias //
46-
@TargetElement(onlyWith = JDK21OrEarlier.class) //
47-
static Target_java_lang_ref_ReferenceQueue<Object> NULL;
48-
4944
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) //
5045
volatile Reference<? extends T> head;
5146

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_jdk_internal_ref_Cleaner.java

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.lang.ref.Cleaner;
2828
import java.lang.ref.ReferenceQueue;
2929

30-
import jdk.graal.compiler.serviceprovider.JavaVersionUtil;
3130
import org.graalvm.nativeimage.hosted.FieldValueTransformer;
3231

3332
import com.oracle.svm.core.NeverInline;
@@ -37,11 +36,11 @@
3736
import com.oracle.svm.core.annotate.Substitute;
3837
import com.oracle.svm.core.annotate.TargetClass;
3938
import com.oracle.svm.core.annotate.TargetElement;
40-
import com.oracle.svm.core.jdk.JDK21OrEarlier;
4139
import com.oracle.svm.core.jdk.JDKLatest;
4240
import com.oracle.svm.core.thread.VMThreads;
4341
import com.oracle.svm.util.ReflectionUtil;
4442

43+
import jdk.graal.compiler.serviceprovider.JavaVersionUtil;
4544
import jdk.internal.misc.InnocuousThread;
4645

4746
@TargetClass(className = "jdk.internal.ref.Cleaner")
@@ -79,44 +78,13 @@ final class Target_java_lang_ref_Cleaner_Cleanable {
7978
@TargetClass(className = "jdk.internal.ref.CleanerImpl")
8079
final class Target_jdk_internal_ref_CleanerImpl {
8180

82-
@TargetElement(onlyWith = JDK21OrEarlier.class)//
83-
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClassName = "jdk.internal.ref.CleanerImpl$PhantomCleanableRef")//
84-
Target_jdk_internal_ref_PhantomCleanable_JDK21 phantomCleanableList;
85-
8681
@TargetElement(onlyWith = JDKLatest.class)//
8782
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClassName = "jdk.internal.ref.CleanerImpl$CleanableList")//
8883
Target_jdk_internal_ref_CleanerImpl_CleanableList activeList;
8984

9085
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClassName = "java.lang.ref.ReferenceQueue")//
9186
public ReferenceQueue<Object> queue;
9287

93-
/**
94-
* This loop executes in a daemon thread and waits until there are no more cleanables (including
95-
* the {@code Cleaner} itself), ignoring {@link InterruptedException}. This blocks VM tear-down,
96-
* so we add a check if the VM is tearing down here.
97-
*/
98-
@TargetElement(name = "run", onlyWith = JDK21OrEarlier.class)
99-
@Substitute
100-
public void runJDK21() {
101-
Thread t = Thread.currentThread();
102-
InnocuousThread mlThread = (t instanceof InnocuousThread) ? (InnocuousThread) t : null;
103-
while (!phantomCleanableList.isListEmpty()) {
104-
if (mlThread != null) {
105-
mlThread.eraseThreadLocals();
106-
}
107-
try {
108-
Cleaner.Cleanable ref = (Cleaner.Cleanable) queue.remove(60 * 1000L);
109-
if (ref != null) {
110-
ref.clean();
111-
}
112-
} catch (Throwable e) {
113-
if (VMThreads.isTearingDown()) {
114-
return;
115-
}
116-
}
117-
}
118-
}
119-
12088
@TargetElement(name = "run", onlyWith = JDKLatest.class)
12189
@Substitute
12290
public void run() {
@@ -140,27 +108,6 @@ public void run() {
140108
}
141109
}
142110

143-
@TargetClass(className = "jdk.internal.ref.PhantomCleanable", onlyWith = JDK21OrEarlier.class)
144-
final class Target_jdk_internal_ref_PhantomCleanable_JDK21 {
145-
/*
146-
* Unlink from the list for the image heap so that we cannot reach Cleanables irrelevant for the
147-
* image heap which could fail the image build; we reset the list head anyway.
148-
*/
149-
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = HolderObjectFieldTransformer.class) //
150-
Target_jdk_internal_ref_PhantomCleanable_JDK21 prev;
151-
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = HolderObjectFieldTransformer.class) //
152-
Target_jdk_internal_ref_PhantomCleanable_JDK21 next;
153-
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = HolderObjectFieldTransformer.class) //
154-
Target_jdk_internal_ref_PhantomCleanable_JDK21 list;
155-
156-
@Alias
157-
native boolean isListEmpty();
158-
159-
@AnnotateOriginal
160-
@NeverInline("Ensure that every exception can be caught, including implicit exceptions.")
161-
/* final */ native void clean();
162-
}
163-
164111
@TargetClass(className = "jdk.internal.ref.PhantomCleanable", onlyWith = JDKLatest.class)
165112
final class Target_jdk_internal_ref_PhantomCleanable {
166113
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = GetCleanableListSingletonTransformer.class) //

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHub.java

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@
114114
import com.oracle.svm.core.heap.UnknownPrimitiveField;
115115
import com.oracle.svm.core.imagelayer.DynamicImageLayerInfo;
116116
import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport;
117-
import com.oracle.svm.core.jdk.JDK21OrEarlier;
118117
import com.oracle.svm.core.jdk.JDKLatest;
119118
import com.oracle.svm.core.jdk.ProtectionDomainSupport;
120119
import com.oracle.svm.core.jdk.Resources;
@@ -1113,10 +1112,6 @@ void setClassLoaderAtRuntime(ClassLoader loader) {
11131112
@KeepOriginal
11141113
private native boolean isAnonymousClass();
11151114

1116-
@KeepOriginal
1117-
@TargetElement(onlyWith = JDK21OrEarlier.class)
1118-
private native boolean isUnnamedClass();
1119-
11201115
@Substitute
11211116
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
11221117
public boolean isHidden() {
@@ -1500,29 +1495,6 @@ private RecordComponent[] getRecordComponents0() {
15001495
@KeepOriginal
15011496
private native Class<?>[] getPermittedSubclasses();
15021497

1503-
@TargetElement(onlyWith = JDK21OrEarlier.class)
1504-
@Substitute
1505-
@SuppressWarnings("unused")
1506-
private void checkMemberAccess(SecurityManager sm, int which, Class<?> caller, boolean checkProxyInterfaces) {
1507-
/* No runtime access checks. */
1508-
}
1509-
1510-
@TargetElement(onlyWith = JDK21OrEarlier.class)
1511-
@Substitute
1512-
@SuppressWarnings({"deprecation", "unused"})
1513-
private void checkPackageAccess(SecurityManager sm, ClassLoader ccl, boolean checkProxyInterfaces) {
1514-
/* No runtime access checks. */
1515-
}
1516-
1517-
/**
1518-
* Never called as it is partially evaluated away due to SecurityManager.
1519-
*/
1520-
@TargetElement(onlyWith = JDK21OrEarlier.class)
1521-
@KeepOriginal
1522-
@SuppressWarnings({"deprecation", "unused"})
1523-
private static native void checkPackageAccessForPermittedSubclasses(@SuppressWarnings("removal") SecurityManager sm,
1524-
ClassLoader ccl, Class<?>[] subClasses);
1525-
15261498
@Substitute
15271499
private static ReflectionFactory getReflectionFactory() {
15281500
return Target_jdk_internal_reflect_ReflectionFactory.getReflectionFactory();
@@ -1634,9 +1606,7 @@ private static Class<?> forName(Module module, String className) throws Throwabl
16341606
return forName(module, className, Reflection.getCallerClass());
16351607
}
16361608

1637-
@Substitute
16381609
@CallerSensitiveAdapter
1639-
@TargetElement(onlyWith = JDK21OrEarlier.class)
16401610
private static Class<?> forName(@SuppressWarnings("unused") Module module, String className, Class<?> caller) throws Throwable {
16411611
/*
16421612
* 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
16551625
return forName(name, initialize, loader, Reflection.getCallerClass());
16561626
}
16571627

1658-
@Substitute
16591628
@CallerSensitiveAdapter
1660-
@TargetElement(onlyWith = JDK21OrEarlier.class)
16611629
private static Class<?> forName(String name, boolean initialize, ClassLoader loader, @SuppressWarnings("unused") Class<?> caller) throws Throwable {
16621630
if (name == null) {
16631631
throw new NullPointerException();
@@ -1767,12 +1735,6 @@ public ProtectionDomain getProtectionDomain() {
17671735
return companion.protectionDomain;
17681736
}
17691737

1770-
@Substitute
1771-
@TargetElement(onlyWith = JDK21OrEarlier.class)
1772-
private ProtectionDomain protectionDomain() {
1773-
return getProtectionDomain();
1774-
}
1775-
17761738
void setProtectionDomainAtRuntime(ProtectionDomain protectionDomain) {
17771739
VMError.guarantee(companion.protectionDomain == null && protectionDomain != null);
17781740
companion.protectionDomain = protectionDomain;
@@ -2101,10 +2063,6 @@ private Class<?>[] getPermittedSubclasses0() {
21012063
@KeepOriginal
21022064
private static native void addAll(Collection<Field> c, Field[] o);
21032065

2104-
@KeepOriginal
2105-
@TargetElement(onlyWith = JDK21OrEarlier.class)
2106-
private native Target_java_lang_PublicMethods_MethodList getMethodsRecursive(String methodName, Class<?>[] parameterTypes, boolean includeStatic);
2107-
21082066
@KeepOriginal
21092067
@TargetElement(onlyWith = JDKLatest.class)
21102068
private native Target_java_lang_PublicMethods_MethodList getMethodsRecursive(String methodName, Class<?>[] parameterTypes, boolean includeStatic, boolean publicOnly);

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/SunReflectTypeSubstitutions.java

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)