--- a/jdk/src/share/classes/sun/print/CustomMediaSizeName.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/share/classes/sun/print/CustomMediaSizeName.java Mon Jun 09 11:47:18 2014 -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<String> customStringTable = new ArrayList<>();
+ private static ArrayList<MediaSizeName> 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);
}
}
--- a/jdk/src/share/classes/sun/print/CustomMediaTray.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/share/classes/sun/print/CustomMediaTray.java Mon Jun 09 11:47:18 2014 -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<String> customStringTable = new ArrayList<>();
+ private static ArrayList<MediaTray> 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);
}
}
--- a/jdk/src/share/classes/sun/print/DialogOwner.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/share/classes/sun/print/DialogOwner.java Mon Jun 09 11:47:18 2014 -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<? extends Attribute> getCategory() {
return DialogOwner.class;
}
--- a/jdk/src/share/classes/sun/print/PSPrinterJob.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/share/classes/sun/print/PSPrinterJob.java Mon Jun 09 11:47:18 2014 -0700
@@ -310,7 +310,7 @@
/**
* A stack that represents the PostScript gstate stack.
*/
- ArrayList mGStateStack = new ArrayList();
+ ArrayList<GState> 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<Object>() {
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<Boolean>() {
+ 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<OutputStream> {
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<Object> {
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<Object>() {
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<Boolean>() {
+ 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);
}
/**
--- a/jdk/src/share/classes/sun/print/PSStreamPrintJob.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/share/classes/sun/print/PSStreamPrintJob.java Mon Jun 09 11:47:18 2014 -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<PrintJobListener> jobListeners;
+ transient private Vector<PrintJobAttributeListener> attrListeners;
+ transient private Vector<PrintJobAttributeSet> 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<? extends Attribute> category;
if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) {
fidelity = true;
--- a/jdk/src/share/classes/sun/print/PSStreamPrintService.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/share/classes/sun/print/PSStreamPrintService.java Mon Jun 09 11:47:18 2014 -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<? extends Attribute> category = attr.getCategory();
if (!isAttributeCategorySupported(category)) {
return false;
}
--- a/jdk/src/share/classes/sun/print/PrintJob2D.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/share/classes/sun/print/PrintJob2D.java Mon Jun 09 11:47:18 2014 -0700
@@ -1011,7 +1011,7 @@
private String qid="noname";
- private ArrayList queue = new ArrayList();
+ private ArrayList<Graphics2D> 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 {
--- a/jdk/src/share/classes/sun/print/PrintJobAttributeException.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/share/classes/sun/print/PrintJobAttributeException.java Mon Jun 09 11:47:18 2014 -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;
}
}
--- a/jdk/src/share/classes/sun/print/PrinterJobWrapper.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/share/classes/sun/print/PrinterJobWrapper.java Mon Jun 09 11:47:18 2014 -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<? extends Attribute> getCategory() {
return PrinterJobWrapper.class;
}
--- a/jdk/src/share/classes/sun/print/RasterPrinterJob.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/share/classes/sun/print/RasterPrinterJob.java Mon Jun 09 11:47:18 2014 -0700
@@ -273,7 +273,7 @@
/**
* List of areas & the graphics state for redrawing
*/
- private ArrayList redrawList = new ArrayList();
+ private ArrayList<GraphicsState> 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<PrintService>() {
+ 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<PrintService>() {
+ 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<PrintService>() {
+ 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<PrintService[]>() {
+ public PrintService[] run() {
PrintService[] services = PrinterJob.lookupPrintServices();
return services;
}
@@ -2131,7 +2127,7 @@
painter.print(pathGraphics, origPage, pageIndex);
for (int i=0;i<redrawList.size();i++) {
- GraphicsState gstate = (GraphicsState)redrawList.get(i);
+ GraphicsState gstate = redrawList.get(i);
pathGraphics.setTransform(initialTx);
((PathGraphics)pathGraphics).redrawRegion(
gstate.region,
--- a/jdk/src/share/classes/sun/print/ServiceDialog.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/share/classes/sun/print/ServiceDialog.java Mon Jun 09 11:47:18 2014 -0700
@@ -395,7 +395,7 @@
* for "Print To File"
*/
private boolean showFileChooser() {
- Class dstCategory = Destination.class;
+ Class<Destination> 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<Object>() {
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<URL>() {
+ 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<String> 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<Destination> dstCategory = Destination.class;
boolean dstSupported = false;
boolean dstSelected = false;
boolean dstAllowed = filePermission ?
@@ -1123,7 +1123,7 @@
}
public void updateInfo() {
- Class prCategory = PageRanges.class;
+ Class<PageRanges> 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<Copies> cpCategory = Copies.class;
+ Class<SheetCollate> scCategory = SheetCollate.class;
boolean cpSupported = false;
scSupported = false;
@@ -1525,7 +1524,7 @@
float bm = bmTmpObj.floatValue();
/* adjust for orientation */
- Class orCategory = OrientationRequested.class;
+ Class<OrientationRequested> 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<MediaPrintableArea> mpaCategory = MediaPrintableArea.class;
MediaPrintableArea mpa;
MediaPrintableArea mpaMax = null;
MediaSize mediaSize = null;
@@ -1671,7 +1670,7 @@
return;
}
- Class mpaCategory = MediaPrintableArea.class;
+ Class<MediaPrintableArea> 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<OrientationRequested> 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<Object> cbSize, cbSource;
+ private Vector<MediaSizeName> sizes = new Vector<>();
+ private Vector<MediaTray> 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<Media> mdCategory = Media.class;
+ Class<SunAlternateMedia> 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<OrientationRequested> orCategory = OrientationRequested.class;
boolean pSupported = false;
boolean lSupported = false;
boolean rpSupported = false;
@@ -2363,7 +2362,7 @@
}
public void updateInfo() {
- Class chCategory = Chromaticity.class;
+ Class<Chromaticity> chCategory = Chromaticity.class;
boolean monoSupported = false;
boolean colorSupported = false;
@@ -2458,7 +2457,7 @@
}
public void updateInfo() {
- Class pqCategory = PrintQuality.class;
+ Class<PrintQuality> pqCategory = PrintQuality.class;
boolean draftSupported = false;
boolean normalSupported = false;
boolean highSupported = false;
@@ -2568,7 +2567,7 @@
}
public void updateInfo() {
- Class sdCategory = Sides.class;
+ Class<Sides> 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<JobSheets> jsCategory = JobSheets.class;
+ Class<JobPriority> jpCategory = JobPriority.class;
+ Class<JobName> jnCategory = JobName.class;
+ Class<RequestingUserName> 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<Icon>() {
+ public Icon run() {
Icon icon = new ImageIcon(imgURL);
return icon;
}
--- a/jdk/src/share/classes/sun/print/ServiceNotifier.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/share/classes/sun/print/ServiceNotifier.java Mon Jun 09 11:47:18 2014 -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<PrintServiceAttributeListener> 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 =
--- a/jdk/src/share/classes/sun/print/SunAlternateMedia.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/share/classes/sun/print/SunAlternateMedia.java Mon Jun 09 11:47:18 2014 -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<? extends Attribute> getCategory() {
return SunAlternateMedia.class;
}
--- a/jdk/src/share/classes/sun/print/SunMinMaxPage.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/share/classes/sun/print/SunMinMaxPage.java Mon Jun 09 11:47:18 2014 -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<? extends PrintRequestAttribute> getCategory() {
return SunMinMaxPage.class;
}
--- a/jdk/src/share/classes/sun/print/SunPageSelection.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/share/classes/sun/print/SunPageSelection.java Mon Jun 09 11:47:18 2014 -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<? extends Attribute> getCategory() {
return SunPageSelection.class;
}
--- a/jdk/src/share/classes/sun/print/SunPrinterJobService.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/share/classes/sun/print/SunPrinterJobService.java Mon Jun 09 11:47:18 2014 -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);
}
--- a/jdk/src/solaris/classes/sun/print/CUPSPrinter.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/solaris/classes/sun/print/CUPSPrinter.java Mon Jun 09 11:47:18 2014 -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<OutputStream>() {
+ public OutputStream run() {
try {
return urlConnection.getOutputStream();
} catch (Exception e) {
@@ -274,10 +274,10 @@
IPPPrintService.OP_CUPS_GET_DEFAULT,
attCl)) {
- HashMap defaultMap = null;
+ HashMap<String, AttributeClass> defaultMap = null;
String[] printerInfo = new String[2];
InputStream is = urlConnection.getInputStream();
- HashMap[] responseMap = IPPPrintService.readIPPResponse(
+ HashMap<String, AttributeClass>[] 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<OutputStream>() {
+ 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<String, AttributeClass>[] responseMap =
IPPPrintService.readIPPResponse(is);
is.close();
@@ -386,9 +384,9 @@
return null;
}
- ArrayList printerNames = new ArrayList();
+ ArrayList<String> 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();
--- a/jdk/src/solaris/classes/sun/print/IPPPrintService.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/solaris/classes/sun/print/IPPPrintService.java Mon Jun 09 11:47:18 2014 -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<String, AttributeClass> 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<Media> sizeList = new ArrayList<>();
+ ArrayList<Media> trayList = new ArrayList<>();
for (int i=0; i<allMedia.length; i++) {
if (allMedia[i] instanceof MediaSizeName) {
sizeList.add(allMedia[i]);
@@ -436,13 +436,11 @@
if (sizeList != null) {
mediaSizeNames = new MediaSizeName[sizeList.size()];
- mediaSizeNames = (MediaSizeName[])sizeList.toArray(
- mediaSizeNames);
+ mediaSizeNames = sizeList.toArray(mediaSizeNames);
}
if (trayList != null) {
mediaTrays = new MediaTray[trayList.size()];
- mediaTrays = (MediaTray[])trayList.toArray(
- mediaTrays);
+ mediaTrays = trayList.toArray(mediaTrays);
}
urlConnection.disconnect();
@@ -503,7 +501,7 @@
flavor.equals(DocFlavor.BYTE_ARRAY.POSTSCRIPT))) {
CopiesSupported cs = new CopiesSupported(1, MAXCOPIES);
AttributeClass attribClass = (getAttMap != null) ?
- (AttributeClass)getAttMap.get(cs.getName()) : null;
+ getAttMap.get(cs.getName()) : null;
if (attribClass != null) {
int[] range = attribClass.getIntRangeValue();
cs = new CopiesSupported(range[0], range[1]);
@@ -545,7 +543,7 @@
return arr;
} else if (category == Finishings.class) {
AttributeClass attribClass = (getAttMap != null) ?
- (AttributeClass)getAttMap.get("finishings-supported")
+ getAttMap.get("finishings-supported")
: null;
if (attribClass != null) {
int[] finArray = attribClass.getArrayOfIntValues();
@@ -648,7 +646,7 @@
}
} else if (category == NumberUp.class) {
AttributeClass attribClass = (getAttMap != null) ?
- (AttributeClass)getAttMap.get("number-up-supported") : null;
+ getAttMap.get("number-up-supported") : null;
if (attribClass != null) {
int[] values = attribClass.getArrayOfIntValues();
if (values != null) {
@@ -673,7 +671,7 @@
OrientationRequested[] orientSup = null;
AttributeClass attribClass = (getAttMap != null) ?
- (AttributeClass)getAttMap.get("orientation-requested-supported")
+ getAttMap.get("orientation-requested-supported")
: null;
if (attribClass != null) {
int[] orientArray = attribClass.getArrayOfIntValues();
@@ -748,7 +746,7 @@
// or printable so if the document is in Landscape, this may
// result in double rotation.
AttributeClass attribClass = (getAttMap != null) ?
- (AttributeClass)getAttMap.get("sides-supported")
+ getAttMap.get("sides-supported")
: null;
if (attribClass != null) {
String[] sidesArray = attribClass.getArrayOfStringValues();
@@ -833,13 +831,13 @@
getAttMap.containsKey("document-format-supported")) {
AttributeClass attribClass =
- (AttributeClass)getAttMap.get("document-format-supported");
+ getAttMap.get("document-format-supported");
if (attribClass != null) {
String mimeType;
boolean psSupported = false;
String[] docFlavors = attribClass.getArrayOfStringValues();
DocFlavor[] flavors;
- HashSet docList = new HashSet();
+ HashSet<Object> 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<Class<?>> 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 extends PrintServiceAttribute>
T getAttribute(Class<T> 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<PrintServiceAttribute> c = (Class<PrintServiceAttribute>)serviceAttributes[i][0];
PrintServiceAttribute psa = getAttribute(c);
if (psa != null) {
attrs.add(psa);
@@ -1279,7 +1275,7 @@
return false;
}
}
- Class category = attr.getCategory();
+ Class<? extends Attribute> 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<OutputStream>() {
+ 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<String, AttributeClass>[] 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<String, AttributeClass>[] 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<HashMap<String, AttributeClass>> respList = new ArrayList<>();
+ HashMap<String, AttributeClass> 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<String, AttributeClass>[] tmp =
+ respList.toArray((HashMap<String, AttributeClass>[])new HashMap[respList.size()]);
+ return tmp;
} else {
debug_println(debugPrefix+
"readIPPResponse client error, IPP status code: 0x"+
--- a/jdk/src/solaris/classes/sun/print/UnixPrintJob.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/solaris/classes/sun/print/UnixPrintJob.java Mon Jun 09 11:47:18 2014 -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<PrintJobListener> jobListeners;
+ transient private Vector<PrintJobAttributeListener> attrListeners;
+ transient private Vector<PrintJobAttributeSet> 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<? extends Attribute> 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<OutputStream> {
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<Object> {
PrintException pex;
private void handleProcessFailure(final Process failedProcess,
--- a/jdk/src/solaris/classes/sun/print/UnixPrintService.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/solaris/classes/sun/print/UnixPrintService.java Mon Jun 09 11:47:18 2014 -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<String> 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 extends PrintServiceAttribute>
T getAttribute(Class<T> 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<? extends Attribute> 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);
}
--- a/jdk/src/solaris/classes/sun/print/UnixPrintServiceLookup.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/solaris/classes/sun/print/UnixPrintServiceLookup.java Mon Jun 09 11:47:18 2014 -0700
@@ -69,7 +69,7 @@
private String defaultPrinter;
private PrintService defaultPrintService;
private PrintService[] printServices; /* includes the default printer */
- private Vector lookupListeners = null;
+ private Vector<BackgroundLookupListener> 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<PrintService> 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<PrintService> printerList = new ArrayList<>();
int defaultIndex = -1;
for (int p=0; p<printers.length; p++) {
if (printers[p] == null) {
@@ -396,8 +396,7 @@
defaultIndex = addPrintServiceToList(printerList, defaultPrintService);
}
- printServices = (PrintService[])printerList.toArray(
- new PrintService[] {});
+ printServices = printerList.toArray(new PrintService[] {});
// swap default with the first in the list
if (defaultIndex > 0) {
@@ -411,9 +410,9 @@
PrintServiceAttributeSet attributes) {
Attribute [] attrs = attributes.toArray();
- Attribute serviceAttr;
for (int i=0; i<attrs.length; i++) {
- serviceAttr
+ @SuppressWarnings("unchecked")
+ Attribute serviceAttr
= service.getAttribute((Class<PrintServiceAttribute>)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<PrintService> 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<PrintService> matchingServices = new ArrayList<>();
for (int i=0; i<services.length; i++) {
try {
if (services[i].
@@ -602,7 +601,7 @@
}
}
services = new PrintService[matchingServices.size()];
- return (PrintService[])matchingServices.toArray(services);
+ return matchingServices.toArray(services);
} else {
// We only need to compare 1 PrintService because all
@@ -704,7 +703,7 @@
listener.notifyServices(printServices);
} else {
if (lookupListeners == null) {
- lookupListeners = new Vector();
+ lookupListeners = new Vector<>();
lookupListeners.add(listener);
Thread lookupThread = new Thread(this);
lookupThread.start();
@@ -733,8 +732,7 @@
synchronized (this) {
BackgroundLookupListener listener;
for (int i=0; i<lookupListeners.size(); i++) {
- listener =
- (BackgroundLookupListener)lookupListeners.elementAt(i);
+ listener = lookupListeners.elementAt(i);
listener.notifyServices(copyOf(services));
}
lookupListeners = null;
@@ -820,7 +818,7 @@
String command = "/usr/bin/lpstat -v|/usr/bin/expand|/usr/bin/cut -f3 -d' ' |/usr/bin/cut -f1 -d':' | /usr/bin/sort";
String [] names = execCmd(command);
- ArrayList printerNames = new ArrayList();
+ ArrayList<String> 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<String> 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<ArrayList<String>>() {
+ public ArrayList<String> 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<String> 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()]);
}
}
--- a/jdk/src/windows/classes/sun/print/Win32MediaTray.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/windows/classes/sun/print/Win32MediaTray.java Mon Jun 09 11:47:18 2014 -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<String> winStringTable = new ArrayList<>();
+ private static ArrayList<Win32MediaTray> winEnumTable = new ArrayList<>();
public int winID;
private Win32MediaTray(int value, int id) {
@@ -97,22 +97,22 @@
}
protected String[] getStringTable() {
- ArrayList completeList = new ArrayList();
+ ArrayList<String> 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<MediaTray> 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);
}
}
--- a/jdk/src/windows/classes/sun/print/Win32PrintJob.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/windows/classes/sun/print/Win32PrintJob.java Mon Jun 09 11:47:18 2014 -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<PrintJobListener> jobListeners;
+ transient private Vector<PrintJobAttributeListener> attrListeners;
+ transient private Vector<PrintJobAttributeSet> 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<? extends Attribute> category;
Attribute [] attrs = reqAttrSet.toArray();
for (int i=0; i<attrs.length; i++) {
Attribute attr = attrs[i];
--- a/jdk/src/windows/classes/sun/print/Win32PrintService.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/windows/classes/sun/print/Win32PrintService.java Mon Jun 09 11:47:18 2014 -0700
@@ -97,7 +97,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,
@@ -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<MediaSizeName, MediaPrintableArea> 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<Integer> 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<MediaSizeName> 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<MediaSizeName> msnList = new ArrayList<>();
ArrayList<Win32MediaSize> trailingWmsList = new ArrayList<Win32MediaSize>();
- 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<String> dmPaperNameList) {
+ private MediaSize[] getMediaSizes(ArrayList<Integer> idList, int[] media,
+ ArrayList<String> dmPaperNameList) {
if (dmPaperNameList == null) {
dmPaperNameList = new ArrayList<String>();
}
@@ -641,7 +642,7 @@
}
int nMedia = mediaSz.length/2;
- ArrayList msList = new ArrayList();
+ ArrayList<MediaSize> 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<PrinterResolution> arrList = new ArrayList<>();
PrinterResolution pr;
for (int i=0; i<nRes; i++) {
@@ -826,8 +827,7 @@
}
}
- printRes = (PrinterResolution[])arrList.toArray(
- new PrinterResolution[arrList.size()]);
+ printRes = arrList.toArray(new PrinterResolution[arrList.size()]);
}
}
return printRes;
@@ -915,6 +915,7 @@
}
}
+ @SuppressWarnings("unchecked")
public <T extends PrintServiceAttribute> T
getAttribute(Class<T> category)
{
@@ -1009,7 +1010,7 @@
}
public Class<?>[] getSupportedAttributeCategories() {
- ArrayList categList = new ArrayList(otherAttrCats.length+3);
+ ArrayList<Class<?>> 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<? extends Attribute> 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<String> winStringTable = new ArrayList<>();
+ private static ArrayList<Win32MediaSize> 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);
}
}
--- a/jdk/src/windows/classes/sun/print/Win32PrintServiceLookup.java Mon Jun 09 20:23:26 2014 +0400
+++ b/jdk/src/windows/classes/sun/print/Win32PrintServiceLookup.java Mon Jun 09 11:47:18 2014 -0700
@@ -183,6 +183,7 @@
}
}
+ @SuppressWarnings("unchecked") // Cast to Class<PrintServiceAttribute>
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<PrintService> matchingServices = new ArrayList<>();
for (int i=0; i<services.length; i++) {
try {
if (services[i].
@@ -257,7 +258,7 @@
}
}
services = new PrintService[matchingServices.size()];
- return (PrintService[])matchingServices.toArray(services);
+ return matchingServices.toArray(services);
}
}