JDK-8264021 : Add --disable-registry option to jhsdb debugd
  • Type: CSR
  • Component: hotspot
  • Sub-Component: svc-agent
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 17
  • Submitted: 2021-03-23
  • Updated: 2021-04-07
  • Resolved: 2021-04-07
Related Reports
CSR :  
Relates :  
Description
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");
```
Comments
Moving to Approved.
07-04-2021

I updated description and issue subject. Also I updated GitHub PR.
07-04-2021

I was just wondering if consistency with the style of existing options might take priority. It sounds like you don't thinks so. I'm ok with that. Just wanted to clarify.
06-04-2021

Those are legacy. We can add proper aliases if we want to over time, but it is not a priority.
06-04-2021

[~mr] What about --serverid, --rmiport, --registryport, and -hostname?
06-04-2021

For consistency with other long-form options, which do not collapse words together, please rename this to `--disable-registry`.
06-04-2021