--- 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"+