6610094: Add generic support for platform MXBeans of any type
Mandy.Chung at Sun.COM
Thu Apr 3 13:49:00 PDT 2008
Daniel Fuchs wrote:
> Hy Mandy,
> Here are my comment.
> 1) ManagementFactory.java: lines 103-106
> I am not sure I really like the idea of adding new methods
> to existing interfaces.
This statement is a clarification in the specification for M&M support
for the platform. For a platform management interface, only the JDK
vendor will implement these interfaces and thus there is no
compatibility issue. The other alternative to add new methods for
existing MXBeans is to add new MXBean interfaces in new JDK releases
which is overkilled. We considered these alternatives and decided in JDK
5 when we added the M&M API.
> 2) Logging.java: The implementation of getObjectName() is
> strange - I would have expected the ObjectName to be stored in
> a static final field.
> ObjectNames are immutable, so it is safe to have a static - you
> don't need to return a new object each time.
The MXBean interfaces can be used locally in the application in a
non-JMX context. Thus the ObjectName is lazily created when needed.
> Eamonn as recently added a public internal
> utility method to create an ObjectName from a String
> so you could probably call that to initialize your static
Eamonn also mentioned that too. Thanks.
> 3) ClassLoadingImpl.java, CompilationImpl.java, HotSpotDiagnostic.java,
> MemoryImpl.java, OperatingSystemImpl.java, RuntimeImpl.java,
> OK I see you're using another Util.newObjectName() here - but
> the ObjectName could still be a static final field in these classes.
Same reason as above.
> 4) I see that sun.management.ManagementFactory is still there.
> Shouldn't it be merged with ManagementFactoryHelper?
It was one class but it is splitted into 2 classes.
I like Eamonn's suggestion to rename sun.management.ManagementFactory to
something else so that the java.lang.management implementation is much
cleaner. However, the HotSpot VM depends on a few methods in the
sun.management.ManagementFactory class for constructing the memory pool
and managers and so we have to keep this interface contract.
> 5) I was a bit puzzled by the fact that PlatformComponent
> defines several components which contain each a
> different implementation of the same MBean (all sharing the
> same ObjectName).
> For instance if we look at OPRATING_SYSTEM, SUN_OPERATING_SYSTEM,
> SUN_UNIX_OPERATING_SYSTEM, it took me a while to understand that
> registration in getPlatformMBeanServer() worked because all these
> enum pointed towards the same MBean instance...
> Maybe some comment would have helped... ;-)
Sure. I'll add some comment.
> 6) Maybe there should be a special case in the unit test which
> should try to guess which of the *OPERATING_SYSTEM case should
> be implemented, and verify that it is indeed the
> correct implementation which is registered, and compare with
> the result of the three calls:
Good suggestion. I'll look into this.
> Best regards,
> -- daniel
> Mandy Chung wrote:
>> Please review the fix for:
>> 6610094: Add generic support for platform MXBeans of any type
>> The java.lang.management API defines the management interfaces for the
>> virtual machine. The management interface for other components in the
>> will reside in its own package. For example, the management interface
>> for the
>> logging facility is java.util.logging.LoggingMXBean.
>> There is no easy way to find out what management interfaces are
>> defined in
>> the Java platform. In addition, when a new management interface is
>> added in
>> the platform, it needs to provide a factory method to obtain the platform
>> MXBeans (e.g. java.util.logging.LogManager.getLoggerMXBean()). We
>> expect that
>> NIO and the new module system will define their management interfaces
>> in JDK7.
>> Add a new java.lang.management.PlatformManagedObject interface which
>> a method to return the object name. All existing MXBean interfaces
>> will be
>> modified to extend this interface.
>> (Note: In the interface summary, the methods count for the *MXBean
>> reflects the number of methods added resulting from extending the
>> PlatformManagedObject interface)
>> Add new methods the in java.lang.management.ManagementFactory class:
>> 1) A method to return the list of platform MXBeans that implement a given
>> management interface in the running JVM
>> 2) A method to return the list of platform MXBean proxies that
>> implement a given
>> management interface and in the given remote MBeanServerConnection
>> 3) A method to return all MXBean interfaces for monitoring and
>> managing the
>> Java platform
>> Attached webrev.zip. This webrev also contains some code clean up
>> including to throw AssertionError instead of InternalError.
More information about the serviceability-dev