--- old/src/share/classes/sun/print/CustomMediaSizeName.java 2014-06-08 21:27:53.000000000 -0700 +++ new/src/share/classes/sun/print/CustomMediaSizeName.java 2014-06-08 21:27:52.000000000 -0700 @@ -33,8 +33,8 @@ import java.util.ArrayList; class CustomMediaSizeName extends MediaSizeName { - private static ArrayList customStringTable = new ArrayList(); - private static ArrayList customEnumTable = new ArrayList(); + private static ArrayList customStringTable = new ArrayList<>(); + private static ArrayList customEnumTable = new ArrayList<>(); private String choiceName; private MediaSizeName mediaName; @@ -162,7 +162,7 @@ */ protected String[] getStringTable() { String[] nameTable = new String[customStringTable.size()]; - return (String[])customStringTable.toArray(nameTable); + return customStringTable.toArray(nameTable); } /** @@ -170,7 +170,7 @@ */ protected EnumSyntax[] getEnumValueTable() { MediaSizeName[] enumTable = new MediaSizeName[customEnumTable.size()]; - return (MediaSizeName[])customEnumTable.toArray(enumTable); + return customEnumTable.toArray(enumTable); } } --- old/src/share/classes/sun/print/CustomMediaTray.java 2014-06-08 21:27:53.000000000 -0700 +++ new/src/share/classes/sun/print/CustomMediaTray.java 2014-06-08 21:27:53.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,8 +31,8 @@ import java.util.ArrayList; class CustomMediaTray extends MediaTray { - private static ArrayList customStringTable = new ArrayList(); - private static ArrayList customEnumTable = new ArrayList(); + private static ArrayList customStringTable = new ArrayList<>(); + private static ArrayList customEnumTable = new ArrayList<>(); private String choiceName; private CustomMediaTray(int x) { @@ -79,7 +79,7 @@ */ protected String[] getStringTable() { String[] nameTable = new String[customStringTable.size()]; - return (String[])customStringTable.toArray(nameTable); + return customStringTable.toArray(nameTable); } /** @@ -87,7 +87,7 @@ */ protected EnumSyntax[] getEnumValueTable() { MediaTray[] enumTable = new MediaTray[customEnumTable.size()]; - return (MediaTray[])customEnumTable.toArray(enumTable); + return customEnumTable.toArray(enumTable); } } --- old/src/share/classes/sun/print/DialogOwner.java 2014-06-08 21:27:54.000000000 -0700 +++ new/src/share/classes/sun/print/DialogOwner.java 2014-06-08 21:27:53.000000000 -0700 @@ -25,6 +25,7 @@ package sun.print; +import javax.print.attribute.Attribute; import javax.print.attribute.PrintRequestAttribute; import java.awt.Frame; @@ -72,7 +73,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 DialogOwner.class; } --- old/src/share/classes/sun/print/PSPrinterJob.java 2014-06-08 21:27:54.000000000 -0700 +++ new/src/share/classes/sun/print/PSPrinterJob.java 2014-06-08 21:27:54.000000000 -0700 @@ -310,7 +310,7 @@ /** * A stack that represents the PostScript gstate stack. */ - ArrayList mGStateStack = new ArrayList(); + ArrayList mGStateStack = new ArrayList<>(); /** * The x coordinate of the current pen position. @@ -346,7 +346,7 @@ //enable priviledges so initProps can access system properties, // open the property file, etc. java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { + new java.security.PrivilegedAction() { public Object run() { mFontProps = initProps(); String osName = System.getProperty("os.name"); @@ -622,11 +622,11 @@ paperWidth + " "+ paperHeight+"]"); final PrintService pservice = getPrintService(); - Boolean isPS = (Boolean)java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + Boolean isPS = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public Boolean run() { try { - Class psClass = Class.forName("sun.print.IPPPrintService"); + Class psClass = Class.forName("sun.print.IPPPrintService"); if (psClass.isInstance(pservice)) { Method isPSMethod = psClass.getMethod("isPostscript", (Class[])null); @@ -660,11 +660,11 @@ // Inner class to run "privileged" to open the printer output stream. - private class PrinterOpener implements java.security.PrivilegedAction { + private class PrinterOpener implements java.security.PrivilegedAction { PrinterException pex; OutputStream result; - public Object run() { + public OutputStream run() { try { /* Write to a temporary file which will be spooled to @@ -687,7 +687,7 @@ // Inner class to run "privileged" to invoke the system print command - private class PrinterSpooler implements java.security.PrivilegedAction { + private class PrinterSpooler implements java.security.PrivilegedAction { PrinterException pex; private void handleProcessFailure(final Process failedProcess, @@ -753,7 +753,7 @@ mPSStream.close(); } java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { + new java.security.PrivilegedAction() { public Object run() { if (spoolFile != null && spoolFile.exists()) { @@ -812,7 +812,7 @@ * It will have the default PostScript gstate * attributes. */ - mGStateStack = new ArrayList(); + mGStateStack = new ArrayList<>(); mGStateStack.add(new GState()); mPSStream.println(PAGE_COMMENT + pageNumber + " " + pageNumber); @@ -825,13 +825,11 @@ paperWidth + " " + paperHeight + "]"); final PrintService pservice = getPrintService(); - Boolean isPS = - (Boolean)java.security.AccessController.doPrivileged( - - new java.security.PrivilegedAction() { - public Object run() { + Boolean isPS = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public Boolean run() { try { - Class psClass = + Class psClass = Class.forName("sun.print.IPPPrintService"); if (psClass.isInstance(pservice)) { Method isPSMethod = @@ -1720,7 +1718,7 @@ */ private GState getGState() { int count = mGStateStack.size(); - return (GState) mGStateStack.get(count - 1); + return mGStateStack.get(count - 1); } /** --- old/src/share/classes/sun/print/PSStreamPrintJob.java 2014-06-08 21:27:55.000000000 -0700 +++ new/src/share/classes/sun/print/PSStreamPrintJob.java 2014-06-08 21:27:54.000000000 -0700 @@ -66,9 +66,9 @@ public class PSStreamPrintJob implements CancelablePrintJob { - transient private Vector jobListeners; - transient private Vector attrListeners; - transient private Vector listenedAttributeSets; + transient private Vector jobListeners; + transient private Vector attrListeners; + transient private Vector listenedAttributeSets; private PSStreamPrintService service; private boolean fidelity; @@ -117,7 +117,7 @@ return; } if (jobListeners == null) { - jobListeners = new Vector(); + jobListeners = new Vector<>(); } jobListeners.add(listener); } @@ -191,7 +191,7 @@ PrintJobListener listener; PrintJobEvent event = new PrintJobEvent(this, reason); for (int i = 0; i < jobListeners.size(); i++) { - listener = (PrintJobListener)(jobListeners.elementAt(i)); + listener = jobListeners.elementAt(i); switch (reason) { case PrintJobEvent.JOB_CANCELED : @@ -230,8 +230,8 @@ return; } if (attrListeners == null) { - attrListeners = new Vector(); - listenedAttributeSets = new Vector(); + attrListeners = new Vector<>(); + listenedAttributeSets = new Vector<>(); } attrListeners.add(listener); if (attributes == null) { @@ -494,7 +494,7 @@ private void getAttributeValues(DocFlavor flavor) throws PrintException { Attribute attr; - Class category; + Class category; if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) { fidelity = true; --- old/src/share/classes/sun/print/PSStreamPrintService.java 2014-06-08 21:27:55.000000000 -0700 +++ new/src/share/classes/sun/print/PSStreamPrintService.java 2014-06-08 21:27:55.000000000 -0700 @@ -62,7 +62,7 @@ public class PSStreamPrintService extends StreamPrintService implements SunPrinterJobService { - private static final Class[] suppAttrCats = { + private static final Class[] suppAttrCats = { Chromaticity.class, Copies.class, Fidelity.class, @@ -108,7 +108,7 @@ return new PSStreamPrintJob(this); } - public boolean usesClass(Class c) { + public boolean usesClass(Class c) { return (c == sun.print.PSPrinterJob.class); } @@ -137,7 +137,9 @@ throw new IllegalArgumentException("Not a PrintServiceAttribute"); } if (category == ColorSupported.class) { - return (T)ColorSupported.SUPPORTED; + @SuppressWarnings("unchecked") + T tmp = (T)ColorSupported.SUPPORTED; + return tmp; } else { return null; } @@ -161,7 +163,7 @@ public Class[] getSupportedAttributeCategories() { - Class []cats = new Class[suppAttrCats.length]; + Class[] cats = new Class[suppAttrCats.length]; System.arraycopy(suppAttrCats, 0, cats, 0, cats.length); return cats; } @@ -401,7 +403,7 @@ throw new IllegalArgumentException(flavor + " is an unsupported flavor"); } - Class category = attr.getCategory(); + Class category = attr.getCategory(); if (!isAttributeCategorySupported(category)) { return false; } --- old/src/share/classes/sun/print/PrintJob2D.java 2014-06-08 21:27:56.000000000 -0700 +++ new/src/share/classes/sun/print/PrintJob2D.java 2014-06-08 21:27:55.000000000 -0700 @@ -1011,7 +1011,7 @@ private String qid="noname"; - private ArrayList queue = new ArrayList(); + private ArrayList queue = new ArrayList<>(); MessageQ(String id) { qid = id; @@ -1055,7 +1055,7 @@ while (g == null && queue != null) { if (queue.size() > 0) { - g = (Graphics2D) queue.remove(0); + g = queue.remove(0); notify(); } else { --- old/src/share/classes/sun/print/PrintJobAttributeException.java 2014-06-08 21:27:56.000000000 -0700 +++ new/src/share/classes/sun/print/PrintJobAttributeException.java 2014-06-08 21:27:56.000000000 -0700 @@ -34,19 +34,19 @@ implements AttributeException { private Attribute attr; - private Class category; + private Class category; - PrintJobAttributeException(String s, Class cat, Attribute attrval) { + PrintJobAttributeException(String s, Class cat, Attribute attrval) { super(s); attr = attrval; category = cat; } - public Class[] getUnsupportedAttributes() { + public Class[] getUnsupportedAttributes() { if (category == null) { return null; } else { - Class [] cats = { category}; + Class[] cats = { category}; return cats; } } --- old/src/share/classes/sun/print/PrinterJobWrapper.java 2014-06-08 21:27:57.000000000 -0700 +++ new/src/share/classes/sun/print/PrinterJobWrapper.java 2014-06-08 21:27:56.000000000 -0700 @@ -26,6 +26,7 @@ package sun.print; import java.awt.print.PrinterJob; +import javax.print.attribute.Attribute; import javax.print.attribute.PrintRequestAttribute; public class PrinterJobWrapper implements PrintRequestAttribute { @@ -42,7 +43,7 @@ return job; } - public final Class getCategory() { + public final Class getCategory() { return PrinterJobWrapper.class; } --- old/src/share/classes/sun/print/RasterPrinterJob.java 2014-06-08 21:27:57.000000000 -0700 +++ new/src/share/classes/sun/print/RasterPrinterJob.java 2014-06-08 21:27:57.000000000 -0700 @@ -273,7 +273,7 @@ /** * List of areas & the graphics state for redrawing */ - private ArrayList redrawList = new ArrayList(); + private ArrayList redrawList = new ArrayList<>(); /* variables representing values extracted from an attribute set. @@ -712,10 +712,9 @@ GraphicsEnvironment.getLocalGraphicsEnvironment(). getDefaultScreenDevice().getDefaultConfiguration(); - PrintService service = - (PrintService)java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + PrintService service = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public PrintService run() { PrintService service = getPrintService(); if (service == null) { ServiceDialog.showNoPrintService(gc); @@ -768,10 +767,9 @@ int x = bounds.x+bounds.width/3; int y = bounds.y+bounds.height/3; - PrintService service = - (PrintService)java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + PrintService service = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public PrintService run() { PrintService service = getPrintService(); if (service == null) { ServiceDialog.showNoPrintService(gc); @@ -793,7 +791,7 @@ if (pageDialog.getStatus() == ServiceDialog.APPROVE) { PrintRequestAttributeSet newas = pageDialog.getAttributes(); - Class amCategory = SunAlternateMedia.class; + Class amCategory = SunAlternateMedia.class; if (attributes.containsKey(amCategory) && !newas.containsKey(amCategory)) { @@ -868,10 +866,9 @@ GraphicsEnvironment.getLocalGraphicsEnvironment(). getDefaultScreenDevice().getDefaultConfiguration(); - PrintService service = - (PrintService)java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + PrintService service = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public PrintService run() { PrintService service = getPrintService(); if (service == null) { ServiceDialog.showNoPrintService(gc); @@ -894,10 +891,9 @@ services[i] = spsFactories[i].getPrintService(null); } } else { - services = - (PrintService[])java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + services = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public PrintService[] run() { PrintService[] services = PrinterJob.lookupPrintServices(); return services; } @@ -2131,7 +2127,7 @@ painter.print(pathGraphics, origPage, pageIndex); for (int i=0;i dstCategory = Destination.class; Destination dst = (Destination)asCurrent.get(dstCategory); if (dst == null) { @@ -463,7 +463,7 @@ */ public static void initResource() { java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { + new java.security.PrivilegedAction() { public Object run() { try { messageRB = ResourceBundle.getBundle(strBundle); @@ -529,7 +529,7 @@ /** * Returns the mnemonic as a KeyEvent.VK constant from the resource. */ - static Class _keyEventClazz = null; + static Class _keyEventClazz = null; private static int getVKMnemonic(String key) { String s = String.valueOf(getMnemonic(key)); if ( s == null || s.length() != 1) { @@ -554,9 +554,9 @@ * Returns URL for image resource */ private static URL getImageResource(final String key) { - URL url = (URL)java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + URL url = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public URL run() { URL url = ServiceDialog.class.getResource( "resources/" + key); return url; @@ -710,7 +710,7 @@ private FilePermission printToFilePermission; private JButton btnProperties; private JCheckBox cbPrintToFile; - private JComboBox cbName; + private JComboBox cbName; private JLabel lblType, lblStatus, lblInfo; private ServiceUIFactory uiFactory; private boolean changedService = false; @@ -731,7 +731,7 @@ for (int i = 0; i < psnames.length; i++) { psnames[i] = services[i].getName(); } - cbName = new JComboBox(psnames); + cbName = new JComboBox<>(psnames); cbName.setSelectedIndex(defaultServiceIndex); cbName.addItemListener(this); cbName.addPopupMenuListener(this); @@ -924,7 +924,7 @@ } public void updateInfo() { - Class dstCategory = Destination.class; + Class dstCategory = Destination.class; boolean dstSupported = false; boolean dstSelected = false; boolean dstAllowed = filePermission ? @@ -1123,7 +1123,7 @@ } public void updateInfo() { - Class prCategory = PageRanges.class; + Class prCategory = PageRanges.class; prSupported = false; if (psCurrent.isAttributeCategorySupported(prCategory) || @@ -1240,9 +1240,8 @@ } public void updateInfo() { - Class cpCategory = Copies.class; - Class csCategory = CopiesSupported.class; - Class scCategory = SheetCollate.class; + Class cpCategory = Copies.class; + Class scCategory = SheetCollate.class; boolean cpSupported = false; scSupported = false; @@ -1525,7 +1524,7 @@ float bm = bmTmpObj.floatValue(); /* adjust for orientation */ - Class orCategory = OrientationRequested.class; + Class orCategory = OrientationRequested.class; OrientationRequested or = (OrientationRequested)asCurrent.get(orCategory); @@ -1589,7 +1588,7 @@ private MediaPrintableArea validateMargins(float lm, float rm, float tm, float bm) { - Class mpaCategory = MediaPrintableArea.class; + Class mpaCategory = MediaPrintableArea.class; MediaPrintableArea mpa; MediaPrintableArea mpaMax = null; MediaSize mediaSize = null; @@ -1671,7 +1670,7 @@ return; } - Class mpaCategory = MediaPrintableArea.class; + Class mpaCategory = MediaPrintableArea.class; MediaPrintableArea mpa = (MediaPrintableArea)asCurrent.get(mpaCategory); MediaPrintableArea mpaMax = null; @@ -1845,7 +1844,7 @@ * to the fields appropriate for the orientation. * Note: if orientation changes this method must be called. */ - Class orCategory = OrientationRequested.class; + Class orCategory = OrientationRequested.class; OrientationRequested or = (OrientationRequested)asCurrent.get(orCategory); @@ -1885,9 +1884,9 @@ private final String strTitle = getMsg("border.media"); private JLabel lblSize, lblSource; - private JComboBox cbSize, cbSource; - private Vector sizes = new Vector(); - private Vector sources = new Vector(); + private JComboBox cbSize, cbSource; + private Vector sizes = new Vector<>(); + private Vector sources = new Vector<>(); private MarginsPanel pnlMargins = null; public MediaPanel() { @@ -1899,8 +1898,8 @@ setLayout(gridbag); setBorder(BorderFactory.createTitledBorder(strTitle)); - cbSize = new JComboBox(); - cbSource = new JComboBox(); + cbSize = new JComboBox<>(); + cbSource = new JComboBox<>(); c.fill = GridBagConstraints.BOTH; c.insets = compInsets; @@ -1950,17 +1949,17 @@ (cbSource.getSelectedIndex() >= 1)) { int src = cbSource.getSelectedIndex() - 1; - MediaTray mt = (MediaTray)sources.get(src); + MediaTray mt = sources.get(src); asCurrent.add(new SunAlternateMedia(mt)); } - asCurrent.add((MediaSizeName)sizes.get(index)); + asCurrent.add(sizes.get(index)); } } else if (source == cbSource) { int index = cbSource.getSelectedIndex(); if ((index >= 1) && (index < (sources.size() + 1))) { asCurrent.remove(SunAlternateMedia.class); - MediaTray newTray = (MediaTray)sources.get(index - 1); + MediaTray newTray = sources.get(index - 1); Media m = (Media)asCurrent.get(Media.class); if (m == null || m instanceof MediaTray) { asCurrent.add(newTray); @@ -1980,7 +1979,7 @@ asCurrent.remove(SunAlternateMedia.class); if (cbSize.getItemCount() > 0) { int size = cbSize.getSelectedIndex(); - asCurrent.add((MediaSizeName)sizes.get(size)); + asCurrent.add(sizes.get(size)); } } } @@ -1997,8 +1996,8 @@ pnlMargins = pnl; } public void updateInfo() { - Class mdCategory = Media.class; - Class amCategory = SunAlternateMedia.class; + Class mdCategory = Media.class; + Class amCategory = SunAlternateMedia.class; boolean mediaSupported = false; cbSize.removeItemListener(this); @@ -2025,10 +2024,10 @@ Media medium = media[i]; if (medium instanceof MediaSizeName) { - sizes.add(medium); + sizes.add((MediaSizeName)medium); cbSize.addItem(getMediaName(medium.toString())); } else if (medium instanceof MediaTray) { - sources.add(medium); + sources.add((MediaTray)medium); cbSource.addItem(getMediaName(medium.toString())); } } @@ -2095,12 +2094,12 @@ int selIndex = cbSize.getSelectedIndex(); if ((selIndex >= 0) && (selIndex < sizes.size())) { - asCurrent.add((MediaSizeName)sizes.get(selIndex)); + asCurrent.add(sizes.get(selIndex)); } selIndex = cbSource.getSelectedIndex(); if ((selIndex >= 1) && (selIndex < (sources.size()+1))) { - MediaTray mt = (MediaTray)sources.get(selIndex-1); + MediaTray mt = sources.get(selIndex-1); if (medium instanceof MediaTray) { asCurrent.add(mt); } else { @@ -2185,7 +2184,7 @@ } public void updateInfo() { - Class orCategory = OrientationRequested.class; + Class orCategory = OrientationRequested.class; boolean pSupported = false; boolean lSupported = false; boolean rpSupported = false; @@ -2363,7 +2362,7 @@ } public void updateInfo() { - Class chCategory = Chromaticity.class; + Class chCategory = Chromaticity.class; boolean monoSupported = false; boolean colorSupported = false; @@ -2458,7 +2457,7 @@ } public void updateInfo() { - Class pqCategory = PrintQuality.class; + Class pqCategory = PrintQuality.class; boolean draftSupported = false; boolean normalSupported = false; boolean highSupported = false; @@ -2568,7 +2567,7 @@ } public void updateInfo() { - Class sdCategory = Sides.class; + Class sdCategory = Sides.class; boolean osSupported = false; boolean tSupported = false; boolean dSupported = false; @@ -2725,10 +2724,10 @@ public void focusGained(FocusEvent e) {} public void updateInfo() { - Class jsCategory = JobSheets.class; - Class jpCategory = JobPriority.class; - Class jnCategory = JobName.class; - Class unCategory = RequestingUserName.class; + Class jsCategory = JobSheets.class; + Class jpCategory = JobPriority.class; + Class jnCategory = JobName.class; + Class unCategory = RequestingUserName.class; boolean jsSupported = false; boolean jpSupported = false; boolean jnSupported = false; @@ -2817,9 +2816,9 @@ { super(new FlowLayout(FlowLayout.LEADING)); final URL imgURL = getImageResource(img); - Icon icon = (Icon)java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + Icon icon = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public Icon run() { Icon icon = new ImageIcon(imgURL); return icon; } --- old/src/share/classes/sun/print/ServiceNotifier.java 2014-06-08 21:27:58.000000000 -0700 +++ new/src/share/classes/sun/print/ServiceNotifier.java 2014-06-08 21:27:58.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,14 +43,14 @@ class ServiceNotifier extends Thread { private PrintService service; - private Vector listeners; + private Vector listeners; private boolean stop = false; private PrintServiceAttributeSet lastSet; ServiceNotifier(PrintService service) { super(service.getName() + " notifier"); this.service = service; - listeners = new Vector(); + listeners = new Vector<>(); try { setPriority(Thread.NORM_PRIORITY-1); setDaemon(true); @@ -128,8 +128,7 @@ } if (psa != null && !psa.isEmpty()) { for (int i = 0; i < listeners.size() ; i++) { - listener = (PrintServiceAttributeListener) - listeners.elementAt(i); + listener = listeners.elementAt(i); attrs = new HashPrintServiceAttributeSet(psa); attrEvent = --- old/src/share/classes/sun/print/SunAlternateMedia.java 2014-06-08 21:27:58.000000000 -0700 +++ new/src/share/classes/sun/print/SunAlternateMedia.java 2014-06-08 21:27:58.000000000 -0700 @@ -25,6 +25,7 @@ package sun.print; +import javax.print.attribute.Attribute; import javax.print.attribute.PrintRequestAttribute; import javax.print.attribute.standard.Media; @@ -47,7 +48,7 @@ return media; } - public final Class getCategory() { + public final Class getCategory() { return SunAlternateMedia.class; } --- old/src/share/classes/sun/print/SunMinMaxPage.java 2014-06-08 21:27:59.000000000 -0700 +++ new/src/share/classes/sun/print/SunMinMaxPage.java 2014-06-08 21:27:59.000000000 -0700 @@ -26,6 +26,7 @@ package sun.print; import javax.print.attribute.PrintRequestAttribute; +import javax.print.attribute.PrintRequestAttribute; /* * A class used to determine minimum and maximum pages. @@ -40,7 +41,7 @@ } - public final Class getCategory() { + public final Class getCategory() { return SunMinMaxPage.class; } --- old/src/share/classes/sun/print/SunPageSelection.java 2014-06-08 21:27:59.000000000 -0700 +++ new/src/share/classes/sun/print/SunPageSelection.java 2014-06-08 21:27:59.000000000 -0700 @@ -25,6 +25,7 @@ package sun.print; +import javax.print.attribute.Attribute; import javax.print.attribute.PrintRequestAttribute; /* @@ -43,7 +44,7 @@ pages = value; } - public final Class getCategory() { + public final Class getCategory() { return SunPageSelection.class; } --- old/src/share/classes/sun/print/SunPrinterJobService.java 2014-06-08 21:28:00.000000000 -0700 +++ new/src/share/classes/sun/print/SunPrinterJobService.java 2014-06-08 21:28:00.000000000 -0700 @@ -37,6 +37,6 @@ * platform's built-in subclass of PrinterJob. * ie the same class as the caller. */ - public boolean usesClass(Class c); + public boolean usesClass(Class c); } --- old/src/solaris/classes/sun/print/CUPSPrinter.java 2014-06-08 21:28:00.000000000 -0700 +++ new/src/solaris/classes/sun/print/CUPSPrinter.java 2014-06-08 21:28:00.000000000 -0700 @@ -246,9 +246,9 @@ IPPPrintService.getIPPConnection(url); if (urlConnection != null) { - OutputStream os = (OutputStream)java.security.AccessController. - doPrivileged(new java.security.PrivilegedAction() { - public Object run() { + OutputStream os = java.security.AccessController. + doPrivileged(new java.security.PrivilegedAction() { + public OutputStream run() { try { return urlConnection.getOutputStream(); } catch (Exception e) { @@ -274,10 +274,10 @@ IPPPrintService.OP_CUPS_GET_DEFAULT, attCl)) { - HashMap defaultMap = null; + HashMap defaultMap = null; String[] printerInfo = new String[2]; InputStream is = urlConnection.getInputStream(); - HashMap[] responseMap = IPPPrintService.readIPPResponse( + HashMap[] responseMap = IPPPrintService.readIPPResponse( is); is.close(); @@ -309,13 +309,11 @@ } - AttributeClass attribClass = (AttributeClass) - defaultMap.get("printer-name"); + AttributeClass attribClass = defaultMap.get("printer-name"); if (attribClass != null) { printerInfo[0] = attribClass.getStringValue(); - attribClass = (AttributeClass) - defaultMap.get("printer-uri-supported"); + attribClass = defaultMap.get("printer-uri-supported"); IPPPrintService.debug_println(debugPrefix+ "printer-uri-supported="+attribClass); if (attribClass != null) { @@ -348,9 +346,9 @@ IPPPrintService.getIPPConnection(url); if (urlConnection != null) { - OutputStream os = (OutputStream)java.security.AccessController. - doPrivileged(new java.security.PrivilegedAction() { - public Object run() { + OutputStream os = java.security.AccessController. + doPrivileged(new java.security.PrivilegedAction() { + public OutputStream run() { try { return urlConnection.getOutputStream(); } catch (Exception e) { @@ -375,7 +373,7 @@ IPPPrintService.OP_CUPS_GET_PRINTERS, attCl)) { InputStream is = urlConnection.getInputStream(); - HashMap[] responseMap = + HashMap[] responseMap = IPPPrintService.readIPPResponse(is); is.close(); @@ -386,9 +384,9 @@ return null; } - ArrayList printerNames = new ArrayList(); + ArrayList printerNames = new ArrayList<>(); for (int i=0; i< responseMap.length; i++) { - AttributeClass attribClass = (AttributeClass) + AttributeClass attribClass = responseMap[i].get("printer-uri-supported"); if (attribClass != null) { @@ -396,7 +394,7 @@ printerNames.add(nameStr); } } - return (String[])printerNames.toArray(new String[] {}); + return printerNames.toArray(new String[] {}); } else { os.close(); urlConnection.disconnect(); --- old/src/solaris/classes/sun/print/IPPPrintService.java 2014-06-08 21:28:01.000000000 -0700 +++ new/src/solaris/classes/sun/print/IPPPrintService.java 2014-06-08 21:28:00.000000000 -0700 @@ -91,7 +91,7 @@ private CUPSPrinter cps; private HttpURLConnection urlConnection = null; private DocFlavor[] supportedDocFlavors; - private Class[] supportedCats; + private Class[] supportedCats; private MediaTray[] mediaTrays; private MediaSizeName[] mediaSizeNames; private CustomMediaSizeName[] customMediaSizeNames; @@ -99,7 +99,7 @@ private boolean isCupsPrinter; private boolean init; private Boolean isPS; - private HashMap getAttMap; + private HashMap getAttMap; private boolean pngImagesAdded = false; private boolean gifImagesAdded = false; private boolean jpgImagesAdded = false; @@ -424,8 +424,8 @@ // use IPP to get all media, Media[] allMedia = getSupportedMedia(); - ArrayList sizeList = new ArrayList(); - ArrayList trayList = new ArrayList(); + ArrayList sizeList = new ArrayList<>(); + ArrayList trayList = new ArrayList<>(); for (int i=0; i docList = new HashSet<>(); int j; String hostEnc = DocFlavor.hostEncoding. toLowerCase(Locale.ENGLISH); @@ -970,8 +968,7 @@ if ((getAttMap != null) && getAttMap.containsKey("media-supported")) { - AttributeClass attribClass = - (AttributeClass)getAttMap.get("media-supported"); + AttributeClass attribClass = getAttMap.get("media-supported"); if (attribClass != null) { String[] mediaVals = attribClass.getArrayOfStringValues(); @@ -990,23 +987,21 @@ } - public synchronized Class[] getSupportedAttributeCategories() { + public synchronized Class[] getSupportedAttributeCategories() { if (supportedCats != null) { return supportedCats; } initAttributes(); - ArrayList catList = new ArrayList(); - Class cl; + ArrayList> catList = new ArrayList<>(); for (int i=0; i < printReqAttribDefault.length; i++) { PrintRequestAttribute pra = (PrintRequestAttribute)printReqAttribDefault[i]; if (getAttMap != null && getAttMap.containsKey(pra.getName()+"-supported")) { - cl = pra.getCategory(); - catList.add(cl); + catList.add(pra.getCategory()); } } @@ -1047,7 +1042,7 @@ if (getAttMap != null && getAttMap.containsKey("color-supported")) { catList.add(Chromaticity.class); } - supportedCats = new Class[catList.size()]; + supportedCats = new Class[catList.size()]; catList.toArray(supportedCats); return supportedCats; } @@ -1085,7 +1080,7 @@ return false; } - + @SuppressWarnings("unchecked") public synchronized T getAttribute(Class category) { @@ -1103,7 +1098,7 @@ } else if (category == PrinterInfo.class) { PrinterInfo pInfo = new PrinterInfo(printer, null); AttributeClass ac = (getAttMap != null) ? - (AttributeClass)getAttMap.get(pInfo.getName()) + getAttMap.get(pInfo.getName()) : null; if (ac != null) { return (T)(new PrinterInfo(ac.getStringValue(), null)); @@ -1112,7 +1107,7 @@ } else if (category == QueuedJobCount.class) { QueuedJobCount qjc = new QueuedJobCount(0); AttributeClass ac = (getAttMap != null) ? - (AttributeClass)getAttMap.get(qjc.getName()) + getAttMap.get(qjc.getName()) : null; if (ac != null) { qjc = new QueuedJobCount(ac.getIntValue()); @@ -1122,7 +1117,7 @@ PrinterIsAcceptingJobs accJob = PrinterIsAcceptingJobs.ACCEPTING_JOBS; AttributeClass ac = (getAttMap != null) ? - (AttributeClass)getAttMap.get(accJob.getName()) + getAttMap.get(accJob.getName()) : null; if ((ac != null) && (ac.getByteValue() == 0)) { accJob = PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS; @@ -1131,7 +1126,7 @@ } else if (category == ColorSupported.class) { ColorSupported cs = ColorSupported.SUPPORTED; AttributeClass ac = (getAttMap != null) ? - (AttributeClass)getAttMap.get(cs.getName()) + getAttMap.get(cs.getName()) : null; if ((ac != null) && (ac.getByteValue() == 0)) { cs = ColorSupported.NOT_SUPPORTED; @@ -1165,7 +1160,8 @@ for (int i=0; i < serviceAttributes.length; i++) { String name = (String)serviceAttributes[i][1]; if (getAttMap != null && getAttMap.containsKey(name)) { - Class c = (Class)serviceAttributes[i][0]; + @SuppressWarnings("unchecked") + Class c = (Class)serviceAttributes[i][0]; PrintServiceAttribute psa = getAttribute(c); if (psa != null) { attrs.add(psa); @@ -1279,7 +1275,7 @@ return false; } } - Class category = attr.getCategory(); + Class category = attr.getCategory(); if (!isAttributeCategorySupported(category)) { return false; } @@ -1397,7 +1393,7 @@ } String attribName = catName+"-default"; AttributeClass attribClass = (getAttMap != null) ? - (AttributeClass)getAttMap.get(attribName) : null; + getAttMap.get(attribName) : null; if (category == Copies.class) { if (attribClass != null) { @@ -1600,7 +1596,7 @@ } - public boolean usesClass(Class c) { + public boolean usesClass(Class c) { return (c == sun.print.PSPrinterJob.class); } @@ -1675,9 +1671,9 @@ AttributeClass.TAG_URI, ""+myURI)}; - OutputStream os = (OutputStream)java.security.AccessController. - doPrivileged(new java.security.PrivilegedAction() { - public Object run() { + OutputStream os = java.security.AccessController. + doPrivileged(new java.security.PrivilegedAction() { + public OutputStream run() { try { return urlConnection.getOutputStream(); } catch (Exception e) { @@ -1696,7 +1692,7 @@ if (success) { InputStream is = null; if ((is = urlConnection.getInputStream())!=null) { - HashMap[] responseMap = readIPPResponse(is); + HashMap[] responseMap = readIPPResponse(is); if (responseMap != null && responseMap.length > 0) { getAttMap = responseMap[0]; @@ -1771,7 +1767,7 @@ } - public static HashMap[] readIPPResponse(InputStream inputStream) { + public static HashMap[] readIPPResponse(InputStream inputStream) { if (inputStream == null) { return null; @@ -1792,8 +1788,8 @@ String attribStr = null; // assign default value byte valTagByte = AttributeClass.TAG_KEYWORD; - ArrayList respList = new ArrayList(); - HashMap responseMap = new HashMap(); + ArrayList> respList = new ArrayList<>(); + HashMap responseMap = new HashMap<>(); response[0] = ois.readByte(); @@ -1829,7 +1825,7 @@ // if key exists, new HashMap if (responseMap.containsKey(attribStr)) { respList.add(responseMap); - responseMap = new HashMap(); + responseMap = new HashMap<>(); } // exclude those that are unknown @@ -1885,7 +1881,7 @@ if ((counter != 0) && responseMap.containsKey(attribStr)) { respList.add(responseMap); - responseMap = new HashMap(); + responseMap = new HashMap<>(); } byte outArray[] = outObj.toByteArray(); @@ -1901,8 +1897,10 @@ if ((responseMap != null) && (responseMap.size() > 0)) { respList.add(responseMap); } - return (HashMap[])respList.toArray( - new HashMap[respList.size()]); + @SuppressWarnings({"unchecked", "rawtypes"}) + HashMap[] tmp = + respList.toArray((HashMap[])new HashMap[respList.size()]); + return tmp; } else { debug_println(debugPrefix+ "readIPPResponse client error, IPP status code: 0x"+ --- old/src/solaris/classes/sun/print/UnixPrintJob.java 2014-06-08 21:28:01.000000000 -0700 +++ new/src/solaris/classes/sun/print/UnixPrintJob.java 2014-06-08 21:28:01.000000000 -0700 @@ -90,9 +90,9 @@ public class UnixPrintJob implements CancelablePrintJob { private static String debugPrefix = "UnixPrintJob>> "; - transient private Vector jobListeners; - transient private Vector attrListeners; - transient private Vector listenedAttributeSets; + transient private Vector jobListeners; + transient private Vector attrListeners; + transient private Vector listenedAttributeSets; private PrintService service; private boolean fidelity; @@ -150,7 +150,7 @@ return; } if (jobListeners == null) { - jobListeners = new Vector(); + jobListeners = new Vector<>(); } jobListeners.add(listener); } @@ -238,7 +238,7 @@ PrintJobListener listener; PrintJobEvent event = new PrintJobEvent(this, reason); for (int i = 0; i < jobListeners.size(); i++) { - listener = (PrintJobListener)(jobListeners.elementAt(i)); + listener = jobListeners.elementAt(i); switch (reason) { case PrintJobEvent.JOB_CANCELED : @@ -273,8 +273,8 @@ return; } if (attrListeners == null) { - attrListeners = new Vector(); - listenedAttributeSets = new Vector(); + attrListeners = new Vector<>(); + listenedAttributeSets = new Vector<>(); } attrListeners.add(listener); if (attributes == null) { @@ -770,7 +770,7 @@ private void getAttributeValues(DocFlavor flavor) throws PrintException { Attribute attr; - Class category; + Class category; if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) { fidelity = true; @@ -941,11 +941,11 @@ // Inner class to run "privileged" to open the printer output stream. - private class PrinterOpener implements java.security.PrivilegedAction { + private class PrinterOpener implements java.security.PrivilegedAction { PrintException pex; OutputStream result; - public Object run() { + public OutputStream run() { try { if (mDestType == UnixPrintJob.DESTFILE) { spoolFile = new File(mDestination); @@ -971,7 +971,7 @@ // Inner class to run "privileged" to invoke the system print command - private class PrinterSpooler implements java.security.PrivilegedAction { + private class PrinterSpooler implements java.security.PrivilegedAction { PrintException pex; private void handleProcessFailure(final Process failedProcess, --- old/src/solaris/classes/sun/print/UnixPrintService.java 2014-06-08 21:28:02.000000000 -0700 +++ new/src/solaris/classes/sun/print/UnixPrintService.java 2014-06-08 21:28:01.000000000 -0700 @@ -148,7 +148,7 @@ } /* let's try to support a few of these */ - private static final Class[] serviceAttrCats = { + private static final Class[] serviceAttrCats = { PrinterName.class, PrinterIsAcceptingJobs.class, QueuedJobCount.class, @@ -157,7 +157,7 @@ /* it turns out to be inconvenient to store the other categories * separately because many attributes are in multiple categories. */ - private static final Class[] otherAttrCats = { + private static final Class[] otherAttrCats = { Chromaticity.class, Copies.class, Destination.class, @@ -278,7 +278,7 @@ // and extra lines which have been added for remote printers. // 'protected' because this method is also used from UnixPrintServiceLookup. protected static String[] filterPrinterNamesAIX(String[] posPrinters) { - ArrayList printers = new ArrayList(); + ArrayList printers = new ArrayList<>(); String [] splitPart; for(int i = 0; i < posPrinters.length; i++) { @@ -295,7 +295,7 @@ } } - return (String[])printers.toArray(new String[printers.size()]); + return printers.toArray(new String[printers.size()]); } private PrinterIsAcceptingJobs getPrinterIsAcceptingJobsAIX() { @@ -533,6 +533,7 @@ } } + @SuppressWarnings("unchecked") public T getAttribute(Class category) { @@ -617,9 +618,9 @@ return false; } - public Class[] getSupportedAttributeCategories() { + public Class[] getSupportedAttributeCategories() { int totalCats = otherAttrCats.length; - Class [] cats = new Class[totalCats]; + Class[] cats = new Class[totalCats]; System.arraycopy(otherAttrCats, 0, cats, 0, otherAttrCats.length); return cats; } @@ -967,7 +968,7 @@ return false; } } - Class category = attr.getCategory(); + Class category = attr.getCategory(); if (!isAttributeCategorySupported(category)) { return false; } @@ -1078,7 +1079,7 @@ return this.getClass().hashCode()+getName().hashCode(); } - public boolean usesClass(Class c) { + public boolean usesClass(Class c) { return (c == sun.print.PSPrinterJob.class); } --- old/src/solaris/classes/sun/print/UnixPrintServiceLookup.java 2014-06-08 21:28:02.000000000 -0700 +++ new/src/solaris/classes/sun/print/UnixPrintServiceLookup.java 2014-06-08 21:28:02.000000000 -0700 @@ -69,7 +69,7 @@ private String defaultPrinter; private PrintService defaultPrintService; private PrintService[] printServices; /* includes the default printer */ - private Vector lookupListeners = null; + private Vector lookupListeners = null; private static String debugPrefix = "UnixPrintServiceLookup>> "; private static boolean pollServices = true; private static final int DEFAULT_MINREFRESH = 120; // 2 minutes @@ -239,7 +239,7 @@ } } - private int addPrintServiceToList(ArrayList printerList, PrintService ps) { + private int addPrintServiceToList(ArrayList printerList, PrintService ps) { int index = printerList.indexOf(ps); // Check if PrintService with same name is already in the list. if (CUPSPrinter.isCupsRunning() && index != -1) { @@ -253,7 +253,7 @@ IPPPrintService.debug_println(debugPrefix+"duplicate PrintService, ignoring the new local printer: "+ps); return index; // Do not add this. } - PrintService oldPS = (PrintService)(printerList.get(index)); + PrintService oldPS = printerList.get(index); uri = oldPS.getAttribute(PrinterURI.class); if (uri.getURI().getHost().equals("localhost")) { IPPPrintService.debug_println(debugPrefix+"duplicate PrintService, removing existing local printer: "+oldPS); @@ -319,7 +319,7 @@ return; } - ArrayList printerList = new ArrayList(); + ArrayList printerList = new ArrayList<>(); int defaultIndex = -1; for (int p=0; p 0) { @@ -411,9 +410,9 @@ PrintServiceAttributeSet attributes) { Attribute [] attrs = attributes.toArray(); - Attribute serviceAttr; for (int i=0; i)attrs[i].getCategory()); if (serviceAttr == null || !serviceAttr.equals(attrs[i])) { return false; @@ -542,7 +541,7 @@ } } else { /* specified service attributes don't include a name.*/ - Vector matchedServices = new Vector(); + Vector matchedServices = new Vector<>(); services = getPrintServices(); for (int i = 0; i< services.length; i++) { if (matchesAttributes(services[i], serviceSet)) { @@ -551,7 +550,7 @@ } services = new PrintService[matchedServices.size()]; for (int i = 0; i< services.length; i++) { - services[i] = (PrintService)matchedServices.elementAt(i); + services[i] = matchedServices.elementAt(i); } return services; } @@ -591,7 +590,7 @@ } if (CUPSPrinter.isCupsRunning()) { - ArrayList matchingServices = new ArrayList(); + ArrayList matchingServices = new ArrayList<>(); for (int i=0; i(); lookupListeners.add(listener); Thread lookupThread = new Thread(this); lookupThread.start(); @@ -733,8 +732,7 @@ synchronized (this) { BackgroundLookupListener listener; for (int i=0; i printerNames = new ArrayList<>(); for (int i=0; i < names.length; i++) { if (!names[i].equals("_default") && !names[i].equals(defaultPrinter) && @@ -828,7 +826,7 @@ printerNames.add(names[i]); } } - return (String[])printerNames.toArray(new String[printerNames.size()]); + return printerNames.toArray(new String[printerNames.size()]); } private String getDefaultPrinterNameAIX() { @@ -870,7 +868,7 @@ } static String[] execCmd(final String command) { - ArrayList results = null; + ArrayList results = null; try { final String[] cmd = new String[3]; if (isSysV() || isAIX()) { @@ -883,9 +881,9 @@ cmd[2] = "LC_ALL=C " + command; } - results = (ArrayList)AccessController.doPrivileged( - new PrivilegedExceptionAction() { - public Object run() throws IOException { + results = AccessController.doPrivileged( + new PrivilegedExceptionAction>() { + public ArrayList run() throws IOException { Process proc; BufferedReader bufferedReader = null; @@ -907,7 +905,7 @@ FileReader reader = new FileReader(f); bufferedReader = new BufferedReader(reader); String line; - ArrayList results = new ArrayList(); + ArrayList results = new ArrayList<>(); while ((line = bufferedReader.readLine()) != null) { results.add(line); @@ -932,7 +930,7 @@ if (results == null) { return new String[0]; } else { - return (String[])results.toArray(new String[results.size()]); + return results.toArray(new String[results.size()]); } } --- old/src/windows/classes/sun/print/Win32MediaTray.java 2014-06-08 21:28:02.000000000 -0700 +++ new/src/windows/classes/sun/print/Win32MediaTray.java 2014-06-08 21:28:02.000000000 -0700 @@ -50,8 +50,8 @@ static final Win32MediaTray FORMSOURCE = new Win32MediaTray(5, 15); //DMBIN_FORMSOURCE - private static ArrayList winStringTable = new ArrayList(); - private static ArrayList winEnumTable = new ArrayList(); + private static ArrayList winStringTable = new ArrayList<>(); + private static ArrayList winEnumTable = new ArrayList<>(); public int winID; private Win32MediaTray(int value, int id) { @@ -97,22 +97,22 @@ } protected String[] getStringTable() { - ArrayList completeList = new ArrayList(); + ArrayList completeList = new ArrayList<>(); for (int i=0; i < myStringTable.length; i++) { completeList.add(myStringTable[i]); } completeList.addAll(winStringTable); String[] nameTable = new String[completeList.size()]; - return (String[])completeList.toArray(nameTable); + return completeList.toArray(nameTable); } protected EnumSyntax[] getEnumValueTable() { - ArrayList completeList = new ArrayList(); + ArrayList completeList = new ArrayList<>(); for (int i=0; i < myEnumValueTable.length; i++) { completeList.add(myEnumValueTable[i]); } completeList.addAll(winEnumTable); MediaTray[] enumTable = new MediaTray[completeList.size()]; - return (MediaTray[])completeList.toArray(enumTable); + return completeList.toArray(enumTable); } } --- old/src/windows/classes/sun/print/Win32PrintJob.java 2014-06-08 21:28:03.000000000 -0700 +++ new/src/windows/classes/sun/print/Win32PrintJob.java 2014-06-08 21:28:03.000000000 -0700 @@ -79,9 +79,9 @@ public class Win32PrintJob implements CancelablePrintJob { - transient private Vector jobListeners; - transient private Vector attrListeners; - transient private Vector listenedAttributeSets; + transient private Vector jobListeners; + transient private Vector attrListeners; + transient private Vector listenedAttributeSets; private Win32PrintService service; private boolean fidelity; @@ -139,7 +139,7 @@ return; } if (jobListeners == null) { - jobListeners = new Vector(); + jobListeners = new Vector<>(); } jobListeners.add(listener); } @@ -227,7 +227,7 @@ PrintJobListener listener; PrintJobEvent event = new PrintJobEvent(this, reason); for (int i = 0; i < jobListeners.size(); i++) { - listener = (PrintJobListener)(jobListeners.elementAt(i)); + listener = jobListeners.elementAt(i); switch (reason) { case PrintJobEvent.JOB_COMPLETE : @@ -266,8 +266,8 @@ return; } if (attrListeners == null) { - attrListeners = new Vector(); - listenedAttributeSets = new Vector(); + attrListeners = new Vector<>(); + listenedAttributeSets = new Vector<>(); } attrListeners.add(listener); if (attributes == null) { @@ -670,7 +670,7 @@ fidelity = false; } - Class category; + Class category; Attribute [] attrs = reqAttrSet.toArray(); for (int i=0; i[] serviceAttrCats = { PrinterName.class, PrinterIsAcceptingJobs.class, QueuedJobCount.class, @@ -107,7 +107,7 @@ /* it turns out to be inconvenient to store the other categories * separately because many attributes are in multiple categories. */ - private static Class[] otherAttrCats = { + private static Class[] otherAttrCats = { JobName.class, RequestingUserName.class, Copies.class, @@ -202,7 +202,7 @@ private MediaPrintableArea[] mediaPrintables; private MediaTray[] mediaTrays; private PrinterResolution[] printRes; - private HashMap mpaMap; + private HashMap mpaMap; private int nCopies; private int prnCaps; private int[] defaultSettings; @@ -212,7 +212,7 @@ private boolean mediaInitialized; private boolean mpaListInitialized; - private ArrayList idList; + private ArrayList idList; private MediaSize[] mediaSizes; private boolean isInvalid; @@ -279,7 +279,7 @@ (idList.size() == mediaSizes.length)) { for (int i=0; i< idList.size(); i++) { if (mediaSizes[i].getMediaSizeName() == msn) { - return ((Integer)idList.get(i)).intValue(); + return idList.get(i).intValue(); } } } @@ -338,10 +338,11 @@ } } - private boolean addToUniqueList(ArrayList msnList, MediaSizeName mediaName) { + private boolean addToUniqueList(ArrayList msnList, + MediaSizeName mediaName) { MediaSizeName msn; for (int i=0; i< msnList.size(); i++) { - msn = (MediaSizeName)msnList.get(i); + msn = msnList.get(i); if (msn == mediaName) { return false; } @@ -360,9 +361,8 @@ return; } - ArrayList msnList = new ArrayList(); + ArrayList msnList = new ArrayList<>(); ArrayList trailingWmsList = new ArrayList(); - ArrayList printableList = new ArrayList(); MediaSizeName mediaName; boolean added; boolean queryFailure = false; @@ -375,7 +375,7 @@ // We remove from ID list any invalid mediaSize. Though this is rare, // it happens in HP 4050 German driver. - idList = new ArrayList(); + idList = new ArrayList<>(); for (int i=0; i < media.length; i++) { idList.add(Integer.valueOf(media[i])); } @@ -385,7 +385,7 @@ for (int i = 0; i < idList.size(); i++) { // match Win ID with our predefined ID using table - mediaName = findWin32Media(((Integer)idList.get(i)).intValue()); + mediaName = findWin32Media(idList.get(i).intValue()); // Verify that this standard size is the same size as that // reported by the driver. This should be the case except when // the driver is mis-using a standard windows paper ID. @@ -420,7 +420,7 @@ */ Win32MediaSize wms = Win32MediaSize.findMediaName(dmPaperNameList.get(i)); if ((wms == null) && (idList.size() == mediaSizes.length)) { - wms = new Win32MediaSize(dmPaperNameList.get(i), (Integer)idList.get(i)); + wms = new Win32MediaSize(dmPaperNameList.get(i), idList.get(i)); mediaSizes[i] = new MediaSize(mediaSizes[i].getX(MediaSize.MM), mediaSizes[i].getY(MediaSize.MM), MediaSize.MM, wms); } @@ -458,7 +458,7 @@ // get from cached mapping of MPAs if (mpaMap != null && (mpaMap.get(msn) != null)) { MediaPrintableArea[] mpaArr = new MediaPrintableArea[1]; - mpaArr[0] = (MediaPrintableArea)mpaMap.get(msn); + mpaArr[0] = mpaMap.get(msn); return mpaArr; } } @@ -478,7 +478,7 @@ } if (mpaMap == null) { - mpaMap = new HashMap(); + mpaMap = new HashMap<>(); } for (int i=0; i < loopNames.length; i++) { @@ -532,10 +532,10 @@ } MediaPrintableArea[] mpaArr = new MediaPrintableArea[1]; // by this time, we've already gotten the desired MPA - mpaArr[0] = (MediaPrintableArea)mpaMap.get(msn); + mpaArr[0] = mpaMap.get(msn); return mpaArr; } else { - mediaPrintables = (MediaPrintableArea[])mpaMap.values().toArray(new MediaPrintableArea[0]); + mediaPrintables = mpaMap.values().toArray(new MediaPrintableArea[0]); mpaListInitialized = true; return mediaPrintables; } @@ -624,7 +624,8 @@ } - private MediaSize[] getMediaSizes(ArrayList idList, int[] media, ArrayList dmPaperNameList) { + private MediaSize[] getMediaSizes(ArrayList idList, int[] media, + ArrayList dmPaperNameList) { if (dmPaperNameList == null) { dmPaperNameList = new ArrayList(); } @@ -641,7 +642,7 @@ } int nMedia = mediaSz.length/2; - ArrayList msList = new ArrayList(); + ArrayList msList = new ArrayList<>(); for (int i = 0; i < nMedia; i++, ms=null) { wid = mediaSz[i*2]/10f; @@ -814,7 +815,7 @@ } else { int nRes = prnRes.length/2; - ArrayList arrList = new ArrayList(); + ArrayList arrList = new ArrayList<>(); PrinterResolution pr; for (int i=0; i T getAttribute(Class category) { @@ -1009,7 +1010,7 @@ } public Class[] getSupportedAttributeCategories() { - ArrayList categList = new ArrayList(otherAttrCats.length+3); + ArrayList> categList = new ArrayList<>(otherAttrCats.length+3); for (int i=0; i < otherAttrCats.length; i++) { categList.add(otherAttrCats[i]); } @@ -1033,7 +1034,7 @@ categList.add(PrinterResolution.class); } - return (Class[])categList.toArray(new Class[categList.size()]); + return categList.toArray(new Class[categList.size()]); } public boolean @@ -1049,7 +1050,7 @@ " is not an Attribute"); } - Class[] classList = getSupportedAttributeCategories(); + Class[] classList = getSupportedAttributeCategories(); for (int i = 0; i < classList.length; i++) { if (category.equals(classList[i])) { return true; @@ -1234,7 +1235,7 @@ } } - private boolean isPSDocAttr(Class category) { + private boolean isPSDocAttr(Class category) { if (category == OrientationRequested.class || category == Copies.class) { return true; } @@ -1475,7 +1476,7 @@ if (attr == null) { throw new NullPointerException("null attribute"); } - Class category = attr.getCategory(); + Class category = attr.getCategory(); if (flavor != null) { if (!isDocFlavorSupported(flavor)) { throw new IllegalArgumentException(flavor + @@ -1700,7 +1701,7 @@ return this.getClass().hashCode()+getName().hashCode(); } - public boolean usesClass(Class c) { + public boolean usesClass(Class c) { return (c == sun.awt.windows.WPrinterJob.class); } @@ -1722,8 +1723,8 @@ @SuppressWarnings("serial") // JDK implementation class class Win32MediaSize extends MediaSizeName { - private static ArrayList winStringTable = new ArrayList(); - private static ArrayList winEnumTable = new ArrayList(); + private static ArrayList winStringTable = new ArrayList<>(); + private static ArrayList winEnumTable = new ArrayList<>(); private static MediaSize[] predefMedia; private int dmPaperID; // driver ID for this paper. @@ -1741,7 +1742,7 @@ public static synchronized Win32MediaSize findMediaName(String name) { int nameIndex = winStringTable.indexOf(name); if (nameIndex != -1) { - return (Win32MediaSize)winEnumTable.get(nameIndex); + return winEnumTable.get(nameIndex); } return null; } @@ -1783,12 +1784,12 @@ protected String[] getStringTable() { String[] nameTable = new String[winStringTable.size()]; - return (String[])winStringTable.toArray(nameTable); + return winStringTable.toArray(nameTable); } protected EnumSyntax[] getEnumValueTable() { MediaSizeName[] enumTable = new MediaSizeName[winEnumTable.size()]; - return (MediaSizeName[])winEnumTable.toArray(enumTable); + return winEnumTable.toArray(enumTable); } } --- old/src/windows/classes/sun/print/Win32PrintServiceLookup.java 2014-06-08 21:28:04.000000000 -0700 +++ new/src/windows/classes/sun/print/Win32PrintServiceLookup.java 2014-06-08 21:28:04.000000000 -0700 @@ -183,6 +183,7 @@ } } + @SuppressWarnings("unchecked") // Cast to Class boolean matchingService(PrintService service, PrintServiceAttributeSet serviceSet) { if (serviceSet != null) { @@ -246,7 +247,7 @@ if (services.length == 0) { return services; } else { - ArrayList matchingServices = new ArrayList(); + ArrayList matchingServices = new ArrayList<>(); for (int i=0; i