eglot-java icon indicating copy to clipboard operation
eglot-java copied to clipboard

passing arguments to debugger jvm process

Open darshanime-d11 opened this issue 10 months ago • 1 comments

hi, i am using eglot-java with microsoft/java-debug, with dape as recommended. however, i need to pass additional jvm args to the child debugger process (like -Dio.netty.transport.noNative=true) how do i do that?

eglot logs:

[jsonrpc] e[09:51:31.007] <-- $/progress {"jsonrpc":"2.0","method":"$/progress","params":{"token":"fb4e3aca-9ec8-45a9-b502-f5bd155cdbf1","value":{"kind":"end","message":"Building"}}}
[stderr]  Feb 20, 2025 9:51:31 AM com.microsoft.java.debug.core.UsageDataSession recordInfo
[stderr]  INFO: launch debug info
[stderr]  Feb 20, 2025 9:51:31 AM com.microsoft.java.debug.core.adapter.handler.LaunchRequestHandler launch
[stderr]  INFO: Trying to launch Java Program with options:
[stderr]  main-class: com.dream11.synthesizer.MainApplication
[stderr]  args: 
[stderr]  module-path: 
[stderr]  module-path: 
[stderr]  nil
[stderr]  nil
[stderr]  nil
[stderr]  nil
[stderr]  class-path: <snip>...:/Users/foo/.m2/repository/ch/qos/logback/logback-classic/1.4.11/logback-classic-1.4.11.jar
[stderr]  vmArgs:  -XX:+ShowCodeDetailsInExceptionMessages
[stderr]  Feb 20, 2025 9:51:31 AM com.microsoft.java.debug.core.adapter.handler.LaunchWithDebuggingDelegate launch
[stderr]  INFO: Launching debuggee VM succeeded.
[stderr]  Feb 20, 2025 9:51:37 AM com.microsoft.java.debug.core.UsageDataSession submitUsageData
[stderr]  INFO: session usage data summary
[stderr]  Feb 20, 2025 9:51:37 AM com.microsoft.java.debug.plugin.internal.JavaDebugServer$2 run
[stderr]  INFO: Debug connection closed

darshanime-d11 avatar Feb 20 '25 04:02 darshanime-d11

I believe that you can already pass JVM arguments to the debugger with a prefix argument (e.g. customize eglot-java-debug-jvm-arg and type "C-u" before invoking the debug command). Please let me know if that works.

If my suggestion works, one future improvement would be allowing users to override defaults with a prompt instead of reading the global variable eglot-java-debug-jvm-arg.

For reference

  • https://github.com/yveszoundi/eglot-java/blob/main/eglot-java.el#L718
  • https://www.gnu.org/software/emacs/manual/html_node/elisp/Prefix-Command-Arguments.html

The same applies to running main classes, the command also support a prefix argument that allows passing JVM parameters.

yveszoundi avatar Mar 30 '25 21:03 yveszoundi