Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8227229

Deprecate the launcher -Xdebug/-debug flags that have not done anything since Java 6



    • Enhancement
    • Resolution: Fixed
    • P4
    • 22
    • 14
    • tools
    • 6
    • b08


      The Xdebug (and its alias -debug) launcher flag does nothing and is documented as existing "for backwards compatibility". The history is rather complex but fortunately it is summarized in JDK-6272174:

      History, to the best of my memory --

      (1) Long ago and far away

       -Xdebug used to mean use JVMDI
       -Djava.compiler=whatever was how you could specify a JIT compiler to run in the Classic VM
       -Djava.compiler=NONE was the Classic VM way of forcing interpreted execution and had to be used with -Xdebug because JVMDI ran in the interpreter

      (2) HotSpot came along

       -Djava.compiler=whatever was meaningless and ignored, but,
       -Djava.compiler=NONE presumably so that the "-Xdebug -Djava.compiler=NONE" command line worked, was made the same as -Xint

      (3) Then full-speed debugging came along

       Everybody's command line was still launching the debugee with "-Xdebug -Djava.compiler=NONE", so a horrible hack was added out of cautiousness:

       -Djava.compiler=NONE was left equal the same as -Xint, but was ignored if combined with -Xdebug *gag*

       Worse, I think this was me

      (4) Then JVM TI came along (JDK5)

       -Xdebug now meant set up the internal JVMDI emulating JVM TI environment enabling all the JVMDI events, like breakpoint.
       There wasn't a JVMDI flag anymore, so the full-speed hack (3) was changed to check for breakpoints being enabled

      (5) Then JVMDI was removed (JDK6)

       -Xdebug is now just ignored

       So, -Xdebug won't enable breakpoints.


      So Xdebug has done nothing since JDK 6, but unfortunately continues to be referred to in relation to JDWP! This occurs in our own JDWP usage information:

       > java -Xrunjdwp:help
                     Java Debugger JDWP Agent Library
        - The older -Xrunjdwp interface can still be used, but will be removed in
          a future release, for example:
              java -Xdebug -Xrunjdwp:[help]|[<option>=<value>, ...]


      This then makes its way into other web documents e.g.

      To run a regular serverless Java class Test with debugging enabled in the Oracle HotSpot JVM, you need to use the following command:

      java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y Test

      As you can see, you basically need only two JVM options: -Xdebug and -Xrunjdwp. Note that these are X-arguments, which means that they are not standardized and may not work as expected in other JVM implementations.

      The -Xdebug argument enables the debugging itself, and the -Xrunjdwp argument configures the JDWP protocol with several important parameters. [1]
      [1] https://stackify.com/java-remote-debugging/ (December 2017)

      So I propose that we officially deprecate -Xdebug/-debug in 14 so that we can remove it in 15.

      There are obviously multiple pieces to this and we need to update the JDWP usage information independent of this.


        Issue Links



              jpai Jaikiran Pai
              dholmes David Holmes
              0 Vote for this issue
              5 Start watching this issue