summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2006-07-29 14:05:57 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2006-07-29 14:05:57 +0000
commit68f4e1ca39e9b3a4669d07776b0cab10177d0631 (patch)
treea9a22fe744307e1a4d140a8e47d0d8b9029ff3dc
parentc6cadc52dc947b78783d05a13fb751924425f223 (diff)
downloadclasspath-68f4e1ca39e9b3a4669d07776b0cab10177d0631.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 8bf66f8cd..4806567be 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-28 Thomas Fitzsimmons <fitzsim@redhat.com>
* native/jawt/Makefile.am (libjawt_la_LDFLAGS): Add
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 9554aae00..ed4dccd76 100644
--- a/gnu/java/lang/management/MemoryPoolMXBeanImpl.java
+++ b/gnu/java/lang/management/MemoryPoolMXBeanImpl.java
@@ -42,6 +42,8 @@ import gnu.classpath.SystemProperties;
import java.lang.management.MemoryPoolMXBean;
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
@@ -78,9 +80,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 5ce879788..6e7af0f27 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;
}
@@ -207,7 +263,16 @@ public class ManagementFactory
List poolBeans = new ArrayList();
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;
}
@@ -223,7 +288,16 @@ public class ManagementFactory
List managerBeans = new ArrayList();
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;
}
@@ -240,7 +314,17 @@ public class ManagementFactory
List gcBeans = new ArrayList();
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());
}
}