I can see that some methods on the jconsole are disabled.
Given below is the screenshot for com.sun.management.ThreadMXBean
The javadocs for these MBean methods do not specify anything about the accessibility part.
I think it is a security feature, but I am not able to get a concrete answer for this.
The obvious second part to this question is how to create custom MBean implementations which can be selectively disabled on the jconsole.
Given below is the system config :
JConsole version "1.7.0-b147"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)
EDIT :
The disabled methods are invokable from a stand alone 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);
Starting JConsole. The jconsole executable can be found in JDK_HOME/bin, where JDK_HOME is the directory in which the Java Development Kit (JDK) is installed. If this directory is in your system path, you can start JConsole by simply typing jconsole in a command (shell) prompt.
You can use JConsole to connect to a running Java virtual machine, and then monitor the memory usage and thread activity. You can obtain class-loading information, plus information on the JVM and the operating system.
An MBean is a managed Java object, similar to a JavaBeans component, that follows the design patterns set forth in the JMX specification. An MBean can represent a device, an application, or any resource that needs to be managed.
The reason is a little more benign, they are enabled only for operations which take in simple types - int or string. The disabled operations take in more complex types like arrays ( there is no facility to take in complex types, and nothing like say a Spring property editor which can convert a string to a complex type)
Here is a related question: Websphere 7.X. JMX, how to enable all operations in JConsole?
Update: This is based on looking at the source code for JConsole from the OpenJDK site http://hg.openjdk.java.net/jdk7u/jdk7u, the operations are enabled or disabled based on the method signature and this is encapsulated in the method - sun.tools.jconsole.inspector.Utils.isEditable(String type)
. The allowed types are primitives, primitives wrappers, array of primitives,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With