]
James Perkins commented on WFCORE-4845:
---------------------------------------
I'm debating if we want to do this or not. The simple solution is to just do
{{StandaloneCommandBuilder.addJavaOption("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005")}}.
We don't, and I don't think we should, support this in the standalone scripts.
This would make the launcher API behave differently.
Allow Remote Debug Connections on Java 9+ With
StandaloneCommandBuilder
-----------------------------------------------------------------------
Key: WFCORE-4845
URL:
https://issues.redhat.com/browse/WFCORE-4845
Project: WildFly Core
Issue Type: Enhancement
Components: Launcher
Reporter: Josh Fisher
Assignee: James Perkins
Priority: Minor
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.
{code:java}
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;
}
{code}