Skip to content

Commit 041a820

Browse files
committed
Provide com.oracle.svm.core.jdk.SystemInOutErrFeature backward compatibility
1 parent fb131df commit 041a820

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SystemInOutErrSupport.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,32 @@ private static PrintStream newPrintStream(FileOutputStream fos, String enc) {
6363
return new PrintStream(new BufferedOutputStream(fos, 128), true);
6464
}
6565

66-
public static InputStream in() {
67-
return ImageSingletons.lookup(SystemInOutErrSupport.class).in;
66+
public InputStream in() {
67+
return in;
6868
}
6969

7070
public static void setIn(InputStream in) {
7171
ImageSingletons.lookup(SystemInOutErrSupport.class).in = Objects.requireNonNull(in);
7272
}
7373

74-
public static PrintStream out() {
75-
return ImageSingletons.lookup(SystemInOutErrSupport.class).out;
74+
public PrintStream out() {
75+
return out;
7676
}
7777

7878
public static void setOut(PrintStream out) {
7979
ImageSingletons.lookup(SystemInOutErrSupport.class).out = Objects.requireNonNull(out);
8080
}
8181

82-
public static PrintStream err() {
83-
return ImageSingletons.lookup(SystemInOutErrSupport.class).err;
82+
public PrintStream err() {
83+
return err;
8484
}
8585

8686
public static void setErr(PrintStream err) {
8787
ImageSingletons.lookup(SystemInOutErrSupport.class).err = Objects.requireNonNull(err);
8888
}
8989
}
90+
91+
@SuppressWarnings("unused")
92+
class SystemInOutErrFeature implements Feature {
93+
/* Dummy for backward compatibility. */
94+
}

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,17 @@ public class SystemInOutErrFeature implements Feature {
4848
private final PrintStream hostedOut = System.out;
4949
private final PrintStream hostedErr = System.err;
5050

51+
private SystemInOutErrSupport runtime;
52+
53+
@Override
54+
public void afterRegistration(AfterRegistrationAccess access) {
55+
runtime = new SystemInOutErrSupport();
56+
ImageSingletons.add(SystemInOutErrSupport.class, runtime);
57+
}
58+
5159
@Override
5260
public void duringSetup(DuringSetupAccess access) {
5361
NativeImageSystemIOWrappers.singleton().verifySystemOutErrReplacement();
54-
55-
ImageSingletons.add(SystemInOutErrSupport.class, new SystemInOutErrSupport());
5662
access.registerObjectReplacer(this::replaceStreams);
5763
}
5864

@@ -63,11 +69,11 @@ public void cleanup() {
6369

6470
Object replaceStreams(Object object) {
6571
if (object == hostedIn) {
66-
return SystemInOutErrSupport.in();
72+
return runtime.in();
6773
} else if (object == hostedOut) {
68-
return SystemInOutErrSupport.out();
74+
return runtime.out();
6975
} else if (object == hostedErr) {
70-
return SystemInOutErrSupport.err();
76+
return runtime.err();
7177
} else {
7278
return object;
7379
}

0 commit comments

Comments
 (0)