JDK-8305998 : remove the java.compiler system property
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.lang
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 21
  • Submitted: 2023-04-14
  • Updated: 2023-04-19
  • Resolved: 2023-04-19
Related Reports
CSR :  
Description
Summary
-------

Remove references and support for the `java.compiler` system property.

Problem
-------

`java.lang.Compiler` was an interface which was supposed to provide a common abstraction for the underlying JIT implementation. However,
given the wide variation of the underlying JIT implementations, this interface was never implemented or supported by the underlying 
JIT implementations. As such, this interface was deprecated for removal in Java 9 https://bugs.openjdk.org/browse/JDK-4285505.
Recently, this interface has now been completely removed https://bugs.openjdk.org/browse/JDK-8205129.

The `java.lang.Compiler` has a corresponding underspecified `java.compiler` system property. This is one of the system properties listed
in the API documentation of `System.getProperties()` and the description of this property states - "Name of JIT compiler to use".

Since the `java.lang.Compiler` interface was never implemented or supported by JIT implementations, there never was a specified set of values for this `java.compiler` system property. In hotspot implementation, the only exception to this were the values `NONE` and empty string. If this system property was set to a value of `NONE` or was set as empty string and if `-Xdebug` option wasn't specified while launching `java`, then the hotspot implementation would consider this as an instruction to run the application in interpreted-only mode. This would be equivalent to launching the application with the hotspot implementation specific `-Xint` option.

With the `java.lang.Compiler` interface now removed and the fact that this system property hasn't seen any practical use, removing this system property and its references would be a good idea.


Solution
--------

- Remove the system property "java.compiler".  This means removing the reference to this property from the table in `java.lang.System.getProperties()` API documentation and removing the hotspot implementation which had special treatment for the values `NONE` and empty string. 

- Change the hotspot implementation to log a warning message when it sees the use of this system property when launching `java`. We believe that removing the implementation in hotspot for `NONE` and empty string value for this property, when `-Xdebug` option isn't set, shouldn't cause major compatibility issue, because applications can regain interpreted-only mode by using the `-Xint` option instead.


Specification
-------------

    
    diff --git a/src/java.base/share/classes/java/lang/System.java b/src/java.base/share/classes/java/lang/System.java
    index f15b5861670..3fd13f89289 100644
    --- a/src/java.base/share/classes/java/lang/System.java
    +++ b/src/java.base/share/classes/java/lang/System.java
    @@ -760,8 +760,6 @@ public final class System {
          *     <td>List of paths to search when loading libraries</td></tr>
          * <tr><th scope="row">{@systemProperty java.io.tmpdir}</th>
          *     <td>Default temp file path</td></tr>
    -     * <tr><th scope="row">{@systemProperty java.compiler}</th>
    -     *     <td>Name of JIT compiler to use</td></tr>
          * <tr><th scope="row">{@systemProperty os.name}</th>
          *     <td>Operating system name</td></tr>
          * <tr><th scope="row">{@systemProperty os.arch}</th>


Launching `java` by passing  `-Djava.compiler` will generate a warning message:

    java -Djava.compiler=bar  Foo.java
    OpenJDK 64-Bit Server VM warning: The java.compiler system property is obsolete and no longer supported.


    java -Djava.compiler=NONE  Foo.java
    OpenJDK 64-Bit Server VM warning: The java.compiler system property is obsolete and no longer supported, use -Xint
Comments
Moving to Approved.
19-04-2023

Thank you everyone for the updates and reviews. I'll now move this to Finalized.
16-04-2023

Yes, I see the full error message (arguements.cpp, new line 1310). No further concerns from me.
15-04-2023

I've edited the Compatibility and Solution sections to make them a bit more crisp/cleaner. I think the CSR is okay now.
15-04-2023

Hello Iris, the warning message for `NONE` value in this CSR says: > OpenJDK 64-Bit Server VM warning: The java.compiler system property is obsolete and no longer supported, use -Xint This matches what we have in the PR https://github.com/openjdk/jdk/pull/13475
15-04-2023

FTR Hotspot never used this property to allow JIT selection, just as it never supported the java.lang.Compiler class.
15-04-2023

Minor nit: The launcher warning message for "NONE" does not match the current PR code under review. It should be truncated, similar to the example for "bar".
14-04-2023

Thank you everyone for the reviews and suggestions. I've updated the relevant sections accordingly. If there are additional changes necessary, do let me know.
14-04-2023

I think the CSR needs a bit of cleanup. The Solution section can be trimmed down to provide a summary of the changes. I agree with David on the specification section as it's looks a bit strange to patch in a patch to the HotSpot code there. In this case, the only SE specification change is that java.compiler is dropped from the list of standard system properties specified in System.geProperties. Running with -Djava.compiler set on the command line will print a warning, running with -Djava.compiler="" or "NONE" no longer disables the compiler. The compatibility is low. The only recent sighting that I've seen of -Djava.compiler= or -Djava.compiler=NONE has been in conjunction with -Xrunjdwp. This seem to date back to before full-speed debugging when it was necessary to do disable the compile. Also -Xrunjdwp pre-dates the switch to -agentlib in JDK 5 so likely CLI options copied from older documentation. As regards history, then -Djava.compiler=symcjit was one way to select the Symantec JIT with the Classic VM. I don't think I've seen the equivalent with HotSpot to select the client or server compiler as they came with -client and -server options instead.
14-04-2023

The "specification" section does not need to show the full code diff for the hotspot changes. There is no "specification" aspect to the hotspot usage, but showing how the warning is now printed would suffice. Thanks.
14-04-2023