On Wed, 8 Mar 2023 23:09:06 GMT, Mandy Chung <mch...@openjdk.org> wrote:

>> Improvements to support OS specific customization for JDK internal use:
>>  - To select values and code; allowing elimination of unused code and values
>>  - Optionally evaluated by build processes, compilation, or archiving (i.e. 
>> CDS)
>>  - Simple API to replace adhoc comparisons with `os.name`
>>  - Clear and consistent use across build, runtime, and JDK modules
>>  
>> The PR includes updates within java.base to use the new API.
>
> src/java.base/share/classes/jdk/internal/misc/OperatingSystem.java line 85:
> 
>> 83:     ;
>> 84: 
>> 85:     // Cache a copy of the array for lightweight indexing
> 
> This is a reference to the Enum values array (not a copy).

The implementation of OperatingSystem.values() does a clone() of the array.
It would be risky to allow the enum to change its own members.

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

PR: https://git.openjdk.org/jdk/pull/12931

Reply via email to