Summary
-------
Add `--disable-registry` option to `debugd` subcommand in jhsdb to disable starting RMI registry on startup.
Problem
-------
`jhsdb debugd` exports RMI object to communicate with remote debugger client. RMI needs RMI registry, so `jhsdb debugd` will start it on startup by default.
Registry port (1099 by default) might be conflict if we have another RMI application or debugd instance. We can use `--registryport` to customize it, but we can also disable it with `sun.jvm.hotspot.rmi.startRegistry` system property. However jhsdb has not provided command line option for it - we need to set system property with `-J-D`.
Solution
--------
Add `--disable-registry` option to debugd subcommand. We can see it on help message of debugd as following:
```
$ jhsdb debugd --help
--serverid <id> A unique identifier for this debug server.
--rmiport <port> Sets the port number to which the RMI connector is bound. If not specified a random available port is used.
--registryport <port> Sets the RMI registry port. This option overrides the system property 'sun.jvm.hotspot.rmi.port'. If not specified, the system property is used. If the system property is not set, the default port 1099 is used.
--disable-registry Do not start RMI registry (use already started RMI registry)
--hostname <hostname> Sets the hostname the RMI connector is bound. The value could be a hostname or an IPv4/IPv6 address. This option overrides the system property 'java.rmi.server.hostname'. If not specified, the system property is used. If the system property is not set, a system hostname is used.
--pid <pid> To attach to and operate on the given live process.
--core <corefile> To operate on the given core file.
--exe <executable for corefile>
The --core and --exe options must be set together to give the core
file, and associated executable, to operate on. They can use
absolute or relative paths.
The --pid option can be set to operate on a live process.
--core and --pid are mutually exclusive.
Examples: jhsdb debugd --pid 1234
or jhsdb debugd --core ./core.1234 --exe ./myexe
```
Specification
-------------
```
@@ -100,6 +101,7 @@ public class SALauncher {
System.out.println(" --registryport <port> Sets the RMI registry port." +
" This option overrides the system property 'sun.jvm.hotspot.rmi.port'. If not specified," +
" the system property is used. If the system property is not set, the default port 1099 is used.");
+ System.out.println(" --disable-registry Do not start RMI registry (use already started RMI registry)");
System.out.println(" --hostname <hostname> Sets the hostname the RMI connector is bound. The value could" +
" be a hostname or an IPv4/IPv6 address. This option overrides the system property" +
" 'java.rmi.server.hostname'. If not specified, the system property is used. If the system" +
```
jhsdb can already connect to debugd which is not the default port number, but it is not described in any help message or man page. So I add it as following:
```
diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java
index 4f70fd96c66..7c60b38ad71 100644
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java
@@ -63,12 +63,12 @@ public class SALauncher {
// --pid <pid>
// --exe <exe>
// --core <core>
- // --connect [<id>@]<host>
+ // --connect [<id>@]<host>[:registryport]
System.out.println(" --pid <pid> To attach to and operate on the given live process.");
System.out.println(" --core <corefile> To operate on the given core file.");
System.out.println(" --exe <executable for corefile>");
if (canConnectToRemote) {
- System.out.println(" --connect [<id>@]<host> To connect to a remote debug server (debugd).");
+ System.out.println(" --connect [<id>@]<host>[:registryport] To connect to a remote debug server (debugd).");
}
System.out.println();
System.out.println(" The --core and --exe options must be set together to give the core");
```