Skip to content

SocketLaunchingConnectorImpl#launch emits legacy JPDA flags on modern JDKs #952

Description

@systemhalted

SocketLaunchingConnectorImpl#launch currently constructs the debuggee command line by unconditionally adding the legacy JPDA launch sequence:

   // SocketLaunchingConnectorImpl.java:204-205
   execString += " -Xdebug -Xnoagent -Djava.compiler=NONE";
   execString += " -Xrunjdwp:transport=dt_socket,address=" + address
               + ",server=n,suspend=" + (fSuspend ? "y" : "n");

On JDK 21, this produces the following warning on every debugger launch:

   OpenJDK 64-Bit Server VM warning: The java.compiler system property
   is obsolete and no longer supported, use -Xint

On JDK 23, the situation is worse: -Xnoagent is no longer recognized
and the debuggee fails to start outright with Unrecognized option: -Xnoagent. The standard JDI launching connector therefore does not
work on a current JDK.

For JDK 5 and later, the supported debug-agent form is:

   -agentlib:jdwp=transport=dt_socket,address=...,server=n,suspend=...

The other options are not needed for modern debugging:

  1. -Xdebug is a compatibility option that has been ignored on modern
    JDKs and was deprecated for removal in JDK 22.
  2. -Xnoagent has been ignored for many releases, was deprecated for
    removal in JDK 22, and is rejected outright in JDK 23.
  3. -Djava.compiler=NONE is obsolete on JDK 13+, emits the warning
    above, and no longer selects interpreted-only execution. If
    interpreted-only execution is desired, the supported option is
    -Xint.
  • The sibling launcher path StandardVMDebugger#runVMArguments
    (org.eclipse.jdt.launching/.../StandardVMDebugger.java:196-214)
    already gates the legacy options by Java version and prefers
    -agentlib:jdwp=... for Java 5 and later.

  • The PR Fix warnings during JDI tests run #511 in this repo fixed the same warning by JDK-gating the legacy emit, but only in the JDI test infrastructure
    (org.eclipse.jdt.debug.jdi.tests/.../AbstractJDITest.java).
    SocketLaunchingConnectorImpl#launch was not updated.

    Suggested fix: replace lines 204-205 with

     execString += " -agentlib:jdwp=transport=dt_socket,address=" + address
                 + ",server=n,suspend=" + (fSuspend ? "y" : "n");
    

    -agentlib:jdwp= has been supported since JDK 5, so no version gating
    is required. Alternatively, mirror StandardVMDebugger by detecting
    the target JDK version and gating the
    legacy emit accordingly.

    Reproduction

    • Editor: Emacs 30.x with dap-mode + lsp-java; JDT LS server bundle
      org.eclipse.jdt.debug 3.25.100.v20260212-0641,
      jdimodel.jar from bundle org.eclipse.jdt.debug.jdi.
    • Target JDK tested: Eclipse Temurin 21.0.11 (reproduces the warning).
      JDK 23 hard-failure mode is documented via JDK-8312072 not re-reproduced here.
    • Action: M-x dap-java-debug on a trivial Maven project with a public
      static void main(String[]).

    Captured debuggee command line:

     java -Xdebug -Xnoagent -Djava.compiler=NONE \
          -Xrunjdwp:transport=dt_socket,address=localhost:<port>,server=n,suspend=y \
          -cp <classpath> <main>
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions