--- old/src/share/classes/javax/naming/directory/BasicAttributes.java 2011-07-27 17:27:12.354949000 -0700 +++ new/src/share/classes/javax/naming/directory/BasicAttributes.java 2011-07-27 17:27:11.605874100 -0700 @@ -78,7 +78,7 @@ // If ignoreCase is true, key is aways lowercase. // If ignoreCase is false, key is stored as supplied by put(). // %%% Not declared "private" due to bug 4064984. - transient Hashtable attrs = new Hashtable(11); + transient Hashtable attrs = new Hashtable<>(11); /** * Constructs a new instance of Attributes. @@ -138,6 +138,7 @@ this.put(new BasicAttribute(attrID, val)); } + @SuppressWarnings("unchecked") public Object clone() { BasicAttributes attrset; try { @@ -145,7 +146,7 @@ } catch (CloneNotSupportedException e) { attrset = new BasicAttributes(ignoreCase); } - attrset.attrs = (Hashtable)attrs.clone(); + attrset.attrs = (Hashtable)attrs.clone(); return attrset; } @@ -158,7 +159,7 @@ } public Attribute get(String attrID) { - Attribute attr = (Attribute) attrs.get( + Attribute attr = attrs.get( ignoreCase ? attrID.toLowerCase() : attrID); return (attr); } @@ -180,12 +181,12 @@ if (ignoreCase) { id = id.toLowerCase(); } - return (Attribute)attrs.put(id, attr); + return attrs.put(id, attr); } public Attribute remove(String attrID) { String id = (ignoreCase ? attrID.toLowerCase() : attrID); - return (Attribute)attrs.remove(id); + return attrs.remove(id); } /** @@ -234,7 +235,7 @@ if (size() == target.size()) { Attribute their, mine; try { - NamingEnumeration theirs = target.getAll(); + NamingEnumeration theirs = target.getAll(); while (theirs.hasMore()) { their = (Attribute)theirs.next(); mine = get(their.getID()); @@ -268,7 +269,7 @@ public int hashCode() { int hash = (ignoreCase ? 1 : 0); try { - NamingEnumeration all = getAll(); + NamingEnumeration all = getAll(); while (all.hasMore()) { hash += all.next().hashCode(); } @@ -286,7 +287,7 @@ throws java.io.IOException { s.defaultWriteObject(); // write out the ignoreCase flag s.writeInt(attrs.size()); - Enumeration attrEnum = attrs.elements(); + Enumeration attrEnum = attrs.elements(); while (attrEnum.hasMoreElements()) { s.writeObject(attrEnum.nextElement()); } @@ -300,8 +301,8 @@ s.defaultReadObject(); // read in the ignoreCase flag int n = s.readInt(); // number of attributes attrs = (n >= 1) - ? new Hashtable(n * 2) - : new Hashtable(2); // can't have initial size of 0 (grrr...) + ? new Hashtable(n * 2) + : new Hashtable(2); // can't have initial size of 0 (grrr...) while (--n >= 0) { put((Attribute)s.readObject()); }