summaryrefslogtreecommitdiff
path: root/gnu/javax
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2007-12-02 01:11:02 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2007-12-02 01:11:02 +0000
commit6432910e197f757b8dbe74734afb193a9957d348 (patch)
tree8eab43340c9087a0d4205766732ac5a07920076c /gnu/javax
parent6114a9a08247cb043e1239f6ac8f690a666a5f41 (diff)
downloadclasspath-6432910e197f757b8dbe74734afb193a9957d348.tar.gz
2007-12-02 Andrew John Hughes <gnu_andrew@member.fsf.org>
PR classpath/34276: * gnu/javax/management/Translator.java: (translate(String)): Select only public methods from a composite type, try this translation in all cases and exit only when no fields are translated.
Diffstat (limited to 'gnu/javax')
-rw-r--r--gnu/javax/management/Translator.java58
1 files changed, 30 insertions, 28 deletions
diff --git a/gnu/javax/management/Translator.java b/gnu/javax/management/Translator.java
index 69191d43f..4b1d2c42f 100644
--- a/gnu/javax/management/Translator.java
+++ b/gnu/javax/management/Translator.java
@@ -39,6 +39,7 @@ package gnu.javax.management;
import java.lang.reflect.Array;
import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy;
import java.lang.reflect.Type;
@@ -440,33 +441,6 @@ public final class Translator
SimpleType.STRING,
null, names);
}
- try
- {
- c.getMethod("from", new Class[] { CompositeData.class });
- Method[] methods = c.getDeclaredMethods();
- List<String> names = new ArrayList<String>();
- List<OpenType> types = new ArrayList<OpenType>();
- for (int a = 0; a < methods.length; ++a)
- {
- String name = methods[a].getName();
- if (name.startsWith("get"))
- {
- names.add(name.substring(3));
- types.add(getTypeFromClass(methods[a].getReturnType()));
- }
- }
- String[] fields = names.toArray(new String[names.size()]);
- CompositeType ctype = new CompositeType(c.getName(), c.getName(),
- fields, fields,
- types.toArray(new OpenType[types.size()]));
- return new OpenMBeanParameterInfoSupport("TransParam",
- "Translated parameter",
- ctype);
- }
- catch (NoSuchMethodException e)
- {
- /* Ignored; we expect this if this isn't a from(CompositeData) class */
- }
if (c.isArray())
{
int depth;
@@ -478,7 +452,35 @@ public final class Translator
new ArrayType(depth, ot)
);
}
- throw new InternalError("The type used does not have an open type translation.");
+ Method[] methods = c.getDeclaredMethods();
+ List<String> names = new ArrayList<String>();
+ List<OpenType> types = new ArrayList<OpenType>();
+ for (int a = 0; a < methods.length; ++a)
+ {
+ String name = methods[a].getName();
+ if (Modifier.isPublic(methods[a].getModifiers()))
+ {
+ if (name.startsWith("get"))
+ {
+ names.add(name.substring(3));
+ types.add(getTypeFromClass(methods[a].getReturnType()));
+ }
+ else if (name.startsWith("is"))
+ {
+ names.add(name.substring(2));
+ types.add(getTypeFromClass(methods[a].getReturnType()));
+ }
+ }
+ }
+ if (names.isEmpty())
+ throw new OpenDataException("The type used does not have an open type translation.");
+ String[] fields = names.toArray(new String[names.size()]);
+ CompositeType ctype = new CompositeType(c.getName(), c.getName(),
+ fields, fields,
+ types.toArray(new OpenType[types.size()]));
+ return new OpenMBeanParameterInfoSupport("TransParam",
+ "Translated parameter",
+ ctype);
}
/**