27
27
28
28
import java .io .InputStream ;
29
29
import java .io .PrintStream ;
30
- import java .lang .reflect .Field ;
31
30
32
- import com .oracle .svm .core .util .VMError ;
33
- import com .oracle .svm .util .ReflectionUtil ;
34
- import jdk .internal .access .SharedSecrets ;
35
31
import org .graalvm .nativeimage .ImageSingletons ;
36
32
import org .graalvm .nativeimage .hosted .Feature ;
37
33
44
40
import com .oracle .svm .core .layeredimagesingleton .FeatureSingleton ;
45
41
import com .oracle .svm .hosted .imagelayer .CrossLayerConstantRegistry ;
46
42
43
+ import jdk .internal .access .SharedSecrets ;
44
+
47
45
/**
48
46
* We use an {@link Feature.DuringSetupAccess#registerObjectReplacer object replacer} because the
49
47
* streams can be cached in other instance and static fields in addition to the fields in
@@ -64,18 +62,7 @@ public SystemInOutErrFeature() {
64
62
hostedOut = wrappers .outWrapper ;
65
63
hostedErr = wrappers .errWrapper ;
66
64
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 ();
79
66
}
80
67
81
68
private SystemInOutErrSupport runtime ;
0 commit comments