import java.lang.management.*; import javax.management.*; /** * Simple test to demonstrate JRockit Bug on Windows and RHEL (and possibly other platforms) * * The problem only appears under JRockit and it is really a JVM bug. * The same test passes with Sun's JVM. * * java version "1.5.0_06" * Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05) * BEA JRockit(R) (build R26.4.0-63-63688-1.5.0_06-20060626-2259-win-ia32, ) * * OS/Kernel/Arch = RHEL4/U4 - Linux 2.6.9-42.0.2.ELsmp * #1 SMP Thu Aug 17 17:57:31 EDT 2006 x86_64 x86_64 x86_64 GNU/Linux * JVM = R26.4.0-63_CR284516-68626-1.5.0_06-20060926-0859-linux-x86_64 * * From jmx 1.2 spec, Chapter 2, MBean Instrumentation (pp57): * * MBeanAttributeInfo Class * "The isIs method will return true if this attribute has a boolean type * and a getter method with the is prefix (versus the get prefix); otherwise * it will return false. Note that this information is only relevant * for a standard MBean". * * Original Issue * see http://jira.jboss.com/jira/browse/JBAS-3746 */ public class TestMBeanAttributeInfo { public static void main(String args[]) throws Exception { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); ObjectName oname = new ObjectName(":name=mbeanInfoTest"); server.registerMBean(new Simple(), oname); MBeanInfo info = server.getMBeanInfo(oname); MBeanAttributeInfo attr = info.getAttributes()[0]; System.out.println( "Attribute '" + attr.getName() + "' : type=" + attr.getType() + ", isReadable=" + attr.isReadable() + ", isWriteable=" + attr.isWritable() + ", isIs=" + attr.isIs()); if (attr.isIs() == false) { System.err.println("ERROR: MBeanAttributeInfo.isIs() returns false, it should be true"); System.exit(1); } } public static class Simple implements SimpleMBean { private boolean someBoolean; public boolean isSomeBoolean() { return someBoolean; } public void setSomeBoolean(boolean someBoolean) { this.someBoolean = someBoolean; } } public interface SimpleMBean { boolean isSomeBoolean(); void setSomeBoolean(boolean someBoolean); } }