Details
-
Enhancement
-
Resolution: Unresolved
-
Minor
-
None
-
None
-
None
Description
When using StandaloneCommandBuilder#setDebug method to set the debug VM argument it will use this format:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=$suspend,address=$debugPort
On Java 9+, this will only accept connections from the localhost, while in Java 8 this will accept connections from any host. It is possible to support remote connections on Java 9+ by configuring the argument in the Java options list instead of using setDebug as a workaround.
While debug connections from remote hosts are not especially common, there are some use cases where it may be desired. For consistency between Java versions, we should consider using the wildcard "*" host so the debug argument format is:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=$suspend,address=*:$debugPort
I believe one way this could be achieved is by modifying the DEBUG_FORMAT to:
DEBUG_FORMAT = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=%s,address=%s"
then in setDebug check the environment VM and format the address accordingly.
public StandaloneCommandBuilder setDebug(boolean suspend, int port) { final String address; if (environment.getJvm().isModular()){ address = "*:" + port; } else { address = String.valueOf(port); } debugArg = String.format(DEBUG_FORMAT, (suspend ? "y" : "n"), address); return this; }