summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2006-12-11 00:10:40 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2006-12-11 00:10:40 +0000
commitfcd8917ecbf247d7028825fd399ab81d3e920a06 (patch)
treeafbccc2645ca69c90183f9305748189a3b3f9d96
parent66244ee7ec1484ed591c51642b04ff1c1814f5e7 (diff)
downloadclasspath-fcd8917ecbf247d7028825fd399ab81d3e920a06.tar.gz
2006-12-11 Andrew John Hughes <gnu_andrew@member.fsf.org>
* gnu/java/lang/management/BeanImpl.java: (translate(String)): Handle Map and List as Strings of the form "java.util.Map<K,V>" and "java.util.List<E>" * javax/management/MBeanAttributeInfo.java: (MBeanAttributeInfo(String,String,Method,Method)): Use generic parameter and return types. * javax/management/MBeanConstructorInfo.java: (MBeanConstructorInfo(String, Constructor)): Use generic parameter types. * javax/management/MBeanOperationInfo.java: (MBeanOperationInfo(String, Method)): Use generic parameter and return types.
-rw-r--r--ChangeLog16
-rw-r--r--gnu/java/lang/management/BeanImpl.java70
-rw-r--r--javax/management/MBeanAttributeInfo.java4
-rw-r--r--javax/management/MBeanConstructorInfo.java5
-rw-r--r--javax/management/MBeanOperationInfo.java7
5 files changed, 56 insertions, 46 deletions
diff --git a/ChangeLog b/ChangeLog
index 135ff8e89..cc9c42323 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2006-12-11 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * gnu/java/lang/management/BeanImpl.java:
+ (translate(String)): Handle Map and List as
+ Strings of the form "java.util.Map<K,V>" and
+ "java.util.List<E>"
+ * javax/management/MBeanAttributeInfo.java:
+ (MBeanAttributeInfo(String,String,Method,Method)):
+ Use generic parameter and return types.
+ * javax/management/MBeanConstructorInfo.java:
+ (MBeanConstructorInfo(String, Constructor)):
+ Use generic parameter types.
+ * javax/management/MBeanOperationInfo.java:
+ (MBeanOperationInfo(String, Method)):
+ Use generic parameter and return types.
+
2006-12-10 Andrew John Hughes <gnu_andrew@member.fsf.org>
* gnu/java/lang/management/BeanImpl.java:
diff --git a/gnu/java/lang/management/BeanImpl.java b/gnu/java/lang/management/BeanImpl.java
index dcd63ed75..521719ab6 100644
--- a/gnu/java/lang/management/BeanImpl.java
+++ b/gnu/java/lang/management/BeanImpl.java
@@ -425,6 +425,34 @@ public class BeanImpl
return new OpenMBeanParameterInfoSupport("TransParam",
"Translated parameter",
SimpleType.VOID);
+ if (type.startsWith("java.util.Map"))
+ {
+ int lparam = type.indexOf("<");
+ int comma = type.indexOf(",", lparam);
+ int rparam = type.indexOf(">", comma);
+ String key = type.substring(lparam + 1, comma);
+ OpenType k = translate(key).getOpenType();
+ OpenType v = translate(type.substring(comma + 1, rparam)).getOpenType();
+ CompositeType ctype = new CompositeType(Map.class.getName(), Map.class.getName(),
+ new String[] { "key", "value" },
+ new String[] { "Map key", "Map value"},
+ new OpenType[] { k, v});
+ TabularType ttype = new TabularType(key, key, ctype,
+ new String[] { "key" });
+ return new OpenMBeanParameterInfoSupport("TransParam",
+ "Translated parameter",
+ ttype);
+ }
+ if (type.startsWith("java.util.List"))
+ {
+ int lparam = type.indexOf("<");
+ int rparam = type.indexOf(">");
+ OpenType e = translate(type.substring(lparam + 1, rparam)).getOpenType();
+ return new OpenMBeanParameterInfoSupport("TransParam",
+ "Translated parameter",
+ new ArrayType(1, e)
+ );
+ }
Class c;
try
{
@@ -432,8 +460,9 @@ public class BeanImpl
}
catch (ClassNotFoundException e)
{
- throw new InternalError("The class for a type used in a management bean " +
- "could not be loaded.");
+ throw (InternalError)
+ (new InternalError("The class for a type used in a management bean " +
+ "could not be loaded.").initCause(e));
}
if (c.isEnum())
{
@@ -474,43 +503,6 @@ public class BeanImpl
{
/* Ignored; we expect this if this isn't a from(CompositeData) class */
}
- if (Map.class.isAssignableFrom(c))
- {
- OpenType k = SimpleType.VOID;
- OpenType v = SimpleType.VOID;
- /*
- TypeVariable[] vars = c.getTypeParameters();
- for (int a = 0; a < vars.length; ++a)
- {
- if (vars[a].getName().equals("K"))
- k = getTypeFromClass((Class) vars[a].getGenericDeclaration());
- if (vars[a].getName().equals("V"))
- v = getTypeFromClass((Class) vars[a].getGenericDeclaration());
- }
- */
- CompositeType ctype = new CompositeType(Map.class.getName(), Map.class.getName(),
- new String[] { "key", "value" },
- new String[] { "Map key", "Map value"},
- new OpenType[] { k, v});
- TabularType ttype = new TabularType(c.getName(), c.getName(), ctype,
- new String[] { "key" });
- return new OpenMBeanParameterInfoSupport("TransParam",
- "Translated parameter",
- ttype);
- }
- if (List.class.isAssignableFrom(c))
- {
- OpenType e = SimpleType.VOID;
- /*
- TypeVariable[] vars = c.getTypeParameters();
- if (vars.length > 0)
- e = getTypeFromClass((Class) vars[0].getGenericDeclaration());
- */
- return new OpenMBeanParameterInfoSupport("TransParam",
- "Translated parameter",
- new ArrayType(1, e)
- );
- }
if (c.isArray())
{
int depth;
diff --git a/javax/management/MBeanAttributeInfo.java b/javax/management/MBeanAttributeInfo.java
index bded7e41a..94786f9d1 100644
--- a/javax/management/MBeanAttributeInfo.java
+++ b/javax/management/MBeanAttributeInfo.java
@@ -109,13 +109,13 @@ public class MBeanAttributeInfo
"not be null.");
if (getter == null)
{
- attributeType = setter.getParameterTypes()[0].getName();
+ attributeType = setter.getGenericParameterTypes()[0].toString();
isRead = false;
is = false;
}
else
{
- attributeType = getter.getReturnType().getName();
+ attributeType = getter.getGenericReturnType().toString();
isRead = true;
is = getter.getName().startsWith("is");
}
diff --git a/javax/management/MBeanConstructorInfo.java b/javax/management/MBeanConstructorInfo.java
index 9ddd432a8..1d3186c89 100644
--- a/javax/management/MBeanConstructorInfo.java
+++ b/javax/management/MBeanConstructorInfo.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package javax.management;
import java.lang.reflect.Constructor;
+import java.lang.reflect.Type;
import java.util.Arrays;
@@ -77,11 +78,11 @@ public class MBeanConstructorInfo
public MBeanConstructorInfo(String desc, Constructor cons)
{
super(cons.getName(), desc);
- Class[] paramTypes = cons.getParameterTypes();
+ Type[] paramTypes = cons.getGenericParameterTypes();
signature = new MBeanParameterInfo[paramTypes.length];
for (int a = 0; a < paramTypes.length; ++a)
signature[a] = new MBeanParameterInfo(null,
- paramTypes[a].getName(),
+ paramTypes[a].toString(),
null);
}
diff --git a/javax/management/MBeanOperationInfo.java b/javax/management/MBeanOperationInfo.java
index 2a78d19d9..65080c160 100644
--- a/javax/management/MBeanOperationInfo.java
+++ b/javax/management/MBeanOperationInfo.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package javax.management;
import java.lang.reflect.Method;
+import java.lang.reflect.Type;
import java.util.Arrays;
@@ -113,13 +114,13 @@ public class MBeanOperationInfo
public MBeanOperationInfo(String desc, Method method)
{
super(method.getName(), desc);
- Class[] paramTypes = method.getParameterTypes();
+ Type[] paramTypes = method.getGenericParameterTypes();
signature = new MBeanParameterInfo[paramTypes.length];
for (int a = 0; a < paramTypes.length; ++a)
signature[a] = new MBeanParameterInfo(null,
- paramTypes[a].getName(),
+ paramTypes[a].toString(),
null);
- type = method.getReturnType().getName();
+ type = method.getGenericReturnType().toString();
if (method.getReturnType() == Void.TYPE)
{
if (paramTypes.length == 0)