--- old/src/share/classes/javax/print/AttributeException.java 2014-05-15 18:04:58.000000000 -0700 +++ new/src/share/classes/javax/print/AttributeException.java 2014-05-15 18:04:58.000000000 -0700 @@ -52,7 +52,7 @@ * * @return unsupported attribute classes */ - public Class[] getUnsupportedAttributes(); + public Class[] getUnsupportedAttributes(); /** * Returns the array of printing attributes for which the Print Service --- old/src/share/classes/javax/print/DocFlavor.java 2014-05-15 18:04:59.000000000 -0700 +++ new/src/share/classes/javax/print/DocFlavor.java 2014-05-15 18:04:59.000000000 -0700 @@ -545,8 +545,7 @@ * @exception NullPointerException if paramName is null. */ public String getParameter(String paramName) { - return - (String)myMimeType.getParameterMap().get(paramName.toLowerCase()); + return myMimeType.getParameterMap().get(paramName.toLowerCase()); } /** --- old/src/share/classes/javax/print/MimeType.java 2014-05-15 18:04:59.000000000 -0700 +++ new/src/share/classes/javax/print/MimeType.java 2014-05-15 18:04:59.000000000 -0700 @@ -117,18 +117,18 @@ /** * Parameter map entry. */ - private class ParameterMapEntry implements Map.Entry { + private class ParameterMapEntry implements Map.Entry { private int myIndex; public ParameterMapEntry(int theIndex) { myIndex = theIndex; } - public Object getKey(){ + public String getKey(){ return myPieces[myIndex]; } - public Object getValue(){ + public String getValue(){ return myPieces[myIndex+1]; } - public Object setValue (Object value) { + public String setValue (String value) { throw new UnsupportedOperationException(); } public boolean equals(Object o) { @@ -145,12 +145,12 @@ /** * Parameter map entry set iterator. */ - private class ParameterMapEntrySetIterator implements Iterator { + private class ParameterMapEntrySetIterator implements Iterator> { private int myIndex = 2; public boolean hasNext() { return myIndex < myPieces.length; } - public Object next() { + public Map.Entry next() { if (hasNext()) { ParameterMapEntry result = new ParameterMapEntry (myIndex); myIndex += 2; @@ -167,8 +167,8 @@ /** * Parameter map entry set. */ - private class ParameterMapEntrySet extends AbstractSet { - public Iterator iterator() { + private class ParameterMapEntrySet extends AbstractSet> { + public Iterator> iterator() { return new ParameterMapEntrySetIterator(); } public int size() { @@ -179,8 +179,8 @@ /** * Parameter map. */ - private class ParameterMap extends AbstractMap { - public Set entrySet() { + private class ParameterMap extends AbstractMap { + public Set> entrySet() { if (myEntrySet == null) { myEntrySet = new ParameterMapEntrySet(); } @@ -234,7 +234,7 @@ * * @return Parameter map for this MIME type object. */ - public Map getParameterMap() { + public Map getParameterMap() { if (myParameterMap == null) { myParameterMap = new ParameterMap(); } @@ -548,7 +548,7 @@ } LexicalAnalyzer theLexer = new LexicalAnalyzer (s); int theLexemeType; - Vector thePieces = new Vector(); + Vector thePieces = new Vector<>(); boolean mediaTypeIsText = false; boolean parameterNameIsCharset = false; @@ -623,7 +623,7 @@ // Save the pieces. Parameters are not in ascending order yet. int n = thePieces.size(); - myPieces = (String[]) thePieces.toArray (new String [n]); + myPieces = thePieces.toArray (new String [n]); // Sort the parameters into ascending order using an insertion sort. int i, j; --- old/src/share/classes/javax/print/PrintServiceLookup.java 2014-05-15 18:05:00.000000000 -0700 +++ new/src/share/classes/javax/print/PrintServiceLookup.java 2014-05-15 18:04:59.000000000 -0700 @@ -69,8 +69,8 @@ public abstract class PrintServiceLookup { static class Services { - private ArrayList listOfLookupServices = null; - private ArrayList registeredServices = null; + private ArrayList listOfLookupServices = null; + private ArrayList registeredServices = null; } private static Services getServicesForContext() { @@ -83,23 +83,23 @@ return services; } - private static ArrayList getListOfLookupServices() { + private static ArrayList getListOfLookupServices() { return getServicesForContext().listOfLookupServices; } - private static ArrayList initListOfLookupServices() { - ArrayList listOfLookupServices = new ArrayList(); + private static ArrayList initListOfLookupServices() { + ArrayList listOfLookupServices = new ArrayList<>(); getServicesForContext().listOfLookupServices = listOfLookupServices; return listOfLookupServices; } - private static ArrayList getRegisteredServices() { + private static ArrayList getRegisteredServices() { return getServicesForContext().registeredServices; } - private static ArrayList initRegisteredServices() { - ArrayList registeredServices = new ArrayList(); + private static ArrayList initRegisteredServices() { + ArrayList registeredServices = new ArrayList<>(); getServicesForContext().registeredServices = registeredServices; return registeredServices; } @@ -120,8 +120,8 @@ public static final PrintService[] lookupPrintServices(DocFlavor flavor, AttributeSet attributes) { - ArrayList list = getServices(flavor, attributes); - return (PrintService[])(list.toArray(new PrintService[list.size()])); + ArrayList list = getServices(flavor, attributes); + return list.toArray(new PrintService[list.size()]); } @@ -148,9 +148,8 @@ public static final MultiDocPrintService[] lookupMultiDocPrintServices(DocFlavor[] flavors, AttributeSet attributes) { - ArrayList list = getMultiDocServices(flavors, attributes); - return (MultiDocPrintService[]) - list.toArray(new MultiDocPrintService[list.size()]); + ArrayList list = getMultiDocServices(flavors, attributes); + return list.toArray(new MultiDocPrintService[list.size()]); } @@ -177,10 +176,10 @@ public static final PrintService lookupDefaultPrintService() { - Iterator psIterator = getAllLookupServices().iterator(); + Iterator psIterator = getAllLookupServices().iterator(); while (psIterator.hasNext()) { try { - PrintServiceLookup lus = (PrintServiceLookup)psIterator.next(); + PrintServiceLookup lus = psIterator.next(); PrintService service = lus.getDefaultPrintService(); if (service != null) { return service; @@ -208,7 +207,8 @@ */ public static boolean registerServiceProvider(PrintServiceLookup sp) { synchronized (PrintServiceLookup.class) { - Iterator psIterator = getAllLookupServices().iterator(); + Iterator psIterator = + getAllLookupServices().iterator(); while (psIterator.hasNext()) { try { Object lus = psIterator.next(); @@ -249,7 +249,7 @@ if (service instanceof StreamPrintService) { return false; } - ArrayList registeredServices = getRegisteredServices(); + ArrayList registeredServices = getRegisteredServices(); if (registeredServices == null) { registeredServices = initRegisteredServices(); } @@ -326,9 +326,9 @@ */ public abstract PrintService getDefaultPrintService(); - private static ArrayList getAllLookupServices() { + private static ArrayList getAllLookupServices() { synchronized (PrintServiceLookup.class) { - ArrayList listOfLookupServices = getListOfLookupServices(); + ArrayList listOfLookupServices = getListOfLookupServices(); if (listOfLookupServices != null) { return listOfLookupServices; } else { @@ -336,12 +336,12 @@ } try { java.security.AccessController.doPrivileged( - new java.security.PrivilegedExceptionAction() { + new java.security.PrivilegedExceptionAction() { public Object run() { Iterator iterator = ServiceLoader.load(PrintServiceLookup.class). iterator(); - ArrayList los = getListOfLookupServices(); + ArrayList los = getListOfLookupServices(); while (iterator.hasNext()) { try { los.add(iterator.next()); @@ -364,14 +364,14 @@ } } - private static ArrayList getServices(DocFlavor flavor, - AttributeSet attributes) { + private static ArrayList getServices(DocFlavor flavor, + AttributeSet attributes) { - ArrayList listOfServices = new ArrayList(); - Iterator psIterator = getAllLookupServices().iterator(); + ArrayList listOfServices = new ArrayList<>(); + Iterator psIterator = getAllLookupServices().iterator(); while (psIterator.hasNext()) { try { - PrintServiceLookup lus = (PrintServiceLookup)psIterator.next(); + PrintServiceLookup lus = psIterator.next(); PrintService[] services=null; if (flavor == null && attributes == null) { try { @@ -391,7 +391,7 @@ } } /* add any directly registered services */ - ArrayList registeredServices = null; + ArrayList registeredServices = null; try { SecurityManager security = System.getSecurityManager(); if (security != null) { @@ -401,8 +401,7 @@ } catch (SecurityException se) { } if (registeredServices != null) { - PrintService[] services = (PrintService[]) - registeredServices.toArray( + PrintService[] services = registeredServices.toArray( new PrintService[registeredServices.size()]); for (int i=0; i getMultiDocServices(DocFlavor[] flavors, + AttributeSet attributes) { - ArrayList listOfServices = new ArrayList(); - Iterator psIterator = getAllLookupServices().iterator(); + ArrayList listOfServices = new ArrayList<>(); + Iterator psIterator = getAllLookupServices().iterator(); while (psIterator.hasNext()) { try { - PrintServiceLookup lus = (PrintServiceLookup)psIterator.next(); + PrintServiceLookup lus = psIterator.next(); MultiDocPrintService[] services = lus.getMultiDocPrintServices(flavors, attributes); if (services == null) { @@ -442,7 +441,7 @@ } } /* add any directly registered services */ - ArrayList registeredServices = null; + ArrayList registeredServices = null; try { SecurityManager security = System.getSecurityManager(); if (security != null) { @@ -452,14 +451,13 @@ } catch (Exception e) { } if (registeredServices != null) { - PrintService[] services = (PrintService[]) - registeredServices.toArray( - new PrintService[registeredServices.size()]); + PrintService[] services = + registeredServices.toArray(new PrintService[registeredServices.size()]); for (int i=0; i dstCategory = Destination.class; + Class amCategory = SunAlternateMedia.class; + Class fdCategory = Fidelity.class; if (attributes.containsKey(dstCategory) && !newas.containsKey(dstCategory)) @@ -315,7 +315,7 @@ Attribute[] usAttrs = asUnsupported.toArray(); for (int i=0; i category = usAttrs[i].getCategory(); if (ps.isAttributeCategorySupported(category)) { Attribute attr = --- old/src/share/classes/javax/print/SimpleDoc.java 2014-05-15 18:05:01.000000000 -0700 +++ new/src/share/classes/javax/print/SimpleDoc.java 2014-05-15 18:05:00.000000000 -0700 @@ -89,7 +89,7 @@ throw new IllegalArgumentException("null argument(s)"); } - Class repClass = null; + Class repClass = null; try { String className = flavor.getRepresentationClassName(); sun.reflect.misc.ReflectUtil.checkPackageAccess(className); --- old/src/share/classes/javax/print/StreamPrintServiceFactory.java 2014-05-15 18:05:01.000000000 -0700 +++ new/src/share/classes/javax/print/StreamPrintServiceFactory.java 2014-05-15 18:05:01.000000000 -0700 @@ -59,7 +59,7 @@ public abstract class StreamPrintServiceFactory { static class Services { - private ArrayList listOfFactories = null; + private ArrayList listOfFactories = null; } private static Services getServices() { @@ -72,12 +72,12 @@ return services; } - private static ArrayList getListOfFactories() { + private static ArrayList getListOfFactories() { return getServices().listOfFactories; } - private static ArrayList initListOfFactories() { - ArrayList listOfFactories = new ArrayList(); + private static ArrayList initListOfFactories() { + ArrayList listOfFactories = new ArrayList<>(); getServices().listOfFactories = listOfFactories; return listOfFactories; } @@ -108,9 +108,8 @@ lookupStreamPrintServiceFactories(DocFlavor flavor, String outputMimeType) { - ArrayList list = getFactories(flavor, outputMimeType); - return (StreamPrintServiceFactory[]) - (list.toArray(new StreamPrintServiceFactory[list.size()])); + ArrayList list = getFactories(flavor, outputMimeType); + return list.toArray(new StreamPrintServiceFactory[list.size()]); } /** Queries the factory for the document format that is emitted @@ -162,10 +161,10 @@ public abstract StreamPrintService getPrintService(OutputStream out); - private static ArrayList getAllFactories() { + private static ArrayList getAllFactories() { synchronized (StreamPrintServiceFactory.class) { - ArrayList listOfFactories = getListOfFactories(); + ArrayList listOfFactories = getListOfFactories(); if (listOfFactories != null) { return listOfFactories; } else { @@ -174,12 +173,12 @@ try { java.security.AccessController.doPrivileged( - new java.security.PrivilegedExceptionAction() { + new java.security.PrivilegedExceptionAction() { public Object run() { Iterator iterator = ServiceLoader.load (StreamPrintServiceFactory.class).iterator(); - ArrayList lof = getListOfFactories(); + ArrayList lof = getListOfFactories(); while (iterator.hasNext()) { try { lof.add(iterator.next()); @@ -210,17 +209,16 @@ return false; } - private static ArrayList getFactories(DocFlavor flavor, String outType) { + private static ArrayList getFactories(DocFlavor flavor, String outType) { if (flavor == null && outType == null) { return getAllFactories(); } - ArrayList list = new ArrayList(); - Iterator iterator = getAllFactories().iterator(); + ArrayList list = new ArrayList<>(); + Iterator iterator = getAllFactories().iterator(); while (iterator.hasNext()) { - StreamPrintServiceFactory factory = - (StreamPrintServiceFactory)iterator.next(); + StreamPrintServiceFactory factory = iterator.next(); if ((outType == null || outType.equalsIgnoreCase(factory.getOutputFormat())) && (flavor == null || --- old/src/share/classes/javax/print/attribute/AttributeSetUtilities.java 2014-05-15 18:05:01.000000000 -0700 +++ new/src/share/classes/javax/print/attribute/AttributeSetUtilities.java 2014-05-15 18:05:01.000000000 -0700 @@ -523,7 +523,7 @@ public static Class verifyAttributeCategory(Object object, Class interfaceName) { - Class result = (Class) object; + Class result = (Class) object; if (interfaceName.isAssignableFrom (result)) { return result; } --- old/src/share/classes/javax/print/attribute/HashAttributeSet.java 2014-05-15 18:05:02.000000000 -0700 +++ new/src/share/classes/javax/print/attribute/HashAttributeSet.java 2014-05-15 18:05:02.000000000 -0700 @@ -48,13 +48,13 @@ * or a subinterface thereof. * @serial */ - private Class myInterface; + private Class myInterface; /* * A HashMap used by the implementation. * The serialised form doesn't include this instance variable. */ - private transient HashMap attrMap = new HashMap(); + private transient HashMap, Attribute> attrMap = new HashMap<>(); /** * Write the instance to a stream (ie serialize the object) @@ -82,7 +82,7 @@ throws ClassNotFoundException, IOException { s.defaultReadObject(); - attrMap = new HashMap(); + attrMap = new HashMap<>(); int count = s.readInt(); Attribute attr; for (int i = 0; i < count; i++) { @@ -274,10 +274,9 @@ * Attribute Attribute}. */ public Attribute get(Class category) { - return (Attribute) - attrMap.get(AttributeSetUtilities. - verifyAttributeCategory(category, - Attribute.class)); + return attrMap.get(AttributeSetUtilities. + verifyAttributeCategory(category, + Attribute.class)); } /** --- old/src/share/classes/javax/print/attribute/SetOfIntegerSyntax.java 2014-05-15 18:05:02.000000000 -0700 +++ new/src/share/classes/javax/print/attribute/SetOfIntegerSyntax.java 2014-05-15 18:05:02.000000000 -0700 @@ -112,7 +112,7 @@ private static int[][] parse(String members) { // Create vector to hold int[] elements, each element being one range // parsed out of members. - Vector theRanges = new Vector(); + Vector theRanges = new Vector<>(); // Run state machine over members. int n = (members == null ? 0 : members.length()); @@ -243,7 +243,7 @@ * Accumulate the given range (lb .. ub) into the canonical array form * into the given vector of int[] objects. */ - private static void accumulate(Vector ranges, int lb,int ub) { + private static void accumulate(Vector ranges, int lb,int ub) { // Make sure range is non-null. if (lb <= ub) { // Stick range at the back of the vector. @@ -253,10 +253,10 @@ // with the existing ranges. for (int j = ranges.size()-2; j >= 0; -- j) { // Get lower and upper bounds of the two ranges being compared. - int[] rangea = (int[]) ranges.elementAt (j); + int[] rangea = ranges.elementAt (j); int lba = rangea[0]; int uba = rangea[1]; - int[] rangeb = (int[]) ranges.elementAt (j+1); + int[] rangeb = ranges.elementAt (j+1); int lbb = rangeb[0]; int ubb = rangeb[1]; @@ -293,8 +293,8 @@ /** * Convert the given vector of int[] objects to canonical array form. */ - private static int[][] canonicalArrayForm(Vector ranges) { - return (int[][]) ranges.toArray (new int[ranges.size()][]); + private static int[][] canonicalArrayForm(Vector ranges) { + return ranges.toArray (new int[ranges.size()][]); } /** @@ -323,7 +323,7 @@ private static int[][] parse(int[][] members) { // Create vector to hold int[] elements, each element being one range // parsed out of members. - Vector ranges = new Vector(); + Vector ranges = new Vector<>(); // Process all integer groups in members. int n = (members == null ? 0 : members.length); --- old/src/share/classes/javax/print/attribute/standard/DialogTypeSelection.java 2014-05-15 18:05:03.000000000 -0700 +++ new/src/share/classes/javax/print/attribute/standard/DialogTypeSelection.java 2014-05-15 18:05:03.000000000 -0700 @@ -110,7 +110,7 @@ * @return Printing attribute class (category), an instance of class * {@link java.lang.Class java.lang.Class}. */ - public final Class getCategory() { + public final Class getCategory() { return DialogTypeSelection.class; } --- old/src/share/classes/javax/print/attribute/standard/MediaSize.java 2014-05-15 18:05:03.000000000 -0700 +++ new/src/share/classes/javax/print/attribute/standard/MediaSize.java 2014-05-15 18:05:03.000000000 -0700 @@ -56,9 +56,9 @@ private MediaSizeName mediaName; - private static HashMap mediaMap = new HashMap(100, 10); + private static HashMap mediaMap = new HashMap<>(100, 10); - private static Vector sizeVector = new Vector(100, 10); + private static Vector sizeVector = new Vector<>(100, 10); /** * Construct a new media size attribute from the given floating-point @@ -174,7 +174,7 @@ * with any size. */ public static MediaSize getMediaSizeForName(MediaSizeName media) { - return (MediaSize)mediaMap.get(media); + return mediaMap.get(media); } /** @@ -213,7 +213,7 @@ float diffy = y; for (int i=0; i < sizeVector.size() ; i++) { - MediaSize mediaSize = (MediaSize)sizeVector.elementAt(i); + MediaSize mediaSize = sizeVector.elementAt(i); dim = mediaSize.getSize(units); if (x == dim[0] && y == dim[1]) { match = mediaSize; --- old/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java 2014-05-15 18:05:04.000000000 -0700 +++ new/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java 2014-05-15 18:05:04.000000000 -0700 @@ -242,16 +242,18 @@ extends AbstractSet { private Severity mySeverity; - private Set myEntrySet; - public PrinterStateReasonSet(Severity severity, Set entrySet) { + private Set> myEntrySet; + + public PrinterStateReasonSet(Severity severity, + Set> entrySet) { mySeverity = severity; myEntrySet = entrySet; } public int size() { int result = 0; - Iterator iter = iterator(); + Iterator iter = iterator(); while (iter.hasNext()) { iter.next(); ++ result; @@ -259,19 +261,19 @@ return result; } - public Iterator iterator() { + public Iterator iterator() { return new PrinterStateReasonSetIterator(mySeverity, myEntrySet.iterator()); } } - private class PrinterStateReasonSetIterator implements Iterator { + private class PrinterStateReasonSetIterator implements Iterator { private Severity mySeverity; - private Iterator myIterator; - private Map.Entry myEntry; + private Iterator> myIterator; + private Map.Entry myEntry; public PrinterStateReasonSetIterator(Severity severity, - Iterator iterator) { + Iterator> iterator) { mySeverity = severity; myIterator = iterator; goToNext(); @@ -280,8 +282,8 @@ private void goToNext() { myEntry = null; while (myEntry == null && myIterator.hasNext()) { - myEntry = (Map.Entry) myIterator.next(); - if ((Severity) myEntry.getValue() != mySeverity) { + myEntry = myIterator.next(); + if (myEntry.getValue() != mySeverity) { myEntry = null; } } @@ -291,11 +293,11 @@ return myEntry != null; } - public Object next() { + public PrinterStateReason next() { if (myEntry == null) { throw new NoSuchElementException(); } - Object result = myEntry.getKey(); + PrinterStateReason result = myEntry.getKey(); goToNext(); return result; }