11

I can see that some methods on the jconsole are disabled.

Given below is the screenshot for com.sun.management.ThreadMXBean

jconsole screenshot

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);
Ajay George
  • 11,759
  • 1
  • 40
  • 48

1 Answers1

15

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,

Community
  • 1
  • 1
Biju Kunjummen
  • 49,138
  • 14
  • 112
  • 125
  • +1 Makes sense. Do you have a link to any official documentation mentioning the same.? – Ajay George Aug 19 '12 at 09:39
  • 1
    Did not find it in the official docs, but found it in the source code :-) - I have added an update as details. – Biju Kunjummen Aug 19 '12 at 12:45
  • I think it is just primitives, primitive wrappers and additional Classes like BigDecimal.class, BigInteger.class, Number.class, String.class, ObjectName.class. If array of primitives were allowed long[] shouldn't have an issue. – Ajay George Aug 19 '12 at 13:33
  • 1
    Yes, you are right, this looks like a complete list - primitives, primitive wrappers, array of BigDecimal, BigInteger, Number, String, ObjectName. – Biju Kunjummen Aug 19 '12 at 13:44
  • specifically array parms are out – MeBigFatGuy Aug 20 '13 at 21:32