JDK-8312220 : Deprecate the launcher -Xdebug/-debug flags that have not done anything since Java 6
  • Type: CSR
  • Component: tools
  • Sub-Component: launcher
  • Priority: P4
  • Status: Finalized
  • Resolution: Unresolved
  • Fix Versions: 22
  • Submitted: 2023-07-18
  • Updated: 2023-07-19
Related Reports
CSR :  
Description
Summary
-------
`java` command's `-Xdebug` and `-debug` options will be deprecated for removal.

Problem
-------

`java` command allows the `-Xdebug` and `-debug` options to be used during launch. The `-debug` option has been an alias for the `-Xdebug` option. `-debug` isn't documented but the `-Xdebug` is and as noted in the documentation (dating as far back as Java 8), this option is only there for backward compatibility and currently does nothing https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html#BGBCIEFC

> -Xdebug
>
>    Does nothing. Provided for backward compatibility.

There are applications which currently pass this option when launching `java`. Most of these usages are of the form:

    -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005

These usages appear to be copy/pasted and are being used when launching `java` with debugging enabled. The use of `-Xdebug` and `-debug` plays no role in launching `java` in debug mode or any other functionality provided by `java`.

Solution
--------

`java` launcher will start printing a warning message if `-debug` or `-Xdebug` is passed. The warning message will state that the option is deprecated and will be removed in a future release:

    java -debug -version                                     
    Warning: -debug option is deprecated and may be removed in a future release.
    ...

similarly:

    java -Xdebug -version
    OpenJDK 64-Bit Server VM warning: Option -Xdebug was deprecated in JDK 22 and will likely be removed in a future release.
    ...

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

There are no specification changes.




Comments
This looks okay. I expect we will be able to drop the java launcher option -debug quickly. My guess is that it will take a much longer time before -Xdebug can be removed, only because it seems to be widely used (even if it has been a no-op for many releases).
19-07-2023