Skip to content

Commit 9b3238f

Browse files
committed
svm: further JDK 21 related clean ups
1 parent 565df9f commit 9b3238f

File tree

2 files changed

+4
-32
lines changed

2 files changed

+4
-32
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateUtil.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import java.lang.reflect.Constructor;
3131
import java.lang.reflect.Executable;
3232
import java.lang.reflect.Field;
33-
import java.lang.reflect.InvocationTargetException;
3433
import java.lang.reflect.Member;
3534
import java.lang.reflect.Method;
3635
import java.util.List;
@@ -90,26 +89,12 @@ public static String getArchitectureName() {
9089
};
9190
}
9291

93-
/*
94-
* [GR-55515]: Accessing isTerminal() reflectively only for 21 JDK compatibility. After dropping
95-
* JDK 21, use it directly.
96-
*/
97-
private static final Method IS_TERMINAL_METHOD = ReflectionUtil.lookupMethod(true, Console.class, "isTerminal");
98-
9992
private static boolean isTTY() {
10093
Console console = System.console();
10194
if (console == null) {
10295
return false;
10396
}
104-
if (IS_TERMINAL_METHOD != null) {
105-
try {
106-
return (boolean) IS_TERMINAL_METHOD.invoke(console);
107-
} catch (IllegalAccessException | InvocationTargetException e) {
108-
throw new Error(e);
109-
}
110-
} else {
111-
return true;
112-
}
97+
return console.isTerminal();
11398
}
11499

115100
public static boolean isNonInteractiveTerminal() {

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SystemInOutErrFeature.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@
2727

2828
import java.io.InputStream;
2929
import java.io.PrintStream;
30-
import java.lang.reflect.Field;
3130

32-
import com.oracle.svm.core.util.VMError;
33-
import com.oracle.svm.util.ReflectionUtil;
34-
import jdk.internal.access.SharedSecrets;
3531
import org.graalvm.nativeimage.ImageSingletons;
3632
import org.graalvm.nativeimage.hosted.Feature;
3733

@@ -44,6 +40,8 @@
4440
import com.oracle.svm.core.layeredimagesingleton.FeatureSingleton;
4541
import com.oracle.svm.hosted.imagelayer.CrossLayerConstantRegistry;
4642

43+
import jdk.internal.access.SharedSecrets;
44+
4745
/**
4846
* We use an {@link Feature.DuringSetupAccess#registerObjectReplacer object replacer} because the
4947
* streams can be cached in other instance and static fields in addition to the fields in
@@ -64,18 +62,7 @@ public SystemInOutErrFeature() {
6462
hostedOut = wrappers.outWrapper;
6563
hostedErr = wrappers.errWrapper;
6664
hostedInitialIn = SharedSecrets.getJavaLangAccess().initialSystemIn();
67-
/*
68-
* GR-55515: Migrate to JavaLangAccess#initialSystemErr(). The method
69-
* JavaLangAccess#initialSystemErr() and the System#initialErr field were both introduced in
70-
* JDK 23. Once JDK 21 compatibility is no longer required, consider switching to
71-
* SharedSecrets.getJavaLangAccess().initialSystemErr().
72-
*/
73-
Field initialErrField = ReflectionUtil.lookupField(true, System.class, "initialErr");
74-
try {
75-
hostedInitialErr = initialErrField != null ? (PrintStream) initialErrField.get(null) : null;
76-
} catch (IllegalAccessException illegalAccess) {
77-
throw VMError.shouldNotReachHere(illegalAccess);
78-
}
65+
hostedInitialErr = SharedSecrets.getJavaLangAccess().initialSystemErr();
7966
}
8067

8168
private SystemInOutErrSupport runtime;

0 commit comments

Comments
 (0)