Collections.enumeration() WAS Warning Cleanup Day (original) (raw)
Rémi Forax forax at univ-mlv.fr
Sat Dec 3 04:37:17 PST 2011
- Previous message: Tests (Was Warnings Cleanup in java.util. (more from hack day))
- Next message: Collections.enumeration() WAS Warning Cleanup Day
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I've started to remove warnings from java.util and I'm not able to cleanly retrofit java.util.PropertyPermission because java.util.Collections.enumeration is wrongly typed.
PropertyPermission contains a member class that define a PermissionCollection that store/load only PropertyPermissions. One method of PermissionCollection returns an Enumeration of Permission by calling Collections.enumeration. But Collections.enumeration doesn't use a wildcard.
This is the actual code of Collections.enumeration is public static Enumeration enumeration(final Collection c) { return new Enumeration() { private final Iterator i = c.iterator();
public boolean hasMoreElements() {
return i.hasNext();
}
public T nextElement() {
return i.next();
}
};
}
and should be: public static Enumeration enumeration(final Collection<? extends T> c) { final Iterator<? extends T> i = c.iterator(); return new Enumeration() { public boolean hasMoreElements() { return i.hasNext(); } public T nextElement() { return i.next(); } }; }
I believe this change is source and binary compatible because the method is static and a Collection<? extends T> is a super type of Collection.
Rémi
- Previous message: Tests (Was Warnings Cleanup in java.util. (more from hack day))
- Next message: Collections.enumeration() WAS Warning Cleanup Day
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]