This patch fixes more issues due to the use of generics in javax.management.openmbean and javax.management.remote.rmi.
ChangeLog: 2008-06-16 Andrew John Hughes <[EMAIL PROTECTED]> * javax/management/openmbean/ArrayType.java, * javax/management/openmbean/CompositeDataSupport.java, * javax/management/openmbean/CompositeType.java, * javax/management/openmbean/OpenMBeanAttributeInfoSupport.java, * javax/management/openmbean/OpenMBeanInfoSupport.java, * javax/management/openmbean/OpenMBeanParameterInfoSupport.java, * javax/management/openmbean/SimpleType.java, * javax/management/openmbean/TabularDataSupport.java: Fix warnings due to use of generics. * javax/management/remote/rmi/RMIConnection.java: Suppress warnings due to API's use of MarshalledObject. -- 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
Index: javax/management/openmbean/ArrayType.java =================================================================== RCS file: /sources/classpath/classpath/javax/management/openmbean/ArrayType.java,v retrieving revision 1.4 diff -u -u -r1.4 ArrayType.java --- javax/management/openmbean/ArrayType.java 18 Sep 2007 21:52:35 -0000 1.4 +++ javax/management/openmbean/ArrayType.java 16 Jun 2008 03:02:59 -0000 @@ -152,7 +152,7 @@ throw new IllegalArgumentException("Dimensions must be greater " + "than or equal to 1."); if (elementType instanceof ArrayType) - return dim + ((ArrayType) elementType).getDimension(); + return dim + ((ArrayType<?>) elementType).getDimension(); return dim; } @@ -236,7 +236,7 @@ private static final OpenType<?> getElementType(OpenType<?> elemType) { if (elemType instanceof ArrayType) - return ((ArrayType) elemType).getElementOpenType(); + return ((ArrayType<?>) elemType).getElementOpenType(); return elemType; } @@ -257,7 +257,7 @@ { OpenType<?> trueElemType = getElementType(elemType); if (elemType instanceof ArrayType && - ((ArrayType) elemType).isPrimitiveArray()) + ((ArrayType<?>) elemType).isPrimitiveArray()) return getPrimitiveTypeClass((SimpleType<?>) trueElemType).getName(); return trueElemType.getClassName(); } @@ -323,7 +323,7 @@ dimension = getDimensions(elementType, dim); this.elementType = getElementType(elementType); primitiveArray = (elementType instanceof ArrayType && - ((ArrayType) elementType).isPrimitiveArray()); + ((ArrayType<?>) elementType).isPrimitiveArray()); } /** @@ -408,7 +408,7 @@ { if (!(obj instanceof ArrayType)) return false; - ArrayType atype = (ArrayType) obj; + ArrayType<?> atype = (ArrayType<?>) obj; return (atype.getDimension() == dimension && atype.getElementOpenType().equals(elementType) && atype.isPrimitiveArray() == primitiveArray); @@ -439,13 +439,14 @@ * is not in [EMAIL PROTECTED] OpenType#ALLOWED_CLASSNAMES_LIST}. * @since 1.6 */ + @SuppressWarnings("unchecked") public static <E> ArrayType<E[]> getArrayType(OpenType<E> elementType) throws OpenDataException { ArrayType<E[]> arr = (ArrayType<E[]>) cache.get(elementType); if (arr != null) return arr; - arr = new ArrayType(1, elementType); + arr = new ArrayType<E[]>(1, elementType); cache.put(elementType, arr); return arr; } @@ -484,6 +485,7 @@ * array. * @since 1.6 */ + @SuppressWarnings("unchecked") public static <T> ArrayType<T> getPrimitiveArrayType(Class<T> type) { ArrayType<T> arr = (ArrayType<T>) primCache.get(type); @@ -499,10 +501,9 @@ throw new IllegalArgumentException("The given class is " + "not an array."); } while (comType.isArray()); - String className = type.getName(); try { - arr = new ArrayType(getPrimitiveType(comType), true); + arr = new ArrayType<T>(getPrimitiveType(comType), true); } catch (OpenDataException e) { @@ -512,7 +513,7 @@ while (dim > 1) try { - arr = new ArrayType(1, arr); + arr = new ArrayType<T>(1, arr); --dim; } catch (OpenDataException e) @@ -610,12 +611,12 @@ { if (obj == null) return false; - Class objClass = obj.getClass(); + Class<?> objClass = obj.getClass(); if (!(objClass.isArray())) return false; if (elementType instanceof SimpleType) return getClassName().equals(objClass.getName()); - Class elementClass = null; + Class<?> elementClass = null; try { elementClass = Class.forName(getClassName()); Index: javax/management/openmbean/CompositeDataSupport.java =================================================================== RCS file: /sources/classpath/classpath/javax/management/openmbean/CompositeDataSupport.java,v retrieving revision 1.3 diff -u -u -r1.3 CompositeDataSupport.java --- javax/management/openmbean/CompositeDataSupport.java 6 Mar 2007 23:24:21 -0000 1.3 +++ javax/management/openmbean/CompositeDataSupport.java 16 Jun 2008 03:03:00 -0000 @@ -154,7 +154,7 @@ throw new IllegalArgumentException("The values array is null."); if (names.length != values.length) throw new IllegalArgumentException("The sizes of the arrays differ."); - Set typeKeys = type.keySet(); + Set<String> typeKeys = type.keySet(); if (typeKeys.size() != names.length) throw new OpenDataException("The number of field names does not match " + "the type description."); @@ -227,10 +227,8 @@ CompositeData data = (CompositeData) obj; if (!(data.getCompositeType().equals(compositeType))) return false; - Iterator it = contents.keySet().iterator(); - while (it.hasNext()) + for (String key : contents.keySet()) { - String key = (String) it.next(); if (!(data.containsKey(key))) return false; if (!(data.get(key).equals(contents.get(key)))) @@ -308,9 +306,8 @@ public int hashCode() { int code = compositeType.hashCode(); - Iterator it = values().iterator(); - while (it.hasNext()) - code += it.next().hashCode(); + for (Object o : contents.values()) + code += o.hashCode(); return code; } Index: javax/management/openmbean/CompositeType.java =================================================================== RCS file: /sources/classpath/classpath/javax/management/openmbean/CompositeType.java,v retrieving revision 1.3 diff -u -u -r1.3 CompositeType.java --- javax/management/openmbean/CompositeType.java 5 Mar 2007 23:19:44 -0000 1.3 +++ javax/management/openmbean/CompositeType.java 16 Jun 2008 03:03:00 -0000 @@ -118,7 +118,7 @@ || names.length != types.length) throw new IllegalArgumentException("Arrays must be non-empty " + "and of equal size."); - nameToDescription = new TreeMap(); + nameToDescription = new TreeMap<String,String>(); for (int a = 0; a < names.length; ++a) { if (names[a] == null) @@ -243,10 +243,8 @@ if (hashCode == null) { int elementTotal = 0; - Iterator it = nameToType.entrySet().iterator(); - while (it.hasNext()) + for (Map.Entry<String,OpenType<?>> entry : nameToType.entrySet()) { - Map.Entry entry = (Map.Entry) it.next(); elementTotal += (entry.getKey().hashCode() + entry.getValue().hashCode()); } Index: javax/management/openmbean/OpenMBeanAttributeInfoSupport.java =================================================================== RCS file: /sources/classpath/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java,v retrieving revision 1.2 diff -u -u -r1.2 OpenMBeanAttributeInfoSupport.java --- javax/management/openmbean/OpenMBeanAttributeInfoSupport.java 5 Mar 2007 23:19:44 -0000 1.2 +++ javax/management/openmbean/OpenMBeanAttributeInfoSupport.java 16 Jun 2008 03:03:00 -0000 @@ -77,12 +77,12 @@ /** * The minimum value of the attribute (may be <code>null</code>). */ - private Comparable<Object> minValue; + private Comparable<?> minValue; /** * The maximum value of the attribute (may be <code>null</code>). */ - private Comparable<Object> maxValue; + private Comparable<?> maxValue; /** * The hash code of this instance. @@ -203,6 +203,7 @@ * the empty string. * @throws OpenDataException if any condition in the list above is broken. */ + @SuppressWarnings("unchecked") public <T> OpenMBeanAttributeInfoSupport(String name, String desc, OpenType<T> type, boolean isReadable, boolean isWritable, boolean isIs, T defaultValue, @@ -224,23 +225,23 @@ type instanceof TabularType)) throw new OpenDataException("Default values are not applicable for " + "array or tabular types."); - if (minValue != null && maxValue != null - && minValue.compareTo(maxValue) > 0) + if (minimumValue != null && maximumValue != null + && minimumValue.compareTo((T) maximumValue) > 0) throw new OpenDataException("The minimum value is greater than the " + "maximum."); - if (minValue != null && defaultValue != null - && minValue.compareTo(defaultValue) > 0) + if (minimumValue != null && defaultValue != null + && minimumValue.compareTo(defaultValue) > 0) throw new OpenDataException("The minimum value is greater than the " + "default."); - if (defaultValue != null && maxValue != null - && maxValue.compareTo(defaultValue) < 0) + if (defaultValue != null && maximumValue != null + && maximumValue.compareTo(defaultValue) < 0) throw new OpenDataException("The default value is greater than the " + "maximum."); openType = type; this.defaultValue = defaultValue; - minValue = (Comparable<Object>) minimumValue; - maxValue = (Comparable<Object>) maximumValue; + minValue = minimumValue; + maxValue = maximumValue; } /** @@ -300,7 +301,7 @@ "array or tabular types."); if (legalValues != null && legalValues.length > 0) { - Set lv = new HashSet(legalValues.length); + Set<T> lv = new HashSet<T>(legalValues.length); for (int a = 0; a < legalValues.length; ++a) { if (legalValues[a] != null && Index: javax/management/openmbean/OpenMBeanInfoSupport.java =================================================================== RCS file: /sources/classpath/classpath/javax/management/openmbean/OpenMBeanInfoSupport.java,v retrieving revision 1.2 diff -u -u -r1.2 OpenMBeanInfoSupport.java --- javax/management/openmbean/OpenMBeanInfoSupport.java 5 Aug 2006 18:08:28 -0000 1.2 +++ javax/management/openmbean/OpenMBeanInfoSupport.java 16 Jun 2008 03:03:00 -0000 @@ -151,10 +151,10 @@ if (hashCode == null) hashCode = Integer.valueOf(getClassName().hashCode() + - new HashSet(Arrays.asList(getAttributes())).hashCode() + - new HashSet(Arrays.asList(getConstructors())).hashCode() + - new HashSet(Arrays.asList(getNotifications())).hashCode() + - new HashSet(Arrays.asList(getOperations())).hashCode()); + new HashSet<MBeanAttributeInfo>(Arrays.asList(getAttributes())).hashCode() + + new HashSet<MBeanConstructorInfo>(Arrays.asList(getConstructors())).hashCode() + + new HashSet<MBeanNotificationInfo>(Arrays.asList(getNotifications())).hashCode() + + new HashSet<MBeanOperationInfo>(Arrays.asList(getOperations())).hashCode()); return hashCode.intValue(); } Index: javax/management/openmbean/OpenMBeanParameterInfoSupport.java =================================================================== RCS file: /sources/classpath/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java,v retrieving revision 1.5 diff -u -u -r1.5 OpenMBeanParameterInfoSupport.java --- javax/management/openmbean/OpenMBeanParameterInfoSupport.java 5 Mar 2007 23:19:44 -0000 1.5 +++ javax/management/openmbean/OpenMBeanParameterInfoSupport.java 16 Jun 2008 03:03:00 -0000 @@ -78,12 +78,12 @@ /** * The minimum value of the parameter (may be <code>null</code>). */ - private Comparable<Object> minValue; + private Comparable<?> minValue; /** * The maximum value of the parameter (may be <code>null</code>). */ - private Comparable<Object> maxValue; + private Comparable<?> maxValue; /** * The hash code of this instance. @@ -190,6 +190,7 @@ * the empty string. * @throws OpenDataException if any condition in the list above is broken. */ + @SuppressWarnings("unchecked") public <T> OpenMBeanParameterInfoSupport(String name, String desc, OpenType<T> type, T defaultValue, Comparable<T> minimumValue, Comparable<T> maximumValue) @@ -209,22 +210,22 @@ type instanceof TabularType)) throw new OpenDataException("Default values are not applicable for " + "array or tabular types."); - if (minValue != null && maxValue != null - && minValue.compareTo(maxValue) > 0) + if (minimumValue != null && maximumValue != null + && minimumValue.compareTo((T) maximumValue) > 0) throw new OpenDataException("The minimum value is greater than the " + "maximum."); - if (minValue != null && defaultValue != null - && minValue.compareTo(defaultValue) > 0) + if (minimumValue != null && defaultValue != null + && minimumValue.compareTo(defaultValue) > 0) throw new OpenDataException("The minimum value is greater than the " + "default."); - if (defaultValue != null && maxValue != null - && maxValue.compareTo(defaultValue) < 0) + if (defaultValue != null && maximumValue != null + && maximumValue.compareTo(defaultValue) < 0) throw new OpenDataException("The default value is greater than the " + "maximum."); this.defaultValue = defaultValue; - minValue = (Comparable<Object>) minimumValue; - maxValue = (Comparable<Object>) maximumValue; + minValue = minimumValue; + maxValue = maximumValue; } /** @@ -279,7 +280,7 @@ "array or tabular types."); if (legalValues != null && legalValues.length > 0) { - Set lv = new HashSet(legalValues.length); + Set<T> lv = new HashSet<T>(legalValues.length); for (int a = 0; a < legalValues.length; ++a) { if (legalValues[a] != null && Index: javax/management/openmbean/SimpleType.java =================================================================== RCS file: /sources/classpath/classpath/javax/management/openmbean/SimpleType.java,v retrieving revision 1.4 diff -u -u -r1.4 SimpleType.java --- javax/management/openmbean/SimpleType.java 11 Mar 2007 22:15:45 -0000 1.4 +++ javax/management/openmbean/SimpleType.java 16 Jun 2008 03:03:01 -0000 @@ -232,7 +232,7 @@ { if (!(obj instanceof SimpleType)) return false; - SimpleType sType = (SimpleType) obj; + SimpleType<?> sType = (SimpleType<?>) obj; return sType.getClassName().equals(getClassName()); } Index: javax/management/openmbean/TabularDataSupport.java =================================================================== RCS file: /sources/classpath/classpath/javax/management/openmbean/TabularDataSupport.java,v retrieving revision 1.3 diff -u -u -r1.3 TabularDataSupport.java --- javax/management/openmbean/TabularDataSupport.java 16 Jun 2008 00:44:26 -0000 1.3 +++ javax/management/openmbean/TabularDataSupport.java 16 Jun 2008 03:03:01 -0000 @@ -163,6 +163,7 @@ * * @return a shallow clone of this [EMAIL PROTECTED] TabularDataSupport}. */ + @SuppressWarnings("unchecked") public Object clone() { TabularDataSupport clone = null; Index: javax/management/remote/rmi/RMIConnection.java =================================================================== RCS file: /sources/classpath/classpath/javax/management/remote/rmi/RMIConnection.java,v retrieving revision 1.3 diff -u -u -r1.3 RMIConnection.java --- javax/management/remote/rmi/RMIConnection.java 10 Feb 2008 23:29:09 -0000 1.3 +++ javax/management/remote/rmi/RMIConnection.java 16 Jun 2008 03:03:03 -0000 @@ -152,6 +152,7 @@ * NotificationFilter, * Object) */ + @SuppressWarnings("unchecked") void addNotificationListener(ObjectName name, ObjectName listener, MarshalledObject filter, MarshalledObject passback, Subject delegationSubject) @@ -223,6 +224,7 @@ * NotificationFilter, * Object) */ + @SuppressWarnings("unchecked") Integer[] addNotificationListeners(ObjectName[] names, MarshalledObject[] filters, Subject[] delegationSubjects) throws InstanceNotFoundException, IOException; @@ -296,6 +298,7 @@ * @throws IOException if an I/O error occurred in communicating with * the bean server. */ + @SuppressWarnings("unchecked") ObjectInstance createMBean(String className, ObjectName name, MarshalledObject params, String[] sig, Subject delegationSubject) @@ -364,6 +367,7 @@ * @throws IOException if an I/O error occurred in communicating with * the bean server. */ + @SuppressWarnings("unchecked") ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, MarshalledObject params, String[] sig, Subject delegationSubject) @@ -763,6 +767,7 @@ * the bean server. * @see DynamicMBean#invoke(String, Object[], String[]) */ + @SuppressWarnings("unchecked") Object invoke(ObjectName bean, String name, MarshalledObject params, String[] sig, Subject delegationSubject) throws InstanceNotFoundException, MBeanException, @@ -866,6 +871,7 @@ * @throws SecurityException if the client or delegated subject (if any) does * not have permission to invoke this operation. */ + @SuppressWarnings("unchecked") Set<ObjectInstance> queryMBeans(ObjectName name, MarshalledObject query, Subject delegationSubject) throws IOException; @@ -908,6 +914,7 @@ * @throws IOException if an I/O error occurred in communicating with * the bean server. */ + @SuppressWarnings("unchecked") Set<ObjectName> queryNames(ObjectName name, MarshalledObject query, Subject delegationSubject) throws IOException; @@ -953,6 +960,7 @@ * NotificationFilter, * Object) */ + @SuppressWarnings("unchecked") void removeNotificationListener(ObjectName name, ObjectName listener, MarshalledObject filter, @@ -1072,6 +1080,7 @@ * @see #getAttribute(ObjectName, String, Subject) * @see javax.management.DynamicMBean#setAttribute(Attribute) */ + @SuppressWarnings("unchecked") void setAttribute(ObjectName name, MarshalledObject attribute, Subject delegationSubject) throws InstanceNotFoundException, AttributeNotFoundException, @@ -1112,6 +1121,7 @@ * @see #getAttributes(ObjectName, String[]) * @see DynamicMBean#setAttributes(AttributeList) */ + @SuppressWarnings("unchecked") AttributeList setAttributes(ObjectName name, MarshalledObject attributes, Subject delegationSubject) throws InstanceNotFoundException, ReflectionException,