@@ -163,7 +163,9 @@ public final class System {
163
163
/*[IF JAVA_SPEC_VERSION >= 11]*/
164
164
private static boolean hasSetErrEncoding ;
165
165
private static boolean hasSetOutEncoding ;
166
+ /*[IF JAVA_SPEC_VERSION < 24]*/
166
167
private static String consoleDefaultEncoding ;
168
+ /*[ENDIF] JAVA_SPEC_VERSION < 24 */
167
169
/* The consoleDefaultCharset is different from the default console encoding when the encoding
168
170
* doesn't exist, or isn't available at startup. Some character sets are not available in the
169
171
* java.base module, there are more in the jdk.charsets module, and so are not used at startup.
@@ -228,7 +230,9 @@ public final class System {
228
230
* if different from the default console Charset.
229
231
*
230
232
* consoleDefaultCharset must be initialized before calling.
233
+ /*[IF JAVA_SPEC_VERSION < 24]
231
234
* consoleDefaultEncoding must be initialized before calling with fallback set to true.
235
+ /*[ENDIF] JAVA_SPEC_VERSION < 24
232
236
*/
233
237
static Charset getCharset (boolean isStdout , boolean fallback ) {
234
238
/*[IF JAVA_SPEC_VERSION >= 19]*/
@@ -248,6 +252,7 @@ static Charset getCharset(boolean isStdout, boolean fallback) {
248
252
// ignore unsupported or invalid encodings
249
253
}
250
254
}
255
+ /*[IF JAVA_SPEC_VERSION < 24]*/
251
256
if (fallback && (consoleDefaultEncoding != null )) {
252
257
try {
253
258
Charset newCharset = Charset .forName (consoleDefaultEncoding );
@@ -260,6 +265,7 @@ static Charset getCharset(boolean isStdout, boolean fallback) {
260
265
// ignore unsupported or invalid encodings
261
266
}
262
267
}
268
+ /*[ENDIF] JAVA_SPEC_VERSION < 24 */
263
269
return null ;
264
270
}
265
271
@@ -419,8 +425,12 @@ static void afterClinitInitialization() {
419
425
Properties props = internalGetProperties ();
420
426
/*[IF JAVA_SPEC_VERSION >= 11]*/
421
427
/*[IF JAVA_SPEC_VERSION >= 18]*/
428
+ /*[IF JAVA_SPEC_VERSION >= 24]*/
429
+ consoleDefaultCharset = sun .nio .cs .UTF_8 .INSTANCE ;
430
+ /*[ELSE] JAVA_SPEC_VERSION >= 24 */
422
431
consoleDefaultEncoding = props .getProperty ("native.encoding" ); //$NON-NLS-1$
423
432
consoleDefaultCharset = Charset .forName (consoleDefaultEncoding , sun .nio .cs .UTF_8 .INSTANCE );
433
+ /*[ENDIF] JAVA_SPEC_VERSION >= 24 */
424
434
/*[ELSE] JAVA_SPEC_VERSION >= 18 */
425
435
String fileEncodingProp = props .getProperty ("file.encoding" ); //$NON-NLS-1$
426
436
// Do not call Charset.defaultEncoding() since this would initialize the default encoding
0 commit comments