This correctly handles conversion of Maps and Lists
to TabularData and arrays respectively.

Changelog:

2006-12-18  Andrew John Hughes  <[EMAIL PROTECTED]>

        * gnu/java/lang/management/BeanImpl.java:
        (getAttribute(String)): Fix Map and List conversion.
        * java/lang/management/ManagementFactory.java:
        (newPlatformMXBeanProxy(MBeanServerConnection,
        String, Class<T>)): Add a comma.

-- 
Andrew :-)

Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html
public class gcj extends Freedom implements Java { ... }
Index: gnu/java/lang/management/BeanImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/lang/management/BeanImpl.java,v
retrieving revision 1.8
diff -u -3 -p -u -r1.8 BeanImpl.java
--- gnu/java/lang/management/BeanImpl.java      11 Dec 2006 01:54:39 -0000      
1.8
+++ gnu/java/lang/management/BeanImpl.java      19 Dec 2006 00:05:25 -0000
@@ -201,32 +201,36 @@ public class BeanImpl
       return ((Enum) value).name();
     Class vClass = value.getClass();
     if (vClass.isArray())
-      return value;
+      vClass = vClass.getComponentType();
     String cName = vClass.getName();
     String[] allowedTypes = OpenType.ALLOWED_CLASSNAMES;
     for (int a = 0; a < allowedTypes.length; ++a)
       if (cName.equals(allowedTypes[a]))
        return value;
-    if (value instanceof List)
-      {
-       List l = (List) value;
-       Class e = null;
-       TypeVariable[] vars = vClass.getTypeParameters();
-       for (int a = 0; a < vars.length; ++a)
-         if (vars[a].getName().equals("E"))
-           e = (Class) vars[a].getGenericDeclaration();
-       if (e == null)
-         e = Object.class;
-       Object[] array = (Object[]) Array.newInstance(e, l.size());
-       return l.toArray(array);
-      }
     OpenMBeanInfo info = (OpenMBeanInfo) getMBeanInfo();
-    OpenMBeanAttributeInfo[] attribs =
-      (OpenMBeanAttributeInfo[]) info.getAttributes();
+    MBeanAttributeInfo[] attribs =
+      (MBeanAttributeInfo[]) info.getAttributes();
     OpenType type = null;
     for (int a = 0; a < attribs.length; ++a)
-      if (attribs[a].getName().equals("attribute"))
-       type = attribs[a].getOpenType();
+      if (attribs[a].getName().equals(attribute))
+       type = ((OpenMBeanAttributeInfo) attribs[a]).getOpenType();
+    if (value instanceof List)
+      {
+       try
+         {
+           Class e =
+             Class.forName(((ArrayType) 
type).getElementOpenType().getClassName());
+           List l = (List) value;
+           Object[] array = (Object[]) Array.newInstance(e, l.size());
+           return l.toArray(array);
+         }
+       catch (ClassNotFoundException e)
+         {
+           throw (InternalError) (new InternalError("The class of the list " +
+                                                    "element type could not " +
+                                                    "be 
created").initCause(e));
+         }
+      }
     if (value instanceof Map)
       {
        TabularType ttype = (TabularType) type;
Index: java/lang/management/ManagementFactory.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/java/lang/management/ManagementFactory.java,v
retrieving revision 1.17
diff -u -3 -p -u -r1.17 ManagementFactory.java
--- java/lang/management/ManagementFactory.java 17 Dec 2006 23:47:59 -0000      
1.17
+++ java/lang/management/ManagementFactory.java 19 Dec 2006 00:05:26 -0000
@@ -629,7 +629,7 @@ public class ManagementFactory
        (mxbeanName.equals(THREAD_MXBEAN_NAME) &&
         mxbeanInterface != ThreadMXBean.class))
       throw new IllegalArgumentException("The interface, " + mxbeanInterface +
-                                        "does not match the bean, " + 
mxbeanName);
+                                        ", does not match the bean, " + 
mxbeanName);
     ObjectName bean;
     try
       {

Attachment: signature.asc
Description: Digital signature

Reply via email to