<Swing Dev> JDK 9 RFR of JDK-8032733: Fix cast lint warnings in client libraries
Joe Darcy
joe.darcy at oracle.com
Mon Jan 27 19:52:14 UTC 2014
On 01/27/2014 12:04 AM, Alan Bateman wrote:
> On 26/01/2014 09:30, Alan Bateman wrote:
>> The only non-client changes that I see are to Setup.gmk (previously
>> reviewed on build-dev) and Sdp.java.
> I see the others now, just hard to spot in a large mind-numbing patch :-)
>
> All looks good but as I look at this again then I see a few Iterator
> usages where it might be as quick to just replace the iteration with
> for-each. One example is ProxyClient. getGarbageCollectorMXBeans,
> another one might be XOpenTypeView.load. I realize it's going a bit
> beyond eliminating casts but it's an alternative for a couple of these.
>
> -Alan.
Hello,
Alan, I strongly prefer to limit this patch to just cast cleanup.
However, I fully support broader cleanup of this code and other code in
the jdk repo; many of these files haven't been touched in over a decade
and would certainly benefit from some care and attention! I suggest
interested parties do additional cleanup work using the same methodology
Paul Sandoz and Brian Goetz have been using in core libs and langtools:
sending out IDE-driven single-issue changes to review. I think that
keeps the reviews easier and decreases the likelihood of problems being
introduced.
Based on the results of an exploratory jprt job, listed below is the
incremental patch to address the remaining platform-specific cast
warnings in open code that wasn't covered in the original webrev.
Revised full webrev uploaded to
http://cr.openjdk.java.net/~darcy/8032733.1/
There are also a number of closed source files which need to be updated
for a cast-free build to succeed; I'll be requesting internal reviews
for those changes.
Thanks,
-Joe
--- old/src/macosx/classes/apple/security/KeychainStore.java 2014-01-27
11:17:51.000000000 -0800
+++ new/src/macosx/classes/apple/security/KeychainStore.java 2014-01-27
11:17:50.000000000 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights
reserved.
+ * Copyright (c) 2011, 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
@@ -248,7 +248,7 @@
if (((KeyEntry)entry).chain == null) {
return null;
} else {
- return (Certificate[])((KeyEntry)entry).chain.clone();
+ return ((KeyEntry)entry).chain.clone();
}
} else {
return null;
@@ -365,7 +365,7 @@
throw new KeyStoreException("Certificate chain
does not validate");
}
- entry.chain = (Certificate[])chain.clone();
+ entry.chain = chain.clone();
entry.chainRefs = new long[entry.chain.length];
}
@@ -429,7 +429,7 @@
if ((chain != null) &&
(chain.length != 0)) {
- entry.chain = (Certificate[])chain.clone();
+ entry.chain = chain.clone();
entry.chainRefs = new long[entry.chain.length];
}
@@ -1122,7 +1122,7 @@
throw uke;
}
- return ((byte[])key);
+ return key;
}
--- old/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java 2014-01-27
11:17:51.000000000 -0800
+++ new/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java 2014-01-27
11:17:51.000000000 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -640,7 +640,7 @@
if (onEventThread) {
try { EventQueue.invokeAndWait(r);
} catch (java.lang.reflect.InvocationTargetException ite) {
- Throwable te = (Throwable)ite.getTargetException();
+ Throwable te = ite.getTargetException();
if (te instanceof PrinterException) throw
(PrinterException)te;
else te.printStackTrace();
} catch (Exception e) { e.printStackTrace(); }
--- old/src/macosx/classes/sun/font/CFontManager.java 2014-01-27
11:17:52.000000000 -0800
+++ new/src/macosx/classes/sun/font/CFontManager.java 2014-01-27
11:17:51.000000000 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -76,7 +76,7 @@
// This is a way to register any kind of Font2D, not just files
and composites.
public static Font2D[] getGenericFonts() {
- return (Font2D[])genericFonts.values().toArray(new Font2D[0]);
+ return genericFonts.values().toArray(new Font2D[0]);
}
public Font2D registerGenericFont(Font2D f)
@@ -117,7 +117,7 @@
}
return f;
} else {
- return (Font2D)genericFonts.get(fontName);
+ return genericFonts.get(fontName);
}
}
--- old/src/macosx/classes/sun/java2d/CRenderer.java 2014-01-27
11:17:52.000000000 -0800
+++ new/src/macosx/classes/sun/java2d/CRenderer.java 2014-01-27
11:17:52.000000000 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -457,7 +457,7 @@
protected boolean blitImage(SunGraphics2D sg2d, Image img, boolean
fliph, boolean flipv, int sx, int sy, int sw, int sh, int dx, int dy,
int dw, int dh, Color bgColor) {
CPrinterSurfaceData surfaceData =
(CPrinterSurfaceData)sg2d.getSurfaceData();
- OSXOffScreenSurfaceData imgSurfaceData =
(OSXOffScreenSurfaceData)
OSXOffScreenSurfaceData.createNewSurface((BufferedImage)img);
+ OSXOffScreenSurfaceData imgSurfaceData =
OSXOffScreenSurfaceData.createNewSurface((BufferedImage)img);
surfaceData.blitImage(this, sg2d, imgSurfaceData, fliph,
flipv, sx, sy, sw, sh, dx, dy, dw, dh, bgColor);
return true;
}
--- old/src/windows/classes/sun/awt/Win32GraphicsDevice.java 2014-01-27
11:17:53.000000000 -0800
+++ new/src/windows/classes/sun/awt/Win32GraphicsDevice.java 2014-01-27
11:17:52.000000000 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights
reserved.
+ * Copyright (c) 1997, 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
@@ -88,7 +88,7 @@
// is run as an NT service. To prevent the loading of ddraw.dll
// completely, sun.awt.nopixfmt should be set as well. Apps
which use
// OpenGL w/ Java probably don't want to set this.
- String nopixfmt =
(String)java.security.AccessController.doPrivileged(
+ String nopixfmt = java.security.AccessController.doPrivileged(
new
sun.security.action.GetPropertyAction("sun.awt.nopixfmt"));
pfDisabled = (nopixfmt != null);
initIDs();
--- old/src/windows/classes/sun/awt/windows/WPathGraphics.java
2014-01-27 11:17:53.000000000 -0800
+++ new/src/windows/classes/sun/awt/windows/WPathGraphics.java
2014-01-27 11:17:53.000000000 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights
reserved.
+ * Copyright (c) 1998, 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
@@ -94,7 +94,7 @@
private static boolean preferGDITextLayout = false;
static {
String textLayoutStr =
- (String)java.security.AccessController.doPrivileged(
+ java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction(
"sun.java2d.print.enableGDITextLayout"));
--- old/src/windows/classes/sun/io/Win32ErrorMode.java 2014-01-27
11:17:54.000000000 -0800
+++ new/src/windows/classes/sun/io/Win32ErrorMode.java 2014-01-27
11:17:54.000000000 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -67,7 +67,7 @@
*/
public static void initialize() {
if (!sun.misc.VM.isBooted()) {
- String s = (String)
System.getProperty("sun.io.allowCriticalErrorMessageBox");
+ String s =
System.getProperty("sun.io.allowCriticalErrorMessageBox");
if (s == null || s.equals(Boolean.FALSE.toString())) {
long mode = setErrorMode(0);
mode |= SEM_FAILCRITICALERRORS;
--- old/src/windows/classes/sun/print/Win32PrintJob.java 2014-01-27
11:17:54.000000000 -0800
+++ new/src/windows/classes/sun/print/Win32PrintJob.java 2014-01-27
11:17:54.000000000 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2006, 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
@@ -308,12 +308,10 @@
}
}
- PrinterState prnState = (PrinterState)service.getAttribute(
- PrinterState.class);
+ PrinterState prnState = service.getAttribute(PrinterState.class);
if (prnState == PrinterState.STOPPED) {
PrinterStateReasons prnStateReasons =
- (PrinterStateReasons)service.getAttribute(
- PrinterStateReasons.class);
+ service.getAttribute(PrinterStateReasons.class);
if ((prnStateReasons != null) &&
(prnStateReasons.containsKey(PrinterStateReason.SHUTDOWN)))
{
@@ -321,9 +319,8 @@
}
}
- if ((PrinterIsAcceptingJobs)(service.getAttribute(
- PrinterIsAcceptingJobs.class)) ==
- PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS) {
+ if (service.getAttribute(PrinterIsAcceptingJobs.class) ==
+ PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS) {
throw new PrintException("Printer is not accepting job.");
}
--- old/src/windows/classes/sun/print/Win32PrintService.java 2014-01-27
11:17:55.000000000 -0800
+++ new/src/windows/classes/sun/print/Win32PrintService.java 2014-01-27
11:17:55.000000000 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, 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
@@ -506,8 +506,7 @@
}
} else {
// if getting MPA failed, we use MediaSize
- MediaSize ms =
- MediaSize.getMediaSizeForName((MediaSizeName)mediaName);
+ MediaSize ms =
MediaSize.getMediaSizeForName(mediaName);
if (ms != null) {
try {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20140127/e010c0e2/attachment.html>
More information about the swing-dev
mailing list