On Tue, 17 Sep 2024 14:10:07 GMT, Kevin Walls <kev...@openjdk.org> wrote:
> DiagnosticCommandImpl should only publish parameter types in a known standard > set, and use "STRING" on anything else. > e.g. We can say "FILE" in the help output for jcmd, as that's for humans, but > the MBean parameter info should contain "STRING". DiagnosticCommandMBean provides JMX/MBean access to DiagnosticCommands, aka jcmds, as operations. https://docs.oracle.com/en/java/javase/22/docs/api/jdk.management/com/sun/management/DiagnosticCommandMBean.html The range of types for operation parameters is not well specified. In "dcmd.arg.type" it is: "the name of a type recognized by the diagnostic command parser. These types are not Java types and are implementation dependent." We never clarify the range of type names an application can see via the MBean. JMC for example has a historical connection, so it just knows the implementation-specific parameter types to expect. I suggested in a jcmd change that we add a FILE parameter type, it is informative for humans and can have specific meaning internally in addition to being a String. However we find JMC does not recognise it and does not permit editing that operation parameter. It wasn't clear to me at the time that these jcmd/DCmd parameter type names were consumed by other software (i.e. not just appearing in the help, for humans). Standardising or at least ensuring the parameter type list is stable, is needed. No need to change the documentation at this stage, this can be still be implementation dependent. We can't standardise on Java or OpenType names or applications such as JMC will break significantly. But we can standardise on the core list of parameter types that we have: BOOLEAN, STRING and INT are the main types. NANOTIME tells the user they can type "6s" or "10m" and be understood (JFR commands use this) "MEMORY SIZE" tells the user they can type "32m" and be understood. (Compiler.memory and JFR commands use this) "STRING SET" is an array of Strings. JMC does handle it (Only JFR.start uses this. Maybe it doesn't need it, but separate issue...) (JULONG had been added, but was not handled by apps e.g. JMC, and replacement with INT is in progress separately, JDK-8340113.) If a DiagnosticCommand parameter has a type which is outside the standard list, it should publish it via the MBean Operation with a dcmd.arg.type of STRING to avoid confusing applications. An existing test (DcmdMBeanTest.java) finds dcmds and shows parameters, e.g. dcmd.arg.type=STRING This test can verify parameter types observed via the MBean are of the known published set. ------------- PR Comment: https://git.openjdk.org/jdk/pull/21040#issuecomment-2358039865