On Mon, 15 Dec 2025 06:11:22 GMT, David Holmes <[email protected]> wrote:

> If we are just changing the implementation then I guess this would be okay. 
> But it seems the API for this allows for specific DCmds to be disabled (how?) 
> - or at least intended for it to be possible. As per the doc:
> 
> > When the set of diagnostic commands currently supported by the Java Virtual 
> > Machine is modified, the DiagnosticCommandMBean emits a 
> > [Notification](https://docs.oracle.com/javase/8/docs/api/javax/management/Notification.html?is-external=true)
> >  with a 
> > [type](https://docs.oracle.com/javase/8/docs/api/javax/management/Notification.html?is-external=true#getType--)
> >  of[ 
> > "jmx.mbean.info.changed"](https://docs.oracle.com/javase/8/docs/api/javax/management/MBeanInfo.html#info-changed)
> >  and a 
> > [userData](https://docs.oracle.com/javase/8/docs/api/javax/management/Notification.html?is-external=true#getUserData--)
> >  that is the new MBeanInfo.

The above paragraph is about new commands being added:


int DCmdFactory::register_DCmdFactory(DCmdFactory* factory) {
  MutexLocker ml(DCmdFactory_lock, Mutex::_no_safepoint_check_flag);
  factory->_next = _DCmdFactoryList;
  _DCmdFactoryList = factory;
  if (_send_jmx_notification && !factory->_hidden
      && (factory->_export_flags & DCmd_Source_MBean)) {
    DCmdFactory::push_jmx_notification_request();
  }
  return 0; // Actually, there's no checks for duplicates
}


Which will eventually cause 
`DiagnosticCommandImpl::createDiagnosticFrameworkNotification()` to be called 
by HotSpot to dispatch the `Notification`.

I checked older source code like JDK 8, which has a 
`DCmdFactory::set_enabled()` method but there are no callers. If there had been 
a way to disable commands dynamically, that has been lost for a very long time.

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

PR Comment: https://git.openjdk.org/jdk/pull/28794#issuecomment-3657448785

Reply via email to