From e26ff7211c1400e149ef258abc4ddf2560564100 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Wed, 11 Jun 2014 14:21:12 +0400 Subject: [PATCH 01/11] 8041644: [OGL] clip is ignored during surface->sw blit Reviewed-by: bae, prr --- .../sun/java2d/opengl/OGLBlitLoops.java | 56 ++++++ .../DrawImage/IncorrectClipSurface2SW.java | 166 ++++++++++++++++++ 2 files changed, 222 insertions(+) create mode 100644 jdk/test/java/awt/image/DrawImage/IncorrectClipSurface2SW.java diff --git a/jdk/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java b/jdk/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java index aeab20823bb..54cfaf1f58f 100644 --- a/jdk/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java +++ b/jdk/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java @@ -510,6 +510,7 @@ class OGLRTTSurfaceToSurfaceTransform extends TransformBlit { final class OGLSurfaceToSwBlit extends Blit { private final int typeval; + private WeakReference srcTmp; // destination will actually be ArgbPre or Argb OGLSurfaceToSwBlit(final SurfaceType dstType,final int typeval) { @@ -519,11 +520,66 @@ final class OGLSurfaceToSwBlit extends Blit { this.typeval = typeval; } + private synchronized void complexClipBlit(SurfaceData src, SurfaceData dst, + Composite comp, Region clip, + int sx, int sy, int dx, int dy, + int w, int h) { + SurfaceData cachedSrc = null; + if (srcTmp != null) { + // use cached intermediate surface, if available + cachedSrc = srcTmp.get(); + } + + // We can convert argb_pre data from OpenGL surface in two places: + // - During OpenGL surface -> SW blit + // - During SW -> SW blit + // The first one is faster when we use opaque OGL surface, because in + // this case we simply skip conversion and use color components as is. + // Because of this we align intermediate buffer type with type of + // destination not source. + final int type = typeval == OGLSurfaceData.PF_INT_ARGB_PRE ? + BufferedImage.TYPE_INT_ARGB_PRE : + BufferedImage.TYPE_INT_ARGB; + + src = convertFrom(this, src, sx, sy, w, h, cachedSrc, type); + + // copy intermediate SW to destination SW using complex clip + final Blit performop = Blit.getFromCache(src.getSurfaceType(), + CompositeType.SrcNoEa, + dst.getSurfaceType()); + performop.Blit(src, dst, comp, clip, 0, 0, dx, dy, w, h); + + if (src != cachedSrc) { + // cache the intermediate surface + srcTmp = new WeakReference<>(src); + } + } + public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) { + if (clip != null) { + clip = clip.getIntersectionXYWH(dx, dy, w, h); + // At the end this method will flush the RenderQueue, we should exit + // from it as soon as possible. + if (clip.isEmpty()) { + return; + } + sx += clip.getLoX() - dx; + sy += clip.getLoY() - dy; + dx = clip.getLoX(); + dy = clip.getLoY(); + w = clip.getWidth(); + h = clip.getHeight(); + + if (!clip.isRectangular()) { + complexClipBlit(src, dst, comp, clip, sx, sy, dx, dy, w, h); + return; + } + } + OGLRenderQueue rq = OGLRenderQueue.getInstance(); rq.lock(); try { diff --git a/jdk/test/java/awt/image/DrawImage/IncorrectClipSurface2SW.java b/jdk/test/java/awt/image/DrawImage/IncorrectClipSurface2SW.java new file mode 100644 index 00000000000..3c972b661ea --- /dev/null +++ b/jdk/test/java/awt/image/DrawImage/IncorrectClipSurface2SW.java @@ -0,0 +1,166 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsEnvironment; +import java.awt.Image; +import java.awt.Rectangle; +import java.awt.Shape; +import java.awt.geom.AffineTransform; +import java.awt.geom.Ellipse2D; +import java.awt.image.BufferedImage; +import java.awt.image.VolatileImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import static java.awt.geom.Rectangle2D.Double; + +/** + * @test + * @bug 8041644 + * @summary Tests drawing volatile image to BI using different clip. + * Results of the blit compatibleImage to BI used for comparison. + * @author Sergey Bylokhov + * @run main/othervm -Dsun.java2d.d3d=false IncorrectClipSurface2SW + */ +public final class IncorrectClipSurface2SW { + + private static int[] SCALES = {1, 2, 4}; + private static int[] SIZES = {127, 3, 2, 1}; + private static final Shape[] SHAPES = {new Rectangle(0, 0, 0, 0), + new Rectangle(0, 0, 1, 1), + new Rectangle(0, 1, 1, 1), + new Rectangle(1, 0, 1, 1), + new Rectangle(1, 1, 1, 1), + + new Ellipse2D.Double(0, 0, 1, 1), + new Ellipse2D.Double(0, 1, 1, 1), + new Ellipse2D.Double(1, 0, 1, 1), + new Ellipse2D.Double(1, 1, 1, 1), + new Ellipse2D.Double(.25, .25, .5, + .5), + + new Double(0, 0, 0.5, 0.5), + new Double(0, 0.5, 0.5, 0.5), + new Double(0.5, 0, 0.5, 0.5), + new Double(0.5, 0.5, 0.5, 0.5), + new Double(0.25, 0.25, 0.5, 0.5), + new Double(0, 0.25, 1, 0.5), + new Double(0.25, 0, 0.5, 1), + + new Double(.10, .10, .20, .20), + new Double(.75, .75, .20, .20), + new Double(.75, .10, .20, .20), + new Double(.10, .75, .20, .20),}; + + public static void main(final String[] args) throws IOException { + GraphicsEnvironment ge = GraphicsEnvironment + .getLocalGraphicsEnvironment(); + GraphicsConfiguration gc = ge.getDefaultScreenDevice() + .getDefaultConfiguration(); + AffineTransform at; + for (final int size : SIZES) { + for (final int scale : SCALES) { + final int sw = size * scale; + at = AffineTransform.getScaleInstance(sw, sw); + for (Shape clip : SHAPES) { + clip = at.createTransformedShape(clip); + for (Shape to : SHAPES) { + to = at.createTransformedShape(to); + // Prepare test images + VolatileImage vi = getVolatileImage(gc, size); + BufferedImage bi = getBufferedImage(sw); + // Prepare gold images + BufferedImage goldvi = getCompatibleImage(gc, size); + BufferedImage goldbi = getBufferedImage(sw); + draw(clip, to, vi, bi, scale); + draw(clip, to, goldvi, goldbi, scale); + validate(bi, goldbi); + } + } + } + } + } + + private static void draw(Shape clip, Shape to, Image vi, BufferedImage bi, + int scale) { + Graphics2D big = bi.createGraphics(); + big.setComposite(AlphaComposite.Src); + big.setClip(clip); + Rectangle toBounds = to.getBounds(); + int x1 = toBounds.x; + + int y1 = toBounds.y; + int x2 = x1 + toBounds.width; + int y2 = y1 + toBounds.height; + big.drawImage(vi, x1, y1, x2, y2, 0, 0, toBounds.width / scale, + toBounds.height / scale, null); + big.dispose(); + vi.flush(); + } + + private static BufferedImage getBufferedImage(int sw) { + BufferedImage bi = new BufferedImage(sw, sw, + BufferedImage.TYPE_INT_ARGB); + Graphics2D g2d = bi.createGraphics(); + g2d.setColor(Color.RED); + g2d.fillRect(0, 0, sw, sw); + return bi; + } + + private static VolatileImage getVolatileImage(GraphicsConfiguration gc, + int size) { + VolatileImage vi = gc.createCompatibleVolatileImage(size, size); + Graphics2D g2d = vi.createGraphics(); + g2d.setColor(Color.GREEN); + g2d.fillRect(0, 0, size, size); + return vi; + } + + private static BufferedImage getCompatibleImage(GraphicsConfiguration gc, + int size) { + BufferedImage image = gc.createCompatibleImage(size, size); + Graphics2D g2d = image.createGraphics(); + g2d.setColor(Color.GREEN); + g2d.fillRect(0, 0, size, size); + return image; + } + + private static void validate(BufferedImage bi, BufferedImage goldbi) + throws IOException { + for (int x = 0; x < bi.getWidth(); ++x) { + for (int y = 0; y < bi.getHeight(); ++y) { + if (goldbi.getRGB(x, y) != bi.getRGB(x, y)) { + ImageIO.write(bi, "png", new File("actual.png")); + ImageIO.write(goldbi, "png", new File("expected.png")); + throw new RuntimeException("Test failed."); + } + } + } + } +} From d1927658370b8568cb0997e37fa3a3d9ba65b486 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Wed, 11 Jun 2014 14:38:50 +0400 Subject: [PATCH 02/11] 8042103: Deserialization of empty java.awt.geom.Path2D will cause an exception Reviewed-by: bae, flar --- .../share/classes/java/awt/geom/Path2D.java | 6 ++- .../java/awt/geom/Path2D/EmptyCapacity.java | 42 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 jdk/test/java/awt/geom/Path2D/EmptyCapacity.java diff --git a/jdk/src/share/classes/java/awt/geom/Path2D.java b/jdk/src/share/classes/java/awt/geom/Path2D.java index 7a401d36cf4..d75adf0cb57 100644 --- a/jdk/src/share/classes/java/awt/geom/Path2D.java +++ b/jdk/src/share/classes/java/awt/geom/Path2D.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -285,6 +285,8 @@ public abstract class Path2D implements Shape, Cloneable { int grow = size; if (grow > EXPAND_MAX) { grow = EXPAND_MAX; + } else if (grow == 0) { + grow = 1; } pointTypes = Arrays.copyOf(pointTypes, size+grow); } @@ -1121,6 +1123,8 @@ public abstract class Path2D implements Shape, Cloneable { int grow = size; if (grow > EXPAND_MAX) { grow = EXPAND_MAX; + } else if (grow == 0) { + grow = 1; } pointTypes = Arrays.copyOf(pointTypes, size+grow); } diff --git a/jdk/test/java/awt/geom/Path2D/EmptyCapacity.java b/jdk/test/java/awt/geom/Path2D/EmptyCapacity.java new file mode 100644 index 00000000000..9f6d9c18dc8 --- /dev/null +++ b/jdk/test/java/awt/geom/Path2D/EmptyCapacity.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.geom.Path2D; + +/** + * @test + * @bug 8042103 + * @summary Path2D.moveTo() should work if empty initial capacity was set. + * @author Sergey Bylokhov + */ +public final class EmptyCapacity { + + public static void main(final String[] args) { + final Path2D path1 = new Path2D.Double(Path2D.WIND_EVEN_ODD, 0); + path1.moveTo(10, 10); + path1.lineTo(20, 20); + final Path2D path2 = new Path2D.Float(Path2D.WIND_EVEN_ODD, 0); + path2.moveTo(10, 10); + path2.lineTo(20, 20); + } +} From 57efe4955f0eb38608ece15c3c08f9259e808666 Mon Sep 17 00:00:00 2001 From: Dmitriy Ermashov Date: Wed, 11 Jun 2014 17:23:56 +0400 Subject: [PATCH 03/11] 8043972: Remove wrong copyright notice in jdk/test/java/awt/Frame/DecoratedExceptions/DecoratedExceptions.java Reviewed-by: anthony --- .../awt/Frame/DecoratedExceptions/DecoratedExceptions.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/jdk/test/java/awt/Frame/DecoratedExceptions/DecoratedExceptions.java b/jdk/test/java/awt/Frame/DecoratedExceptions/DecoratedExceptions.java index b2a0ddc6fdc..8dca632bb57 100644 --- a/jdk/test/java/awt/Frame/DecoratedExceptions/DecoratedExceptions.java +++ b/jdk/test/java/awt/Frame/DecoratedExceptions/DecoratedExceptions.java @@ -20,10 +20,6 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - */ import java.awt.*; From 8538800448bf5872fcdbb86609e2969be41b9ffe Mon Sep 17 00:00:00 2001 From: Henry Jen Date: Thu, 5 Jun 2014 13:59:01 -0700 Subject: [PATCH 04/11] 8044551: Fix raw and unchecked lint warnings in platform-specific sun.awt files 8044396: Fix raw and unchecked lint warnings in platform-specific sun.java2d.* Reviewed-by: darcy, prr --- .../windows/classes/sun/awt/Win32FontManager.java | 10 ++++------ .../windows/classes/sun/awt/Win32GraphicsDevice.java | 8 ++++---- .../classes/sun/awt/shell/Win32ShellFolder2.java | 12 ++++++------ .../sun/awt/shell/Win32ShellFolderManager2.java | 4 ++-- .../sun/awt/windows/WDragSourceContextPeer.java | 6 ++++-- .../classes/sun/awt/windows/WFontConfiguration.java | 12 ++++++------ .../classes/sun/awt/windows/WFontMetrics.java | 4 ++-- .../classes/sun/awt/windows/WInputMethod.java | 9 +++++---- .../windows/classes/sun/awt/windows/WToolkit.java | 1 + .../windows/classes/sun/java2d/d3d/D3DBlitLoops.java | 6 +++--- .../classes/sun/java2d/d3d/D3DGraphicsDevice.java | 5 ++--- .../sun/java2d/windows/GDIWindowSurfaceData.java | 2 +- .../classes/sun/java2d/windows/WindowsFlags.java | 2 +- 13 files changed, 41 insertions(+), 40 deletions(-) diff --git a/jdk/src/windows/classes/sun/awt/Win32FontManager.java b/jdk/src/windows/classes/sun/awt/Win32FontManager.java index 5e925f3ce45..68136e98f4e 100644 --- a/jdk/src/windows/classes/sun/awt/Win32FontManager.java +++ b/jdk/src/windows/classes/sun/awt/Win32FontManager.java @@ -42,8 +42,6 @@ import sun.awt.windows.WFontConfiguration; import sun.font.FontManager; import sun.font.SunFontManager; import sun.font.TrueTypeFont; -import sun.java2d.HeadlessGraphicsEnvironment; -import sun.java2d.SunGraphicsEnvironment; /** * The X11 implementation of {@link FontManager}. @@ -56,7 +54,7 @@ public class Win32FontManager extends SunFontManager { static { - AccessController.doPrivileged(new PrivilegedAction() { + AccessController.doPrivileged(new PrivilegedAction() { public Object run() { String eudcFile = getEUDCFontFile(); @@ -90,7 +88,7 @@ public class Win32FontManager extends SunFontManager { public Win32FontManager() { super(); - AccessController.doPrivileged(new PrivilegedAction() { + AccessController.doPrivileged(new PrivilegedAction() { public Object run() { /* Register the JRE fonts so that the native platform can @@ -227,7 +225,7 @@ public class Win32FontManager extends SunFontManager { final String[] dirs = getPlatformFontDirs(true); if (dirs.length > 1) { String dir = (String) - AccessController.doPrivileged(new PrivilegedAction() { + AccessController.doPrivileged(new PrivilegedAction() { public Object run() { for (int i=0; i() { public Object run() { File f1 = new File(pathName); String[] ls = f1.list(SunFontManager.getInstance(). diff --git a/jdk/src/windows/classes/sun/awt/Win32GraphicsDevice.java b/jdk/src/windows/classes/sun/awt/Win32GraphicsDevice.java index d7cfc58e1e8..8ff76dc7e13 100644 --- a/jdk/src/windows/classes/sun/awt/Win32GraphicsDevice.java +++ b/jdk/src/windows/classes/sun/awt/Win32GraphicsDevice.java @@ -172,7 +172,7 @@ public class Win32GraphicsDevice extends GraphicsDevice implements int max = getMaxConfigs(screen); int defaultPixID = getDefaultPixID(screen); - Vector v = new Vector( max ); + Vector v = new Vector<>( max ); if (defaultPixID == 0) { // Workaround for failing GDI calls defaultConfig = Win32GraphicsConfig.getConfig(this, @@ -437,7 +437,7 @@ public class Win32GraphicsDevice extends GraphicsDevice implements protected native void configDisplayMode(int screen, WindowPeer w, int width, int height, int bitDepth, int refreshRate); - protected native void enumDisplayModes(int screen, ArrayList modes); + protected native void enumDisplayModes(int screen, ArrayList modes); @Override public synchronized DisplayMode getDisplayMode() { @@ -447,12 +447,12 @@ public class Win32GraphicsDevice extends GraphicsDevice implements @Override public synchronized DisplayMode[] getDisplayModes() { - ArrayList modes = new ArrayList(); + ArrayList modes = new ArrayList<>(); enumDisplayModes(screen, modes); int listSize = modes.size(); DisplayMode[] retArray = new DisplayMode[listSize]; for (int i = 0; i < listSize; i++) { - retArray[i] = (DisplayMode)modes.get(i); + retArray[i] = modes.get(i); } return retArray; } diff --git a/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java b/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java index 696633917a2..42975132b15 100644 --- a/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java +++ b/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java @@ -894,10 +894,10 @@ final class Win32ShellFolder2 extends ShellFolder { // Icons - private static Map smallSystemImages = new HashMap(); - private static Map largeSystemImages = new HashMap(); - private static Map smallLinkedSystemImages = new HashMap(); - private static Map largeLinkedSystemImages = new HashMap(); + private static Map smallSystemImages = new HashMap<>(); + private static Map largeSystemImages = new HashMap<>(); + private static Map smallLinkedSystemImages = new HashMap<>(); + private static Map largeLinkedSystemImages = new HashMap<>(); // NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details private static native long getIShellIcon(long pIShellFolder); @@ -970,13 +970,13 @@ final class Win32ShellFolder2 extends ShellFolder { // These are cached per type (using the index in the system image list) int index = getIconIndex(parentIShellIcon, relativePIDL); if (index > 0) { - Map imageCache; + Map imageCache; if (isLink()) { imageCache = getLargeIcon ? largeLinkedSystemImages : smallLinkedSystemImages; } else { imageCache = getLargeIcon ? largeSystemImages : smallSystemImages; } - newIcon = (Image) imageCache.get(Integer.valueOf(index)); + newIcon = imageCache.get(Integer.valueOf(index)); if (newIcon == null) { long hIcon = getIcon(getAbsolutePath(), getLargeIcon); newIcon = makeIcon(hIcon, getLargeIcon); diff --git a/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java b/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java index 269eff2e421..426a0eb77ff 100644 --- a/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java +++ b/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java @@ -414,14 +414,14 @@ public class Win32ShellFolderManager2 extends ShellFolderManager { return false; } - private static List topFolderList = null; + private static List topFolderList = null; static int compareShellFolders(Win32ShellFolder2 sf1, Win32ShellFolder2 sf2) { boolean special1 = sf1.isSpecial(); boolean special2 = sf2.isSpecial(); if (special1 || special2) { if (topFolderList == null) { - ArrayList tmpTopFolderList = new ArrayList(); + ArrayList tmpTopFolderList = new ArrayList<>(); tmpTopFolderList.add(Win32ShellFolderManager2.getPersonal()); tmpTopFolderList.add(Win32ShellFolderManager2.getDesktop()); tmpTopFolderList.add(Win32ShellFolderManager2.getDrives()); diff --git a/jdk/src/windows/classes/sun/awt/windows/WDragSourceContextPeer.java b/jdk/src/windows/classes/sun/awt/windows/WDragSourceContextPeer.java index 36280f2e571..360d842834b 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WDragSourceContextPeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WDragSourceContextPeer.java @@ -29,6 +29,7 @@ import java.awt.Component; import java.awt.Cursor; import java.awt.Image; import java.awt.Point; +import java.awt.datatransfer.DataFlavor; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; @@ -76,8 +77,9 @@ final class WDragSourceContextPeer extends SunDragSourceContextPeer { return theInstance; } + @Override protected void startDrag(Transferable trans, - long[] formats, Map formatMap) { + long[] formats, Map formatMap) { long nativeCtxtLocal = 0; @@ -153,7 +155,7 @@ final class WDragSourceContextPeer extends SunDragSourceContextPeer { InputEvent nativeTrigger, int actions, long[] formats, - Map formatMap); + Map formatMap); /** * downcall into native code diff --git a/jdk/src/windows/classes/sun/awt/windows/WFontConfiguration.java b/jdk/src/windows/classes/sun/awt/windows/WFontConfiguration.java index 7315b97db77..4cd88216bca 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WFontConfiguration.java +++ b/jdk/src/windows/classes/sun/awt/windows/WFontConfiguration.java @@ -53,7 +53,7 @@ public final class WFontConfiguration extends FontConfiguration { @Override protected void initReorderMap() { if (encoding.equalsIgnoreCase("windows-31j")) { - localeMap = new Hashtable(); + localeMap = new Hashtable<>(); /* Substitute Mincho for Gothic in this one case. * Note the windows fontconfig files already contain the mapping: * filename.MS_Mincho=MSMINCHO.TTC @@ -67,7 +67,7 @@ public final class WFontConfiguration extends FontConfiguration { localeMap.put("dialoginput.italic.japanese", "MS Mincho"); localeMap.put("dialoginput.bolditalic.japanese", "MS Mincho"); } - reorderMap = new HashMap(); + reorderMap = new HashMap<>(); reorderMap.put("UTF-8.hi", "devanagari"); reorderMap.put("windows-1255", "hebrew"); reorderMap.put("x-windows-874", "thai"); @@ -118,7 +118,7 @@ public final class WFontConfiguration extends FontConfiguration { @Override protected String makeAWTFontName(String platformFontName, String characterSubsetName) { - String windowsCharset = (String) subsetCharsetMap.get(characterSubsetName); + String windowsCharset = subsetCharsetMap.get(characterSubsetName); if (windowsCharset == null) { windowsCharset = "DEFAULT_CHARSET"; } @@ -127,7 +127,7 @@ public final class WFontConfiguration extends FontConfiguration { @Override protected String getEncoding(String awtFontName, String characterSubsetName) { - String encoding = (String) subsetEncodingMap.get(characterSubsetName); + String encoding = subsetEncodingMap.get(characterSubsetName); if (encoding == null) { encoding = "default"; } @@ -174,8 +174,8 @@ public final class WFontConfiguration extends FontConfiguration { return fontName; } - private static HashMap subsetCharsetMap = new HashMap(); - private static HashMap subsetEncodingMap = new HashMap(); + private static HashMap subsetCharsetMap = new HashMap<>(); + private static HashMap subsetEncodingMap = new HashMap<>(); private static String textInputCharset; private void initTables(String defaultEncoding) { diff --git a/jdk/src/windows/classes/sun/awt/windows/WFontMetrics.java b/jdk/src/windows/classes/sun/awt/windows/WFontMetrics.java index 01dae69c91a..8d8a9515df7 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WFontMetrics.java +++ b/jdk/src/windows/classes/sun/awt/windows/WFontMetrics.java @@ -199,10 +199,10 @@ final class WFontMetrics extends FontMetrics { native void init(); - static Hashtable table = new Hashtable(); + static Hashtable table = new Hashtable<>(); static FontMetrics getFontMetrics(Font font) { - FontMetrics fm = (FontMetrics)table.get(font); + FontMetrics fm = table.get(font); if (fm == null) { table.put(font, fm = new WFontMetrics(font)); } diff --git a/jdk/src/windows/classes/sun/awt/windows/WInputMethod.java b/jdk/src/windows/classes/sun/awt/windows/WInputMethod.java index de7c478c087..1d3c413dfc3 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WInputMethod.java +++ b/jdk/src/windows/classes/sun/awt/windows/WInputMethod.java @@ -86,26 +86,27 @@ final class WInputMethod extends InputMethodAdapter // Initialize highlight mapping table static { + @SuppressWarnings({"rawtypes", "unchecked"}) Map styles[] = new Map[4]; HashMap map; // UNSELECTED_RAW_TEXT_HIGHLIGHT - map = new HashMap(1); + map = new HashMap<>(1); map.put(TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.UNDERLINE_LOW_DOTTED); styles[0] = Collections.unmodifiableMap(map); // SELECTED_RAW_TEXT_HIGHLIGHT - map = new HashMap(1); + map = new HashMap<>(1); map.put(TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.UNDERLINE_LOW_GRAY); styles[1] = Collections.unmodifiableMap(map); // UNSELECTED_CONVERTED_TEXT_HIGHLIGHT - map = new HashMap(1); + map = new HashMap<>(1); map.put(TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.UNDERLINE_LOW_DOTTED); styles[2] = Collections.unmodifiableMap(map); // SELECTED_CONVERTED_TEXT_HIGHLIGHT - map = new HashMap(4); + map = new HashMap<>(4); Color navyBlue = new Color(0, 0, 128); map.put(TextAttribute.FOREGROUND, navyBlue); map.put(TextAttribute.BACKGROUND, Color.white); diff --git a/jdk/src/windows/classes/sun/awt/windows/WToolkit.java b/jdk/src/windows/classes/sun/awt/windows/WToolkit.java index 2a27c2df9cc..d33b991d7f8 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WToolkit.java +++ b/jdk/src/windows/classes/sun/awt/windows/WToolkit.java @@ -843,6 +843,7 @@ public final class WToolkit extends SunToolkit implements Runnable { } @Override + @SuppressWarnings("unchecked") public T createDragGestureRecognizer(Class abstractRecognizerClass, DragSource ds, Component c, int srcActions, diff --git a/jdk/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java b/jdk/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java index b7b09e7b6dd..94495da083e 100644 --- a/jdk/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java +++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java @@ -717,7 +717,7 @@ class D3DTextureToSurfaceTransform extends TransformBlit { class D3DGeneralBlit extends Blit { private Blit performop; - private WeakReference srcTmp; + private WeakReference srcTmp; D3DGeneralBlit(SurfaceType dstType, CompositeType compType, @@ -739,7 +739,7 @@ class D3DGeneralBlit extends Blit { SurfaceData cachedSrc = null; if (srcTmp != null) { // use cached intermediate surface, if available - cachedSrc = (SurfaceData)srcTmp.get(); + cachedSrc = srcTmp.get(); } // convert source to IntArgbPre @@ -752,7 +752,7 @@ class D3DGeneralBlit extends Blit { if (src != cachedSrc) { // cache the intermediate surface - srcTmp = new WeakReference(src); + srcTmp = new WeakReference<>(src); } } } diff --git a/jdk/src/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java b/jdk/src/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java index bf6134648c3..d30f1720bfc 100644 --- a/jdk/src/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java +++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java @@ -41,7 +41,6 @@ import sun.awt.Win32GraphicsDevice; import sun.awt.windows.WWindowPeer; import sun.java2d.pipe.hw.ContextCapabilities; import sun.java2d.windows.WindowsFlags; -import static sun.java2d.pipe.BufferedOpCodes.*; import static sun.java2d.d3d.D3DContext.D3DContextCaps.*; import sun.java2d.d3d.D3DContext.D3DContextCaps; @@ -383,9 +382,9 @@ public class D3DGraphicsDevice extends Win32GraphicsDevice { } private static native void enumDisplayModesNative(int screen, - ArrayList modes); + ArrayList modes); @Override - protected void enumDisplayModes(final int screen, final ArrayList modes) { + protected void enumDisplayModes(final int screen, final ArrayList modes) { D3DRenderQueue rq = D3DRenderQueue.getInstance(); rq.lock(); try { diff --git a/jdk/src/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java b/jdk/src/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java index 49d9261bbd3..04ba1464001 100644 --- a/jdk/src/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java +++ b/jdk/src/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java @@ -75,7 +75,7 @@ public class GDIWindowSurfaceData extends SurfaceData { public static final SurfaceType ThreeByteBgrGdi = SurfaceType.ThreeByteBgr.deriveSubType(DESC_GDI); - private static native void initIDs(Class xorComp); + private static native void initIDs(Class xorComp); static { initIDs(XORComposite.class); diff --git a/jdk/src/windows/classes/sun/java2d/windows/WindowsFlags.java b/jdk/src/windows/classes/sun/java2d/windows/WindowsFlags.java index a6d265fd3f8..b8fc7510471 100644 --- a/jdk/src/windows/classes/sun/java2d/windows/WindowsFlags.java +++ b/jdk/src/windows/classes/sun/java2d/windows/WindowsFlags.java @@ -201,7 +201,7 @@ public class WindowsFlags { private static void initJavaFlags() { java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() + new java.security.PrivilegedAction() { public Object run() { magPresent = getBooleanProp( From f829432469a75b7aa115a853a6a1ea021dd3f492 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Wed, 11 Jun 2014 13:25:15 -0700 Subject: [PATCH 05/11] 8043549: Fix raw and unchecked lint warnings in javax.swing.text.* Reviewed-by: prr --- .../javax/swing/text/AbstractDocument.java | 8 +++--- .../javax/swing/text/AbstractWriter.java | 2 +- .../javax/swing/text/DateFormatter.java | 6 ++-- .../javax/swing/text/DefaultFormatter.java | 4 +-- .../swing/text/DefaultStyledDocument.java | 13 +++++---- .../javax/swing/text/ElementIterator.java | 2 +- .../classes/javax/swing/text/GapContent.java | 16 ++++++----- .../classes/javax/swing/text/GlyphView.java | 2 +- .../swing/text/InternationalFormatter.java | 28 ++++++++++--------- .../javax/swing/text/JTextComponent.java | 1 + .../javax/swing/text/NumberFormatter.java | 11 ++++---- .../javax/swing/text/ParagraphView.java | 2 +- .../javax/swing/text/SimpleAttributeSet.java | 11 ++++---- .../javax/swing/text/StringContent.java | 12 ++++---- .../javax/swing/text/StyleContext.java | 14 +++++----- .../classes/javax/swing/text/TextAction.java | 4 +-- .../javax/swing/text/html/AccessibleHTML.java | 2 +- .../classes/javax/swing/text/html/CSS.java | 6 ++-- .../javax/swing/text/html/FormView.java | 21 +++++++++----- .../javax/swing/text/html/HTMLDocument.java | 22 ++++++++++----- .../javax/swing/text/html/HTMLEditorKit.java | 4 +-- .../javax/swing/text/html/HTMLWriter.java | 18 ++++++------ .../javax/swing/text/html/ImageView.java | 7 +++-- .../swing/text/html/MinimalHTMLWriter.java | 4 +-- .../swing/text/html/MuxingAttributeSet.java | 8 +++--- .../javax/swing/text/html/ObjectView.java | 8 +++--- .../swing/text/html/OptionListModel.java | 5 ++-- .../javax/swing/text/html/StyleSheet.java | 21 +++++++++----- .../javax/swing/text/html/parser/DTD.java | 1 + .../swing/text/rtf/MockAttributeSet.java | 4 +-- .../javax/swing/text/rtf/RTFGenerator.java | 10 +++---- .../javax/swing/text/rtf/RTFReader.java | 26 ++++++++++------- 32 files changed, 172 insertions(+), 131 deletions(-) diff --git a/jdk/src/share/classes/javax/swing/text/AbstractDocument.java b/jdk/src/share/classes/javax/swing/text/AbstractDocument.java index a7a109f8c91..e42d549791a 100644 --- a/jdk/src/share/classes/javax/swing/text/AbstractDocument.java +++ b/jdk/src/share/classes/javax/swing/text/AbstractDocument.java @@ -1809,7 +1809,7 @@ public abstract class AbstractDocument implements Document, Serializable { if (getAttributeCount() > 0) { out.println(""); // dump the attributes - Enumeration names = attributes.getAttributeNames(); + Enumeration names = attributes.getAttributeNames(); while (names.hasMoreElements()) { Object name = names.nextElement(); indent(out, indentAmount + 1); @@ -2193,7 +2193,7 @@ public abstract class AbstractDocument implements Document, Serializable { * Enumeration. * @return the children of the receiver as an Enumeration */ - public abstract Enumeration children(); + public abstract Enumeration children(); // --- serialization --------------------------------------------- @@ -2456,7 +2456,7 @@ public abstract class AbstractDocument implements Document, Serializable { * Enumeration. * @return the children of the receiver */ - public Enumeration children() { + public Enumeration children() { if(nchildren == 0) return null; @@ -2610,7 +2610,7 @@ public abstract class AbstractDocument implements Document, Serializable { * Enumeration. * @return the children of the receiver */ - public Enumeration children() { + public Enumeration children() { return null; } diff --git a/jdk/src/share/classes/javax/swing/text/AbstractWriter.java b/jdk/src/share/classes/javax/swing/text/AbstractWriter.java index f2f7f746ee4..cfe619b801f 100644 --- a/jdk/src/share/classes/javax/swing/text/AbstractWriter.java +++ b/jdk/src/share/classes/javax/swing/text/AbstractWriter.java @@ -668,7 +668,7 @@ public abstract class AbstractWriter { */ protected void writeAttributes(AttributeSet attr) throws IOException { - Enumeration names = attr.getAttributeNames(); + Enumeration names = attr.getAttributeNames(); while (names.hasMoreElements()) { Object name = names.nextElement(); write(" " + name + "=" + attr.getAttribute(name)); diff --git a/jdk/src/share/classes/javax/swing/text/DateFormatter.java b/jdk/src/share/classes/javax/swing/text/DateFormatter.java index e935053bfc8..b82788fb6a2 100644 --- a/jdk/src/share/classes/javax/swing/text/DateFormatter.java +++ b/jdk/src/share/classes/javax/swing/text/DateFormatter.java @@ -108,8 +108,8 @@ public class DateFormatter extends InternationalFormatter { /** * Returns the field that will be adjusted by adjustValue. */ - Object getAdjustField(int start, Map attributes) { - Iterator attrs = attributes.keySet().iterator(); + Object getAdjustField(int start, Map attributes) { + Iterator attrs = attributes.keySet().iterator(); while (attrs.hasNext()) { Object key = attrs.next(); @@ -127,7 +127,7 @@ public class DateFormatter extends InternationalFormatter { * Adjusts the Date if FieldPosition identifies a known calendar * field. */ - Object adjustValue(Object value, Map attributes, Object key, + Object adjustValue(Object value, Map attributes, Object key, int direction) throws BadLocationException, ParseException { if (key != null) { diff --git a/jdk/src/share/classes/javax/swing/text/DefaultFormatter.java b/jdk/src/share/classes/javax/swing/text/DefaultFormatter.java index 0a4df2c0a1d..ee9cda6e85f 100644 --- a/jdk/src/share/classes/javax/swing/text/DefaultFormatter.java +++ b/jdk/src/share/classes/javax/swing/text/DefaultFormatter.java @@ -246,12 +246,12 @@ public class DefaultFormatter extends JFormattedTextField.AbstractFormatter } } if (vc != null) { - Constructor cons; + Constructor cons; try { ReflectUtil.checkPackageAccess(vc); SwingUtilities2.checkAccess(vc.getModifiers()); - cons = vc.getConstructor(new Class[]{String.class}); + cons = vc.getConstructor(new Class[]{String.class}); } catch (NoSuchMethodException nsme) { cons = null; diff --git a/jdk/src/share/classes/javax/swing/text/DefaultStyledDocument.java b/jdk/src/share/classes/javax/swing/text/DefaultStyledDocument.java index a5ce0633f74..78788cbfad1 100644 --- a/jdk/src/share/classes/javax/swing/text/DefaultStyledDocument.java +++ b/jdk/src/share/classes/javax/swing/text/DefaultStyledDocument.java @@ -1048,8 +1048,9 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc styleChangeListener = createStyleChangeListener(); } if (styleChangeListener != null && styles != null) { - Enumeration styleNames = styles.getStyleNames(); - Vector v = (Vector)listeningStyles.clone(); + Enumeration styleNames = styles.getStyleNames(); + @SuppressWarnings("unchecked") + Vector