[cp-patches] [generics] Patch: FYI: more genericization
I'm checking this in on the generics branch. This adds generics in to javax.security.auth.Subject. I think this covers everything in the japi report as of today (with a minor exception java.util; and it is a bit hard to be 100% sure as some of the things in the report have been fixed for a few days). Tom 2005-12-06 Tom Tromey <[EMAIL PROTECTED]> * javax/security/auth/Subject.java (Subject): Genericized. (getPrincipals): Likewise. (getPrivateCredentials): Likewise. (getPublicCredentials): Likewise. (getPublicCredentials): Likewise. Index: javax/security/auth/Subject.java === RCS file: /cvsroot/classpath/classpath/javax/security/auth/Subject.java,v retrieving revision 1.2.2.5 diff -u -r1.2.2.5 Subject.java --- javax/security/auth/Subject.java20 Sep 2005 18:46:30 - 1.2.2.5 +++ javax/security/auth/Subject.java7 Dec 2005 01:08:36 - @@ -91,8 +91,9 @@ readOnly = false; } - public Subject (final boolean readOnly, final Set principals, - final Set pubCred, final Set privCred) + public Subject (final boolean readOnly, + final Set principals, + final Set pubCred, final Set privCred) { if (principals == null || pubCred == null || privCred == null) { @@ -265,12 +266,12 @@ privCred.containsAll (that.getPrivateCredentials()); } - public Set getPrincipals() + public Set getPrincipals() { return principals; } - public Set getPrincipals(Class clazz) + public Set getPrincipals(Class clazz) { HashSet result = new HashSet (principals.size()); for (Iterator it = principals.iterator(); it.hasNext(); ) @@ -284,12 +285,12 @@ return Collections.unmodifiableSet (result); } - public Set getPrivateCredentials() + public Set getPrivateCredentials() { return privCred; } - public Set getPrivateCredentials (Class clazz) + public Set getPrivateCredentials (Class clazz) { HashSet result = new HashSet (privCred.size()); for (Iterator it = privCred.iterator(); it.hasNext(); ) @@ -303,12 +304,12 @@ return Collections.unmodifiableSet (result); } - public Set getPublicCredentials() + public Set getPublicCredentials() { return pubCred; } - public Set getPublicCredentials (Class clazz) + public Set getPublicCredentials (Class clazz) { HashSet result = new HashSet (pubCred.size()); for (Iterator it = pubCred.iterator(); it.hasNext(); ) ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches
[cp-patches] [generics] Patch: FYI: more genericization
I'm checking this in on the generics branch. Even more genericization that I somehow missed earlier. I really suspect japi is just feeding me methods and classes piecemeal somehow :-) This one includes some real bug fixes in javax.imageio. An earlier patch I made to ImageIO was in error, so I more fully genericized this class in order to catch bugs. I think this is the first batch of actual bugs caught by genericization -- which is nice but hardly stellar for a safety feature. Another way to look at it is that we're really great and hardly make mistakes in this area :-) The ImageIO fixes should be back-ported to the trunk. I'll try to do that. There's a bit more genericization to come, and then of course whatever japi coughs up in a couple of days. Tom 2005-12-06 Tom Tromey <[EMAIL PROTECTED]> * javax/imageio/ImageIO.java (ImageReaderIterator): Genericized. Added new constructor. (ImageWriterIterator): Likewise. (getReadersByFilter): Genericized. (getWritersByFilter): Likewise. (getImageReadersBySuffix): Likewise. (getImageWriters): Likewise. (hasNext): Likewise. * javax/print/attribute/AttributeSetUtilities.java (verifyAttributeCategory): Genericized. (verifyAttributeValue): Likewise. (verifyCategoryForValue): Likewise. * javax/print/attribute/AttributeSet.java (containsKey): Genericized. (get): Likewise. (remove): Likewise. * javax/print/attribute/Attribute.java (getCategory): Genericized. * javax/print/attribute/HashAttributeSet.java (HashAttributeSet): Genericized. (containsKey): Likewise. * javax/imageio/spi/ServiceRegistry.java (deregisterAll): Genericized. * javax/imageio/spi/IIOServiceProvider.java (onDeregistration): Genericized. (onRegistration): Likewise. * javax/imageio/metadata/IIOMetadataFormatImpl.java (getObjectClass): Genericized. (getObjectMaxValue): Likewise. (getObjectMinValue): Likewise. * javax/imageio/ImageIO.java (getImageReadersBySuffix): Genericized. (getImageWriters): Likewise. Index: javax/imageio/ImageIO.java === RCS file: /cvsroot/classpath/classpath/javax/imageio/ImageIO.java,v retrieving revision 1.4.2.8 diff -u -r1.4.2.8 ImageIO.java --- javax/imageio/ImageIO.java 1 Dec 2005 15:09:47 - 1.4.2.8 +++ javax/imageio/ImageIO.java 7 Dec 2005 00:46:23 - @@ -315,27 +315,37 @@ } } - private static final class ImageReaderIterator implements Iterator + private static final class ImageReaderIterator +implements Iterator { -Iterator it; +Iterator it; Object readerExtension; -public ImageReaderIterator(Iterator it, Object readerExtension) +public ImageReaderIterator(Iterator it, + Object readerExtension) { this.it = it; this.readerExtension = readerExtension; } + +public ImageReaderIterator(Iterator it) +{ + this.it = it; +} public boolean hasNext() { return it.hasNext(); } -public Object next() +public ImageReader next() { try { - return ((ImageReaderSpi) it.next()).createReaderInstance(readerExtension); + ImageReaderSpi spi = it.next(); + return (readerExtension == null + ? spi.createReaderInstance() + : spi.createReaderInstance(readerExtension)); } catch (IOException e) { @@ -349,27 +359,37 @@ } } - private static final class ImageWriterIterator implements Iterator + private static final class ImageWriterIterator +implements Iterator { -Iterator it; +Iterator it; Object writerExtension; -public ImageWriterIterator(Iterator it, Object writerExtension) +public ImageWriterIterator(Iterator it, + Object writerExtension) { this.it = it; this.writerExtension = writerExtension; } + +public ImageWriterIterator(Iterator it) +{ + this.it = it; +} public boolean hasNext() { return it.hasNext(); } -public Object next() +public ImageWriter next() { try { - return ((ImageWriterSpi) it.next()).createWriterInstance(writerExtension); + ImageWriterSpi spi = it.next(); + return (writerExtension == null + ? spi.createWriterInstance() + : spi.createWriterInstance(writerExtension)); } catch (IOException e) { @@ -386,13 +406,14 @@ private static File cacheDirectory; private static boolean useCache = true; - private static Iterator getReadersByFilter(Class type, - ServiceRegistry.Filter filter, -