summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2006-07-29 16:17:03 +0000
committerMark Wielaard <mark@klomp.org>2006-07-29 16:17:03 +0000
commit46bab4f781a5a0ac0de1dfe62f5655662f228f8d (patch)
treef9371c0e9e41bbf97fe5df26ff5cb49772e8e42c
parent36fd88a9441d38f8756724539c412b4e76dbab04 (diff)
downloadclasspath-46bab4f781a5a0ac0de1dfe62f5655662f228f8d.tar.gz
2006-07-29 Andrew John Hughes <gnu_andrew@member.fsf.org>
* gnu/java/lang/management/BeanImpl.java: Extended javax.management.StandardMBean. * gnu/java/lang/management/ClassLoadingMXBeanImpl.java, * gnu/java/lang/management/CompilationMXBeanImpl.java, * gnu/java/lang/management/GarbageCollectorMXBeanImpl.java, * gnu/java/lang/management/MemoryMXBeanImpl.java, * gnu/java/lang/management/MemoryManagerMXBeanImpl.java, * gnu/java/lang/management/MemoryPoolMXBeanImpl.java, * gnu/java/lang/management/OperatingSystemMXBeanImpl.java, * gnu/java/lang/management/RuntimeMXBeanImpl.java, * gnu/java/lang/management/ThreadMXBeanImpl.java: Call the superclass with the appropriate class. * java/lang/management/ManagementFactory.java: (getOperatingSystemMXBean()): Catch exception from StandardMBean. (getRuntimeMXBean()): Likewise. (getClassLoadingMXBean()): Likewise. (getThreadMXBean()): Likewise. (getMemoryMXBean()): Likewise. (getCompilationMXBean()): Likewise. (getMemoryPoolMXBeans()): Likewise. (getMemoryManagerMXBeans()): Likewise. (getGarbageCollectorMXBeans()): Likewise. * javax/management/MBeanFeatureInfo.java: hashCode()): Fixed to check for null values.
-rw-r--r--ChangeLog28
-rw-r--r--gnu/java/lang/management/BeanImpl.java19
-rw-r--r--gnu/java/lang/management/ClassLoadingMXBeanImpl.java16
-rw-r--r--gnu/java/lang/management/CompilationMXBeanImpl.java16
-rw-r--r--gnu/java/lang/management/GarbageCollectorMXBeanImpl.java9
-rw-r--r--gnu/java/lang/management/MemoryMXBeanImpl.java12
-rw-r--r--gnu/java/lang/management/MemoryManagerMXBeanImpl.java25
-rw-r--r--gnu/java/lang/management/MemoryPoolMXBeanImpl.java8
-rw-r--r--gnu/java/lang/management/OperatingSystemMXBeanImpl.java18
-rw-r--r--gnu/java/lang/management/RuntimeMXBeanImpl.java16
-rw-r--r--gnu/java/lang/management/ThreadMXBeanImpl.java9
-rw-r--r--java/lang/management/ManagementFactory.java102
-rw-r--r--javax/management/MBeanFeatureInfo.java3
13 files changed, 268 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 95de43b5f..625e0be5d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2006-07-29 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * gnu/java/lang/management/BeanImpl.java:
+ Extended javax.management.StandardMBean.
+ * gnu/java/lang/management/ClassLoadingMXBeanImpl.java,
+ * gnu/java/lang/management/CompilationMXBeanImpl.java,
+ * gnu/java/lang/management/GarbageCollectorMXBeanImpl.java,
+ * gnu/java/lang/management/MemoryMXBeanImpl.java,
+ * gnu/java/lang/management/MemoryManagerMXBeanImpl.java,
+ * gnu/java/lang/management/MemoryPoolMXBeanImpl.java,
+ * gnu/java/lang/management/OperatingSystemMXBeanImpl.java,
+ * gnu/java/lang/management/RuntimeMXBeanImpl.java,
+ * gnu/java/lang/management/ThreadMXBeanImpl.java:
+ Call the superclass with the appropriate class.
+ * java/lang/management/ManagementFactory.java:
+ (getOperatingSystemMXBean()): Catch exception from
+ StandardMBean.
+ (getRuntimeMXBean()): Likewise.
+ (getClassLoadingMXBean()): Likewise.
+ (getThreadMXBean()): Likewise.
+ (getMemoryMXBean()): Likewise.
+ (getCompilationMXBean()): Likewise.
+ (getMemoryPoolMXBeans()): Likewise.
+ (getMemoryManagerMXBeans()): Likewise.
+ (getGarbageCollectorMXBeans()): Likewise.
+ * javax/management/MBeanFeatureInfo.java:
+ hashCode()): Fixed to check for null values.
+
2006-07-29 Matt Wringe <mwringe@redhat.com>
* gnu/java/security/Engine.java
diff --git a/gnu/java/lang/management/BeanImpl.java b/gnu/java/lang/management/BeanImpl.java
index 1845d7abc..24572a25d 100644
--- a/gnu/java/lang/management/BeanImpl.java
+++ b/gnu/java/lang/management/BeanImpl.java
@@ -39,6 +39,9 @@ package gnu.java.lang.management;
import java.lang.management.ManagementPermission;
+import javax.management.NotCompliantMBeanException;
+import javax.management.StandardMBean;
+
/**
* A common superclass for bean implementations.
*
@@ -46,7 +49,23 @@ import java.lang.management.ManagementPermission;
* @since 1.5
*/
public class BeanImpl
+ extends StandardMBean
{
+
+ /**
+ * Constructs a new <code>BeanImpl</code>.
+ *
+ * @param iface the bean interface being implemented.
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
+ */
+ protected BeanImpl(Class iface)
+ throws NotCompliantMBeanException
+ {
+ super(iface);
+ }
protected void checkMonitorPermissions()
{
diff --git a/gnu/java/lang/management/ClassLoadingMXBeanImpl.java b/gnu/java/lang/management/ClassLoadingMXBeanImpl.java
index d93ccf2c3..92e68ae76 100644
--- a/gnu/java/lang/management/ClassLoadingMXBeanImpl.java
+++ b/gnu/java/lang/management/ClassLoadingMXBeanImpl.java
@@ -39,6 +39,8 @@ package gnu.java.lang.management;
import java.lang.management.ClassLoadingMXBean;
+import javax.management.NotCompliantMBeanException;
+
/**
* Provides access to information about the class loading
* behaviour of the current invocation of the virtual
@@ -53,6 +55,20 @@ public final class ClassLoadingMXBeanImpl
implements ClassLoadingMXBean
{
+ /**
+ * Constructs a new <code>ClassLoadingMXBeanImpl</code>.
+ *
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
+ */
+ public ClassLoadingMXBeanImpl()
+ throws NotCompliantMBeanException
+ {
+ super(ClassLoadingMXBean.class);
+ }
+
public int getLoadedClassCount()
{
return VMClassLoadingMXBeanImpl.getLoadedClassCount();
diff --git a/gnu/java/lang/management/CompilationMXBeanImpl.java b/gnu/java/lang/management/CompilationMXBeanImpl.java
index 044150fae..b3ad898b5 100644
--- a/gnu/java/lang/management/CompilationMXBeanImpl.java
+++ b/gnu/java/lang/management/CompilationMXBeanImpl.java
@@ -41,6 +41,8 @@ import gnu.classpath.SystemProperties;
import java.lang.management.CompilationMXBean;
+import javax.management.NotCompliantMBeanException;
+
/**
* Provides access to information about the JIT
* compiler of the virtual machine, if one exists.
@@ -67,6 +69,20 @@ public final class CompilationMXBeanImpl
private static final String COMPILATION_TIME_SUPPORT =
"gnu.java.lang.management.CompilationTimeSupport";
+ /**
+ * Constructs a new <code>CompilationMXBeanImpl</code>.
+ *
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
+ */
+ public CompilationMXBeanImpl()
+ throws NotCompliantMBeanException
+ {
+ super(CompilationMXBean.class);
+ }
+
public String getName()
{
return SystemProperties.getProperty(COMPILER_NAME);
diff --git a/gnu/java/lang/management/GarbageCollectorMXBeanImpl.java b/gnu/java/lang/management/GarbageCollectorMXBeanImpl.java
index 19db8df1b..b752e6b86 100644
--- a/gnu/java/lang/management/GarbageCollectorMXBeanImpl.java
+++ b/gnu/java/lang/management/GarbageCollectorMXBeanImpl.java
@@ -39,6 +39,8 @@ package gnu.java.lang.management;
import java.lang.management.GarbageCollectorMXBean;
+import javax.management.NotCompliantMBeanException;
+
/**
* Provides access to information about one of the garbage
* collectors used by the current invocation of the
@@ -58,10 +60,15 @@ public final class GarbageCollectorMXBeanImpl
* Constructs a new <code>GarbageCollectorMXBeanImpl</code>.
*
* @param name the name of the garbage collector this bean represents.
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
*/
public GarbageCollectorMXBeanImpl(String name)
+ throws NotCompliantMBeanException
{
- super(name);
+ super(name, GarbageCollectorMXBean.class);
}
public long getCollectionCount()
diff --git a/gnu/java/lang/management/MemoryMXBeanImpl.java b/gnu/java/lang/management/MemoryMXBeanImpl.java
index 6890130d4..064e19a19 100644
--- a/gnu/java/lang/management/MemoryMXBeanImpl.java
+++ b/gnu/java/lang/management/MemoryMXBeanImpl.java
@@ -47,6 +47,7 @@ import java.util.List;
import javax.management.ListenerNotFoundException;
import javax.management.MBeanNotificationInfo;
+import javax.management.NotCompliantMBeanException;
import javax.management.Notification;
import javax.management.NotificationEmitter;
import javax.management.NotificationFilter;
@@ -120,9 +121,18 @@ public final class MemoryMXBeanImpl
}
}
-
+ /**
+ * Constructs a new <code>MemoryMXBeanImpl</code>.
+ *
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
+ */
public MemoryMXBeanImpl()
+ throws NotCompliantMBeanException
{
+ super(MemoryMXBean.class);
listeners = new ArrayList();
notificationCount = 0;
}
diff --git a/gnu/java/lang/management/MemoryManagerMXBeanImpl.java b/gnu/java/lang/management/MemoryManagerMXBeanImpl.java
index 2c6d4472a..5766af9cc 100644
--- a/gnu/java/lang/management/MemoryManagerMXBeanImpl.java
+++ b/gnu/java/lang/management/MemoryManagerMXBeanImpl.java
@@ -39,6 +39,8 @@ package gnu.java.lang.management;
import java.lang.management.MemoryManagerMXBean;
+import javax.management.NotCompliantMBeanException;
+
/**
* Provides access to information about one of the memory
* managers used by the current invocation of the
@@ -63,9 +65,32 @@ public class MemoryManagerMXBeanImpl
* Constructs a new <code>MemoryManagerMXBeanImpl</code>.
*
* @param name the name of the manager this bean represents.
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
*/
public MemoryManagerMXBeanImpl(String name)
+ throws NotCompliantMBeanException
+ {
+ this(name, MemoryManagerMXBean.class);
+ }
+
+ /**
+ * Constructs a new <code>MemoryManagerMXBeanImpl</code>
+ * implementing the specified bean interface.
+ *
+ * @param name the name of the manager this bean represents.
+ * @param iface the bean interface being implemented.
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
+ */
+ protected MemoryManagerMXBeanImpl(String name, Class iface)
+ throws NotCompliantMBeanException
{
+ super(iface);
this.name = name;
}
diff --git a/gnu/java/lang/management/MemoryPoolMXBeanImpl.java b/gnu/java/lang/management/MemoryPoolMXBeanImpl.java
index 457c3c529..e314ca164 100644
--- a/gnu/java/lang/management/MemoryPoolMXBeanImpl.java
+++ b/gnu/java/lang/management/MemoryPoolMXBeanImpl.java
@@ -43,6 +43,8 @@ import java.lang.management.MemoryPoolMXBean;
import java.lang.management.MemoryType;
import java.lang.management.MemoryUsage;
+import javax.management.NotCompliantMBeanException;
+
/**
* Provides access to information about one of the memory
* resources or pools used by the current invocation of the
@@ -79,9 +81,15 @@ public final class MemoryPoolMXBeanImpl
* Constructs a new <code>MemoryPoolMXBeanImpl</code>.
*
* @param name the name of the pool this bean represents.
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
*/
public MemoryPoolMXBeanImpl(String name)
+ throws NotCompliantMBeanException
{
+ super(MemoryPoolMXBean.class);
this.name = name;
}
diff --git a/gnu/java/lang/management/OperatingSystemMXBeanImpl.java b/gnu/java/lang/management/OperatingSystemMXBeanImpl.java
index 7e76c8cd1..9eefc0d9d 100644
--- a/gnu/java/lang/management/OperatingSystemMXBeanImpl.java
+++ b/gnu/java/lang/management/OperatingSystemMXBeanImpl.java
@@ -39,6 +39,8 @@ package gnu.java.lang.management;
import java.lang.management.OperatingSystemMXBean;
+import javax.management.NotCompliantMBeanException;
+
/**
* Provides access to information about the underlying operating
* system.
@@ -50,7 +52,21 @@ public final class OperatingSystemMXBeanImpl
extends BeanImpl
implements OperatingSystemMXBean
{
-
+
+ /**
+ * Constructs a new <code>OperatingSystemMXBeanImpl</code>.
+ *
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
+ */
+ public OperatingSystemMXBeanImpl()
+ throws NotCompliantMBeanException
+ {
+ super(OperatingSystemMXBean.class);
+ }
+
public String getArch()
{
return System.getProperty("os.arch");
diff --git a/gnu/java/lang/management/RuntimeMXBeanImpl.java b/gnu/java/lang/management/RuntimeMXBeanImpl.java
index 2e02cc561..e3ebd162e 100644
--- a/gnu/java/lang/management/RuntimeMXBeanImpl.java
+++ b/gnu/java/lang/management/RuntimeMXBeanImpl.java
@@ -49,6 +49,8 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
+import javax.management.NotCompliantMBeanException;
+
/**
* Provides access to information about the virtual machine.
*
@@ -69,6 +71,20 @@ public final class RuntimeMXBeanImpl
private boolean bootClassPathSupported = true;
+ /**
+ * Constructs a new <code>RuntimeMXBeanImpl</code>.
+ *
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
+ */
+ public RuntimeMXBeanImpl()
+ throws NotCompliantMBeanException
+ {
+ super(RuntimeMXBean.class);
+ }
+
public String getBootClassPath()
{
checkMonitorPermissions();
diff --git a/gnu/java/lang/management/ThreadMXBeanImpl.java b/gnu/java/lang/management/ThreadMXBeanImpl.java
index f788fd5b3..609b58da7 100644
--- a/gnu/java/lang/management/ThreadMXBeanImpl.java
+++ b/gnu/java/lang/management/ThreadMXBeanImpl.java
@@ -42,6 +42,8 @@ import gnu.classpath.SystemProperties;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
+import javax.management.NotCompliantMBeanException;
+
/**
* Provides access to information about the threads
* of the virtual machine. An instance of this bean is
@@ -96,9 +98,16 @@ public final class ThreadMXBeanImpl
* Default constructor to set up flag states. The
* VM has to specify whether time monitoring is initially
* enabled or not.
+ *
+ * @throws NotCompliantMBeanException if this class doesn't implement
+ * the interface or a method appears
+ * in the interface that doesn't comply
+ * with the naming conventions.
*/
public ThreadMXBeanImpl()
+ throws NotCompliantMBeanException
{
+ super(ThreadMXBean.class);
timeEnabled = Boolean.parseBoolean(SystemProperties.getProperty(TIME_ENABLED));
contentionEnabled = false;
}
diff --git a/java/lang/management/ManagementFactory.java b/java/lang/management/ManagementFactory.java
index 638066aad..d6727ea10 100644
--- a/java/lang/management/ManagementFactory.java
+++ b/java/lang/management/ManagementFactory.java
@@ -52,6 +52,8 @@ import gnu.java.lang.management.ThreadMXBeanImpl;
import java.util.ArrayList;
import java.util.List;
+import javax.management.NotCompliantMBeanException;
+
/**
* <p>
* Provides access to the system's management beans via a series
@@ -117,7 +119,16 @@ public class ManagementFactory
public static OperatingSystemMXBean getOperatingSystemMXBean()
{
if (osBean == null)
- osBean = new OperatingSystemMXBeanImpl();
+ try
+ {
+ osBean = new OperatingSystemMXBeanImpl();
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ throw new InternalError("The GNU implementation of the " +
+ "operating system bean is not a " +
+ "compliant management bean.");
+ }
return osBean;
}
@@ -131,7 +142,16 @@ public class ManagementFactory
public static RuntimeMXBean getRuntimeMXBean()
{
if (runtimeBean == null)
- runtimeBean = new RuntimeMXBeanImpl();
+ try
+ {
+ runtimeBean = new RuntimeMXBeanImpl();
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ throw new InternalError("The GNU implementation of the " +
+ "runtime bean is not a compliant " +
+ "management bean.");
+ }
return runtimeBean;
}
@@ -145,7 +165,16 @@ public class ManagementFactory
public static ClassLoadingMXBean getClassLoadingMXBean()
{
if (classLoadingBean == null)
- classLoadingBean = new ClassLoadingMXBeanImpl();
+ try
+ {
+ classLoadingBean = new ClassLoadingMXBeanImpl();
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ throw new InternalError("The GNU implementation of the " +
+ "class loading bean is not a " +
+ "compliant management bean.");
+ }
return classLoadingBean;
}
@@ -159,7 +188,16 @@ public class ManagementFactory
public static ThreadMXBean getThreadMXBean()
{
if (threadBean == null)
- threadBean = new ThreadMXBeanImpl();
+ try
+ {
+ threadBean = new ThreadMXBeanImpl();
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ throw new InternalError("The GNU implementation of the " +
+ "thread bean is not a compliant " +
+ "management bean.");
+ }
return threadBean;
}
@@ -173,7 +211,16 @@ public class ManagementFactory
public static MemoryMXBean getMemoryMXBean()
{
if (memoryBean == null)
- memoryBean = new MemoryMXBeanImpl();
+ try
+ {
+ memoryBean = new MemoryMXBeanImpl();
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ throw new InternalError("The GNU implementation of the " +
+ "memory bean is not a compliant " +
+ "management bean.");
+ }
return memoryBean;
}
@@ -191,7 +238,16 @@ public class ManagementFactory
{
if (compilationBean == null &&
SystemProperties.getProperty("gnu.java.compiler.name") != null)
- compilationBean = new CompilationMXBeanImpl();
+ try
+ {
+ compilationBean = new CompilationMXBeanImpl();
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ throw new InternalError("The GNU implementation of the " +
+ "compilation bean is not a compliant " +
+ "management bean.");
+ }
return compilationBean;
}
@@ -208,7 +264,16 @@ public class ManagementFactory
new ArrayList<MemoryPoolMXBean>();
String[] names = VMManagementFactory.getMemoryPoolNames();
for (int a = 0; a < names.length; ++a)
- poolBeans.add(new MemoryPoolMXBeanImpl(names[a]));
+ try
+ {
+ poolBeans.add(new MemoryPoolMXBeanImpl(names[a]));
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ throw new InternalError("The GNU implementation of the " +
+ "memory pool bean, " + a + ", is " +
+ "not a compliant management bean.");
+ }
return poolBeans;
}
@@ -225,7 +290,16 @@ public class ManagementFactory
new ArrayList<MemoryManagerMXBean>();
String[] names = VMManagementFactory.getMemoryManagerNames();
for (int a = 0; a < names.length; ++a)
- managerBeans.add(new MemoryManagerMXBeanImpl(names[a]));
+ try
+ {
+ managerBeans.add(new MemoryManagerMXBeanImpl(names[a]));
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ throw new InternalError("The GNU implementation of the " +
+ "memory manager bean, " + a + ", is " +
+ "not a compliant management bean.");
+ }
managerBeans.addAll(getGarbageCollectorMXBeans());
return managerBeans;
}
@@ -243,7 +317,17 @@ public class ManagementFactory
new ArrayList<GarbageCollectorMXBean>();
String[] names = VMManagementFactory.getGarbageCollectorNames();
for (int a = 0; a < names.length; ++a)
- gcBeans.add(new GarbageCollectorMXBeanImpl(names[a]));
+ try
+ {
+ gcBeans.add(new GarbageCollectorMXBeanImpl(names[a]));
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ throw new InternalError("The GNU implementation of the " +
+ "garbage collector bean, " + a +
+ ", is not a compliant management " +
+ "bean.");
+ }
return gcBeans;
}
diff --git a/javax/management/MBeanFeatureInfo.java b/javax/management/MBeanFeatureInfo.java
index df49ec50f..79acc7b39 100644
--- a/javax/management/MBeanFeatureInfo.java
+++ b/javax/management/MBeanFeatureInfo.java
@@ -148,7 +148,8 @@ public class MBeanFeatureInfo
*/
public int hashCode()
{
- return name.hashCode() + description.hashCode();
+ return (name == null ? -1 : name.hashCode())
+ + (description == null ? -1 : description.hashCode());
}
}