RFR: 8303485: Replacing os.name for operating system customization

Erik Joelsson erikj at openjdk.org
Thu Mar 9 15:27:08 UTC 2023


On Wed, 8 Mar 2023 22:21:08 GMT, Mandy Chung <mchung at 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/OperatingSystemProps.java.template line 39:
> 
>> 37: 
>> 38:     // Index/ordinal of the current OperatingSystem enum as substituted by the build
>> 39:     static final int TARGET_OS_ORDINAL = TARGET_OS_@@OPENJDK_TARGET_OS@@;
> 
> This represents the current OS.  What about renaming it to:
> Suggestion:
> 
>     static final int CURRENT_OS_ORDINAL = @@OS_NAME@@;

I would argue that we should keep the replacement string matching the make variable its getting the value from. It makes it easier to trace the origin of the value. 

Using the terms `CURRENT` or `TARGET` inside the java class is less clear. `TARGET` is a references to how the JDK was built while `CURRENT` is more of a reference to the current runtime. Both are correct, it's more about what mental model we want at this level.

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

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



More information about the build-dev mailing list