diff --git a/src/java.base/share/classes/java/io/Console.java b/src/java.base/share/classes/java/io/Console.java index cedb6124a31ee..838334a0901fe 100644 --- a/src/java.base/share/classes/java/io/Console.java +++ b/src/java.base/share/classes/java/io/Console.java @@ -31,6 +31,7 @@ import jdk.internal.access.SharedSecrets; import jdk.internal.io.JdkConsoleImpl; import jdk.internal.io.JdkConsoleProvider; +import jdk.internal.util.StaticProperty; import sun.nio.cs.UTF_8; /** @@ -555,9 +556,9 @@ private static UnsupportedOperationException newUnsupportedOperationException() private static final boolean istty = istty(); private static final Charset STDIN_CHARSET = - Charset.forName(System.getProperty("stdin.encoding"), UTF_8.INSTANCE); + Charset.forName(StaticProperty.stdinEncoding(), UTF_8.INSTANCE); private static final Charset STDOUT_CHARSET = - Charset.forName(System.getProperty("stdout.encoding"), UTF_8.INSTANCE); + Charset.forName(StaticProperty.stdoutEncoding(), UTF_8.INSTANCE); private static final Console cons = instantiateConsole(); static { // Set up JavaIOAccess in SharedSecrets diff --git a/src/java.base/share/classes/java/lang/IO.java b/src/java.base/share/classes/java/lang/IO.java index 4630d8a3be208..c4586f6478a87 100644 --- a/src/java.base/share/classes/java/lang/IO.java +++ b/src/java.base/share/classes/java/lang/IO.java @@ -32,6 +32,8 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import jdk.internal.util.StaticProperty; + /** * A collection of static methods that provide convenient access to {@link System#in} * and {@link System#out} for line-oriented input and output. @@ -187,7 +189,7 @@ public static String readln(String prompt) { */ static synchronized BufferedReader reader() { if (br == null) { - String enc = System.getProperty("stdin.encoding", ""); + String enc = StaticProperty.stdinEncoding(); Charset cs = Charset.forName(enc, StandardCharsets.UTF_8); br = new BufferedReader(new InputStreamReader(System.in, cs)); } diff --git a/src/java.base/share/classes/jdk/internal/util/StaticProperty.java b/src/java.base/share/classes/jdk/internal/util/StaticProperty.java index abe2dafa3b795..4fb3ae7a184ee 100644 --- a/src/java.base/share/classes/jdk/internal/util/StaticProperty.java +++ b/src/java.base/share/classes/jdk/internal/util/StaticProperty.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ import java.util.Properties; /** - * System Property access for internal use only. + * System Property access for `java.base` module internal use only. * Read-only access to System property values initialized during Phase 1 * are cached. Setting, clearing, or modifying the value using * {@link System#setProperty} or {@link System#getProperties()} is ignored. @@ -48,8 +48,11 @@ public final class StaticProperty { private static final String JAVA_IO_TMPDIR; private static final String NATIVE_ENCODING; private static final String FILE_ENCODING; - private static final String JAVA_PROPERTIES_DATE; + private static final String STDIN_ENCODING; + private static final String STDERR_ENCODING; + private static final String STDOUT_ENCODING; private static final String SUN_JNU_ENCODING; + private static final String JAVA_PROPERTIES_DATE; private static final String JAVA_LOCALE_USE_OLD_ISO_CODES; private static final String OS_NAME; private static final String OS_ARCH; @@ -86,8 +89,11 @@ private StaticProperty() {} JDK_SERIAL_FILTER_FACTORY = getProperty(props, "jdk.serialFilterFactory", null); NATIVE_ENCODING = getProperty(props, "native.encoding"); FILE_ENCODING = getProperty(props, "file.encoding"); - JAVA_PROPERTIES_DATE = getProperty(props, "java.properties.date", null); + STDIN_ENCODING = getProperty(props, "stdin.encoding"); + STDERR_ENCODING = getProperty(props, "stderr.encoding"); + STDOUT_ENCODING = getProperty(props, "stdout.encoding"); SUN_JNU_ENCODING = getProperty(props, "sun.jnu.encoding"); + JAVA_PROPERTIES_DATE = getProperty(props, "java.properties.date", null); JAVA_LOCALE_USE_OLD_ISO_CODES = getProperty(props, "java.locale.useOldISOCodes", ""); OS_NAME = getProperty(props, "os.name"); OS_ARCH = getProperty(props, "os.arch"); @@ -218,10 +224,24 @@ public static String fileEncoding() { } /** - * {@return the {@code java.properties.date} system property} + * {@return the {@code stdin.encoding} system property} */ - public static String javaPropertiesDate() { - return JAVA_PROPERTIES_DATE; + public static String stdinEncoding() { + return STDIN_ENCODING; + } + + /** + * {@return the {@code stderr.encoding} system property} + */ + public static String stderrEncoding() { + return STDERR_ENCODING; + } + + /** + * {@return the {@code stdout.encoding} system property} + */ + public static String stdoutEncoding() { + return STDOUT_ENCODING; } /** @@ -231,6 +251,13 @@ public static String jnuEncoding() { return SUN_JNU_ENCODING; } + /** + * {@return the {@code java.properties.date} system property} + */ + public static String javaPropertiesDate() { + return JAVA_PROPERTIES_DATE; + } + /** * {@return the {@code java.locale.useOldISOCodes} system property} */ diff --git a/src/java.base/share/classes/sun/security/tools/keytool/Main.java b/src/java.base/share/classes/sun/security/tools/keytool/Main.java index 6bea35a996f17..8c6cd139a0d77 100644 --- a/src/java.base/share/classes/sun/security/tools/keytool/Main.java +++ b/src/java.base/share/classes/sun/security/tools/keytool/Main.java @@ -60,6 +60,8 @@ import javax.security.auth.x500.X500Principal; import java.util.Base64; +import jdk.internal.util.StaticProperty; + import sun.security.pkcs12.PKCS12KeyStore; import sun.security.provider.certpath.CertPathConstraintsParameters; import sun.security.util.*; @@ -3549,7 +3551,7 @@ private String inputStringFromStdin(String prompt) throws Exception { private static BufferedReader stdinAwareReader(InputStream in) { InputStreamReader reader = in == System.in - ? new InputStreamReader(in, Charset.forName(System.getProperty("stdin.encoding"), Charset.defaultCharset())) + ? new InputStreamReader(in, Charset.forName(StaticProperty.stdinEncoding(), Charset.defaultCharset())) : new InputStreamReader(in); return new BufferedReader(reader); } diff --git a/src/java.base/share/classes/sun/security/util/ConsoleCallbackHandler.java b/src/java.base/share/classes/sun/security/util/ConsoleCallbackHandler.java index 66140824bec35..725a78c39c866 100644 --- a/src/java.base/share/classes/sun/security/util/ConsoleCallbackHandler.java +++ b/src/java.base/share/classes/sun/security/util/ConsoleCallbackHandler.java @@ -25,6 +25,8 @@ package sun.security.util; +import jdk.internal.util.StaticProperty; + import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.ConfirmationCallback; @@ -131,7 +133,7 @@ public void handle(Callback[] callbacks) /* Reads a line of input */ private String readLine() throws IOException { - Charset charset = Charset.forName(System.getProperty("stdin.encoding"), Charset.defaultCharset()); + Charset charset = Charset.forName(StaticProperty.stdinEncoding(), Charset.defaultCharset()); InputStreamReader reader = new InputStreamReader(System.in, charset); String result = new BufferedReader(reader).readLine(); if (result == null) { diff --git a/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java b/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java index 2da15b8b6a6bc..ad24432f1889e 100644 --- a/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java +++ b/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,6 @@ import java.security.Provider; import jdk.internal.util.OperatingSystem; -import jdk.internal.util.StaticProperty; import org.ietf.jgss.Oid; import static sun.security.util.SecurityConstants.PROVIDER_VER; @@ -95,7 +94,7 @@ private static Oid[] getMechOIDs() { }; case WINDOWS -> new String[]{ // Full path needed, DLL is in jre/bin - StaticProperty.javaHome() + "\\bin\\sspi_bridge.dll", + System.getProperty("java.home") + "\\bin\\sspi_bridge.dll", }; case AIX -> new String[]{ "/opt/freeware/lib64/libgssapi_krb5.so", diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMathLibrary.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMathLibrary.java index 4729235e2d9b8..ecd03ab912406 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMathLibrary.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMathLibrary.java @@ -24,7 +24,6 @@ */ package jdk.incubator.vector; -import jdk.internal.util.StaticProperty; import jdk.internal.vm.annotation.DontInline; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.annotation.Stable; @@ -70,7 +69,7 @@ static Library getInstance() { } static String getDefaultName() { - return switch (StaticProperty.osArch()) { + return switch (System.getProperty("os.arch")) { case "amd64", "x86_64" -> SVML; case "aarch64", "riscv64" -> SLEEF; default -> JAVA;