On Thu, 29 Apr 2021 13:39:58 GMT, Roger Riggs <rri...@openjdk.org> wrote:

>> Thanks, Joe and Iris. I agree with Iris and that's the reason I chose the 
>> description. System properties are inherently mutable. There are some 
>> "protected" ones, by that I mean a private copy is made just after 
>> initialization for VM use, which is not affected by later setProperty() 
>> calls. But I don't think this new property should be treated as such.
>
> The value of native.encoding should be a static property; that is, read once 
> at startup and later modification
> does not change the behavior of the Java runtime.
> 
> Whereas the value of native.encoding is derived from the value of native 
> variables and those native
> values do not change while Java is running, I think the behavior of the Java 
> runtime should stay the same.
> Unless it is static, the Java runtime will need to read the property every 
> time it is needed and behavior can
> change from call to call and actions in one thread can affect other threads.
> Is there a use case where the application needs to change the encoding for 
> every use in the Java runtime
> independently of the native values.
> Such an application should be explicit about its charset requirements and use 
> APIs to select them explicitly.

Ok, understandable, and having a statement to clearly say 'no effect' would be 
indeed helpful. While working on methods with a charset parameter some time 
ago, I remember reading some user discussions about unable to programmatically 
change the default encoding, a confusion mostly as the user attempted to set 
encoding, e.g. System.setProperty("file.encoding", encoding), it seems that 
"the property is set (meaning no error), but it did not have the desired 
effect". Then there was also a mention in some tutorial where file.encoding and 
sun.jnu.encoding were recognized as read-only. The problem or confusion was 
that it appeared there’s such an API and the operation was successful, but it 
really didn’t have the effect.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3777

Reply via email to