On Fri, 12 Dec 2025 14:54:52 GMT, Ioi Lam <[email protected]> wrote:

> The `DCmdFactory::_enabled` is always set to `true` and there doesn't seem to 
> be a reason to set it to `false`.
> 
> This PR removes this field and simplified the creation of `DCmdFactory` 
> objects.
> 
> The related `_hidden` field is also currently not used, but may be used in 
> the future when deprecating DCmds, so we leave it unchanged.
> 
> Note that now `jmm_GetDiagnosticCommandInfo()` always set `dcmdInfo::enabled` 
> to `true` to be compatible with Java code.

The Java API has "enabled" handled in 
src/jdk.management/share/classes/com/sun/management/internal/DiagnosticCommandInfo.java
(and read in 
src/jdk.management/share/classes/com/sun/management/internal/DiagnosticCommandImpl.java)

In the public API docs we do specify a Descriptor for diagnostic commands:

https://docs.oracle.com/en/java/javase/25/docs/api/jdk.management/com/sun/management/DiagnosticCommandMBean.html
dcmd.enabled    boolean True if the diagnostic command is enabled, false 
otherwise

dcmd.enabled is already not very meaningful as it's always true, but if it 
becomes truly meaningless, it needs thought on whether it stays, maybe with a 
comment that it is always true, or can be removed.

The Java api deals with remote connections, so interactions between JDK 
versions need considering.
If dcmd.enabled is not found, if a client app ever checks this Descriptor, does 
the app think it's not enabled?

Maybe it stays in the Descriptor for compatibility reasons, but can be removed 
from DiagnosticCommandInfo.

This could be a follow up issue if we aren't doing it now.

-------------

PR Review: https://git.openjdk.org/jdk/pull/28794#pullrequestreview-3572764279

Reply via email to