diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2008-06-16 19:00:16 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2008-06-16 19:00:16 +0000 |
commit | b7445c313e41c069dbb69640d23735fcee0b86c2 (patch) | |
tree | aee28b69cea01aa22abbc06bfe7784e3aa6dfbc3 /javax/management | |
parent | 0141b8455dd948ddc762c0b4b95d4c3555bcde86 (diff) | |
download | classpath-b7445c313e41c069dbb69640d23735fcee0b86c2.tar.gz |
Fix use of generics in javax.management.openmbean and javax.management.remote.rmi
ChangeLog:
2008-06-16 Andrew John Hughes <gnu_andrew@member.fsf.org>
* 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.
Diffstat (limited to 'javax/management')
9 files changed, 58 insertions, 49 deletions
diff --git a/javax/management/openmbean/ArrayType.java b/javax/management/openmbean/ArrayType.java index e6cf5261a..1a23f666f 100644 --- a/javax/management/openmbean/ArrayType.java +++ b/javax/management/openmbean/ArrayType.java @@ -152,7 +152,7 @@ public class ArrayType<T> 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 @@ public class ArrayType<T> 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 @@ public class ArrayType<T> { 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 @@ public class ArrayType<T> dimension = getDimensions(elementType, dim); this.elementType = getElementType(elementType); primitiveArray = (elementType instanceof ArrayType && - ((ArrayType) elementType).isPrimitiveArray()); + ((ArrayType<?>) elementType).isPrimitiveArray()); } /** @@ -408,7 +408,7 @@ public class ArrayType<T> { 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 @@ public class ArrayType<T> * is not in {@link 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 @@ public class ArrayType<T> * 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 @@ public class ArrayType<T> 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 @@ public class ArrayType<T> while (dim > 1) try { - arr = new ArrayType(1, arr); + arr = new ArrayType<T>(1, arr); --dim; } catch (OpenDataException e) @@ -610,12 +611,12 @@ public class ArrayType<T> { 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()); diff --git a/javax/management/openmbean/CompositeDataSupport.java b/javax/management/openmbean/CompositeDataSupport.java index d4c9d450c..6bce2672d 100644 --- a/javax/management/openmbean/CompositeDataSupport.java +++ b/javax/management/openmbean/CompositeDataSupport.java @@ -154,7 +154,7 @@ public class CompositeDataSupport 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 @@ public class CompositeDataSupport 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 class CompositeDataSupport 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; } diff --git a/javax/management/openmbean/CompositeType.java b/javax/management/openmbean/CompositeType.java index 1a213f607..3244c6457 100644 --- a/javax/management/openmbean/CompositeType.java +++ b/javax/management/openmbean/CompositeType.java @@ -118,7 +118,7 @@ public class CompositeType || 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 @@ public class CompositeType 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()); } diff --git a/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java b/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java index 22667aadf..6da2e95e6 100644 --- a/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java +++ b/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java @@ -77,12 +77,12 @@ public class OpenMBeanAttributeInfoSupport /** * 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 @@ public class OpenMBeanAttributeInfoSupport * 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 @@ public class OpenMBeanAttributeInfoSupport 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 @@ public class OpenMBeanAttributeInfoSupport "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 && diff --git a/javax/management/openmbean/OpenMBeanInfoSupport.java b/javax/management/openmbean/OpenMBeanInfoSupport.java index 5f8d55b83..d67ff76a0 100644 --- a/javax/management/openmbean/OpenMBeanInfoSupport.java +++ b/javax/management/openmbean/OpenMBeanInfoSupport.java @@ -151,10 +151,10 @@ public class OpenMBeanInfoSupport 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(); } diff --git a/javax/management/openmbean/OpenMBeanParameterInfoSupport.java b/javax/management/openmbean/OpenMBeanParameterInfoSupport.java index 7fad2a131..5f86bf4af 100644 --- a/javax/management/openmbean/OpenMBeanParameterInfoSupport.java +++ b/javax/management/openmbean/OpenMBeanParameterInfoSupport.java @@ -78,12 +78,12 @@ public class OpenMBeanParameterInfoSupport /** * 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 @@ public class OpenMBeanParameterInfoSupport * 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 @@ public class OpenMBeanParameterInfoSupport 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 @@ public class OpenMBeanParameterInfoSupport "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 && diff --git a/javax/management/openmbean/SimpleType.java b/javax/management/openmbean/SimpleType.java index fb3b1bc28..ef05e9dfe 100644 --- a/javax/management/openmbean/SimpleType.java +++ b/javax/management/openmbean/SimpleType.java @@ -232,7 +232,7 @@ public final class SimpleType<T> { if (!(obj instanceof SimpleType)) return false; - SimpleType sType = (SimpleType) obj; + SimpleType<?> sType = (SimpleType<?>) obj; return sType.getClassName().equals(getClassName()); } diff --git a/javax/management/openmbean/TabularDataSupport.java b/javax/management/openmbean/TabularDataSupport.java index 04eff1733..8557f5f24 100644 --- a/javax/management/openmbean/TabularDataSupport.java +++ b/javax/management/openmbean/TabularDataSupport.java @@ -163,6 +163,7 @@ public class TabularDataSupport * * @return a shallow clone of this {@link TabularDataSupport}. */ + @SuppressWarnings("unchecked") public Object clone() { TabularDataSupport clone = null; diff --git a/javax/management/remote/rmi/RMIConnection.java b/javax/management/remote/rmi/RMIConnection.java index 38fb544fe..430f1c7dc 100644 --- a/javax/management/remote/rmi/RMIConnection.java +++ b/javax/management/remote/rmi/RMIConnection.java @@ -152,6 +152,7 @@ public interface RMIConnection * NotificationFilter, * Object) */ + @SuppressWarnings("unchecked") void addNotificationListener(ObjectName name, ObjectName listener, MarshalledObject filter, MarshalledObject passback, Subject delegationSubject) @@ -223,6 +224,7 @@ public interface RMIConnection * NotificationFilter, * Object) */ + @SuppressWarnings("unchecked") Integer[] addNotificationListeners(ObjectName[] names, MarshalledObject[] filters, Subject[] delegationSubjects) throws InstanceNotFoundException, IOException; @@ -296,6 +298,7 @@ public interface RMIConnection * @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 @@ public interface RMIConnection * @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 @@ public interface RMIConnection * 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 @@ public interface RMIConnection * @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 @@ public interface RMIConnection * @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 @@ public interface RMIConnection * NotificationFilter, * Object) */ + @SuppressWarnings("unchecked") void removeNotificationListener(ObjectName name, ObjectName listener, MarshalledObject filter, @@ -1072,6 +1080,7 @@ public interface RMIConnection * @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 @@ public interface RMIConnection * @see #getAttributes(ObjectName, String[]) * @see DynamicMBean#setAttributes(AttributeList) */ + @SuppressWarnings("unchecked") AttributeList setAttributes(ObjectName name, MarshalledObject attributes, Subject delegationSubject) throws InstanceNotFoundException, ReflectionException, |