[cp-patches] FYI: More JMX generic fixes

Andrew John Hughes gnu_andrew at member.fsf.org
Tue Jun 17 16:53:36 UTC 2008


This fixes StandardMBean and ObjectName.

ChangeLog:


-- 
Andrew :)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8
-------------- next part --------------
Index: javax/management/ObjectName.java
===================================================================
RCS file: /sources/classpath/classpath/javax/management/ObjectName.java,v
retrieving revision 1.18
diff -u -u -r1.18 ObjectName.java
--- javax/management/ObjectName.java	7 May 2008 00:18:19 -0000	1.18
+++ javax/management/ObjectName.java	17 Jun 2008 16:49:13 -0000
@@ -306,17 +306,14 @@
 					     "character.");
     char[] keychars = new char[] { '\n', ':', ',', '*', '?', '=' };
     char[] valchars = new char[] { '\n', ':', ',', '=' };
-    Iterator i = properties.entrySet().iterator();
-    while (i.hasNext())
+    for (Map.Entry<String,String> entry : properties.entrySet())
       {
-	Map.Entry entry = (Map.Entry) i.next();
-	String key = (String) entry.getKey();
 	for (int a = 0; a < keychars.length; ++a)
-	  if (key.indexOf(keychars[a]) != -1)
+	  if (entry.getKey().indexOf(keychars[a]) != -1)
 	    throw new MalformedObjectNameException("A key contains a '" +
 						   keychars[a] + "' " +
 						   "character.");
-	String value = (String) entry.getValue();
+	String value = entry.getValue();
 	int quote = value.indexOf('"');
 	if (quote == 0)
 	  {
@@ -389,15 +386,13 @@
 
     if (isPropertyPattern())
       {
-	Hashtable oProps = name.getKeyPropertyList();
-	Iterator i = properties.entrySet().iterator();
-	while (i.hasNext())
+	Hashtable<String,String> oProps = name.getKeyPropertyList();
+	for (Map.Entry<String,String> entry : properties.entrySet())
 	  {
-	    Map.Entry entry = (Map.Entry) i.next();
-	    String key = (String) entry.getKey();
+	    String key = entry.getKey();
 	    if (!(oProps.containsKey(key)))
 	      return false;
-	    String val = (String) entry.getValue();
+	    String val = entry.getValue();
 	    if (!(val.equals(oProps.get(key))))
 	      return false;
 	  }
@@ -479,10 +474,10 @@
   public String getCanonicalKeyPropertyListString()
   {
     CPStringBuilder builder = new CPStringBuilder();
-    Iterator i = properties.entrySet().iterator();
+    Iterator<Map.Entry<String,String>> i = properties.entrySet().iterator();
     while (i.hasNext())
       {
-	Map.Entry entry = (Map.Entry) i.next();
+	Map.Entry<String,String> entry = i.next();
 	builder.append(entry.getKey() + "=" + entry.getValue());
 	if (i.hasNext())
 	  builder.append(",");
Index: javax/management/StandardMBean.java
===================================================================
RCS file: /sources/classpath/classpath/javax/management/StandardMBean.java,v
retrieving revision 1.11
diff -u -u -r1.11 StandardMBean.java
--- javax/management/StandardMBean.java	1 Nov 2007 20:06:57 -0000	1.11
+++ javax/management/StandardMBean.java	17 Jun 2008 16:49:14 -0000
@@ -569,8 +569,8 @@
     if (info != null)
       return info;
     Method[] methods = iface.getMethods();
-    Map attributes = new HashMap();
-    List operations = new ArrayList();
+    Map<String,Method[]> attributes = new HashMap<String,Method[]>();
+    List<MBeanOperationInfo> operations = new ArrayList<MBeanOperationInfo>();
     for (int a = 0; a < methods.length; ++a)
       {
 	String name = methods[a].getName();
@@ -614,16 +614,14 @@
 	  operations.add(new MBeanOperationInfo(methods[a].getName(),
 						methods[a]));
       }
-    List attribs = new ArrayList(attributes.size());
-    Iterator it = attributes.entrySet().iterator();
-    while (it.hasNext())
+    List<MBeanAttributeInfo> attribs = new ArrayList<MBeanAttributeInfo>(attributes.size());
+    for (Map.Entry<String,Method[]> entry : attributes.entrySet())
       {
-	Map.Entry entry = (Map.Entry) it.next();
-	Method[] amethods = (Method[]) entry.getValue();
+	Method[] amethods = entry.getValue();
 	try
 	  {
-	    attribs.add(new MBeanAttributeInfo((String) entry.getKey(),
-					       (String) entry.getKey(),
+	    attribs.add(new MBeanAttributeInfo(entry.getKey(),
+					       entry.getKey(),
 					       amethods[0], amethods[1]));
 	  }
 	catch (IntrospectionException e)
@@ -646,7 +644,7 @@
 					  oldInfo.isWritable(),
 					  oldInfo.isIs());
       }
-    Constructor[] cons = impl.getClass().getConstructors();
+    Constructor<?>[] cons = impl.getClass().getConstructors();
     MBeanConstructorInfo[] cinfo = new MBeanConstructorInfo[cons.length];
     for (int a = 0; a < cinfo.length; ++a)
       {
@@ -778,10 +776,10 @@
 				    "Invocation of an attribute " +
 				    "method is disallowed.");
     ClassLoader loader = getClass().getClassLoader();
-    Class[] sigTypes;
+    Class<?>[] sigTypes;
     if (signature != null)
       {
-	sigTypes = new Class[signature.length];
+	sigTypes = new Class<?>[signature.length];
 	for (int a = 0; a < signature.length; ++a)
 	  try 
 	    {
@@ -892,7 +890,7 @@
   public AttributeList setAttributes(AttributeList attributes)
   {
     AttributeList list = new AttributeList(attributes.size());
-    Iterator it = attributes.iterator();
+    Iterator<Object> it = attributes.iterator();
     while (it.hasNext())
       {
 	try


More information about the Classpath-patches mailing list