Java – why are some methods on jconsole disabled

I can see that some methods on jconsole are disabled

The following shows com sun. management. Screenshot of threadmxbean

The JavaDocs of these MBean methods do not specify anything about the accessibility section

I think this is a security function, but I can't get a specific answer

The second part of the problem is how to create a custom MBean implementation that can be selectively disabled on jconsole

The following is the system configuration:

Edit:

The disabled method can be invoked from an independent process.

MBeanServer server = ManagementFactory.getPlatformMBeanServer();
    ObjectName name = new ObjectName("java.lang","type","Threading");
    String operationName = "getThreadAllocatedBytes";
    //1 is main thread
    Object[] params = {1};
    String[] signature = new String[]{"long"};
    Object result = server.invoke(name,operationName,params,signature);
    //Result is 682760 on my machine
    System.out.println(result);

Solution

The reason is that they are milder, and they only enable – int or string. For operations with simple types Disabled operations use more complex types, such as arrays (there is no facility to use complex types, and there is no spring Attribute Editor to convert strings to complex types)

This is a related question: WebSphere 7 X. JMX,how to enable all operations in JConsole?

Update: This is based on the openjdk site http://hg.openjdk.java.net/jdk7u/jdk7u View the source code of jconsole, enable or disable the operation according to the method signature, and encapsulate it in the method – sun tools. jconsole. inspector. Utils. Iseditable (string type) The allowed types are primitive, primitive wrapper, primitive array,

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>