--- a/jdk/.hgtags Thu May 22 20:24:42 2014 +0000
+++ b/jdk/.hgtags Fri May 23 23:55:14 2014 +0000
@@ -256,3 +256,4 @@
47feccd164b7187a0147693a922ee47c6629643c jdk9-b11
83d9bc20973de232cae45b139fdff8a4549c130f jdk9-b12
c7c8002d02721e02131d104549ebeb8b379fb8d2 jdk9-b13
+5c7a17a81afd0906b53ee31d95a3211c96ff6b25 jdk9-b14
--- a/jdk/make/CopyIntoClasses.gmk Thu May 22 20:24:42 2014 +0000
+++ b/jdk/make/CopyIntoClasses.gmk Fri May 23 23:55:14 2014 +0000
@@ -111,20 +111,8 @@
ALL_META-INF_DIRS := $(ALL_META-INF_DIRS_share)
endif
-ifndef OPENJDK
- ALL_META-INF_DIRS += $(JDK_TOPDIR)/src/closed/share/classes/sun/java2d/cmm/kcms/META-INF
-endif
-
SRC_SERVICES_FILES := $(wildcard $(addsuffix /services/*, $(ALL_META-INF_DIRS)))
-ifdef OPENJDK
- SRC_SERVICES_FILES := $(filter-out %sun/dc/META-INF/services/sun.java2d.pipe.RenderingEngine, $(SRC_SERVICES_FILES))
- SRC_SERVICES_FILES := $(filter-out %sun/java2d/cmm/kcms/META-INF/services/sun.java2d.cmm.CMMServiceProvider, $(SRC_SERVICES_FILES))
-else
- SRC_SERVICES_FILES := $(filter-out %sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine, $(SRC_SERVICES_FILES))
- SRC_SERVICES_FILES := $(filter-out %sun/java2d/cmm/lcms/META-INF/services/sun.java2d.cmm.CMMServiceProvider, $(SRC_SERVICES_FILES))
-endif
-
# The number of services files are relatively few. If the increase in numbers, then
# we have to use ListPathsSafelyNow here.
# Change $(JDK_TOPDIR)/src/.../META-INF/services/yyyy into $(JDK_OUTPUTDIR)/classes/META-INF/services/yyyy
--- a/jdk/make/lib/Awt2dLibraries.gmk Thu May 22 20:24:42 2014 +0000
+++ b/jdk/make/lib/Awt2dLibraries.gmk Fri May 23 23:55:14 2014 +0000
@@ -318,7 +318,7 @@
endif
ifeq ($(OPENJDK_TARGET_OS), macosx)
- LIBAWT_FILES += awt_LoadLibrary.c img_colors.c
+ LIBAWT_FILES += awt_LoadLibrary.c
LIBAWT_CFLAGS += -F/System/Library/Frameworks/JavaVM.framework/Frameworks
endif
@@ -606,7 +606,6 @@
debug_mem.c \
debug_trace.c \
debug_util.c \
- awt_Plugin.c \
gnome_interface.c \
gtk2_interface.c \
swing_GTKEngine.c \
@@ -657,17 +656,34 @@
##########################################################################################
+LIBLCMS_DIR := $(JDK_TOPDIR)/src/share/native/sun/java2d/cmm/lcms
+
+ifeq ($(USE_EXTERNAL_LCMS), true)
+ # If we're using an external library, we'll just need the wrapper part.
+ # By including it explicitely, all other files will be excluded.
+ BUILD_LIBLCMS_INCLUDE_FILES := LCMS.c
+ BUILD_LIBLCMS_HEADERS :=
+else
+ BUILD_LIBLCMS_INCLUDE_FILES :=
+ # If we're using the bundled library, we'll need to include it in the
+ # include path explicitly. Otherwise the system headers will be used.
+ BUILD_LIBLCMS_HEADERS := -I$(LIBLCMS_DIR)
+endif
+
# TODO: Update awt lib path when awt is converted
$(eval $(call SetupNativeCompilation,BUILD_LIBLCMS, \
LIBRARY := lcms, \
OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
- SRC := $(JDK_TOPDIR)/src/share/native/sun/java2d/cmm/lcms, \
+ SRC := $(LIBLCMS_DIR), \
+ INCLUDE_FILES := $(BUILD_LIBLCMS_INCLUDE_FILES), \
LANG := C, \
OPTIMIZATION := HIGHEST, \
CFLAGS := $(filter-out -xc99=%none, $(CFLAGS_JDKLIB)) \
$(SHARED_LIBRARY_FLAGS) \
-I$(JDK_TOPDIR)/src/share/native/sun/java2d \
- -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug, \
+ -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
+ $(BUILD_LIBLCMS_HEADERS) \
+ $(LCMS_CFLAGS), \
CFLAGS_solaris := -xc99=no_lib, \
CFLAGS_windows := -DCMS_IS_WINDOWS_, \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/liblcms/mapfile-vers, \
@@ -675,10 +691,10 @@
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_solaris := /usr/lib$(OPENJDK_TARGET_CPU_ISADIR)/libm.so.2, \
LDFLAGS_windows := $(WIN_AWT_LIB) $(WIN_JAVA_LIB), \
- LDFLAGS_SUFFIX_solaris := -lawt -ljava -ljvm -lc, \
- LDFLAGS_SUFFIX_macosx := $(LIBM) -lawt -ljava -ljvm, \
- LDFLAGS_SUFFIX_linux := -lm -lawt -ljava -ljvm, \
- LDFLAGS_SUFFIX_aix := -lm -lawt -ljava -ljvm,\
+ LDFLAGS_SUFFIX_solaris := -lawt -ljava -ljvm -lc $(LCMS_LIBS), \
+ LDFLAGS_SUFFIX_macosx := $(LIBM) -lawt -ljava -ljvm $(LCMS_LIBS), \
+ LDFLAGS_SUFFIX_linux := -lm -lawt -ljava -ljvm $(LCMS_LIBS), \
+ LDFLAGS_SUFFIX_aix := -lm -lawt -ljava -ljvm $(LCMS_LIBS),\
VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
RC_FLAGS := $(RC_FLAGS) \
-D "JDK_FNAME=lcms.dll" \
--- a/jdk/make/mapfiles/libawt/mapfile-mawt-vers Thu May 22 20:24:42 2014 +0000
+++ b/jdk/make/mapfiles/libawt/mapfile-mawt-vers Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2001, 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
@@ -249,11 +249,6 @@
Java_sun_awt_motif_XsessionWMcommand;
Java_sun_awt_motif_XsessionWMcommand_New;
- # Java Plugin
- getAwtLockFunctions;
- getAwtData;
- getAwtDisplay;
-
# libfontmanager entry points
AWTIsHeadless;
AWTCountFonts;
--- a/jdk/make/mapfiles/libawt/mapfile-vers Thu May 22 20:24:42 2014 +0000
+++ b/jdk/make/mapfiles/libawt/mapfile-vers Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2013, 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
@@ -173,13 +173,6 @@
Java_sun_awt_motif_XsessionWMcommand;
Java_sun_awt_motif_XsessionWMcommand_New;
- # Java Plugin
- # This is in awt_LoadLibrary.c and falls through to libmawt.
- # Evidently plugin needs this for backward compatability.
- getAwtLockFunctions;
- getAwtData;
- getAwtDisplay;
-
# libfontmanager entry points
AWTIsHeadless;
GrPrim_Sg2dGetCompInfo;
--- a/jdk/make/mapfiles/libawt/mapfile-vers-linux Thu May 22 20:24:42 2014 +0000
+++ b/jdk/make/mapfiles/libawt/mapfile-vers-linux Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 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
@@ -152,13 +152,6 @@
# Evidently CDE needs this for backward compatability.
Java_sun_awt_motif_XsessionWMcommand;
- # Java Plugin
- # This is in awt_LoadLibrary.c and falls through to libmawt.
- # Evidently plugin needs this for backward compatability.
- getAwtLockFunctions;
- getAwtData;
- getAwtDisplay;
-
# libfontmanager entry points
AWTIsHeadless;
GrPrim_Sg2dGetCompInfo;
@@ -283,11 +276,6 @@
# CDE private entry point
Java_sun_awt_motif_XsessionWMcommand;
- # Java Plugin
- getAwtLockFunctions;
- getAwtData;
- getAwtDisplay;
-
# libfontmanager entry points
AWTIsHeadless;
AWTCountFonts;
--- a/jdk/make/mapfiles/libawt_xawt/mapfile-vers Thu May 22 20:24:42 2014 +0000
+++ b/jdk/make/mapfiles/libawt_xawt/mapfile-vers Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 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
@@ -449,12 +449,6 @@
awt_Lock;
awt_GetComponent;
- # Java Plugin
- # This is in awt_LoadLibrary.c and falls through to libmawt.
- # Evidently plugin needs this for backward compatability.
- getAwtLockFunctions;
- getAwtData;
- getAwtDisplay;
#XAWT entry point for CDE
Java_sun_awt_motif_XsessionWMcommand;
Java_sun_awt_motif_XsessionWMcommand_New;
--- a/jdk/make/mapfiles/libjpeg/mapfile-vers-closed Thu May 22 20:24:42 2014 +0000
+++ b/jdk/make/mapfiles/libjpeg/mapfile-vers-closed Fri May 23 23:55:14 2014 +0000
@@ -31,10 +31,6 @@
Java_sun_awt_image_JPEGImageDecoder_initIDs;
Java_sun_awt_image_JPEGImageDecoder_readImage;
- Java_sun_awt_image_codec_JPEGImageDecoderImpl_initDecoder;
- Java_sun_awt_image_codec_JPEGImageDecoderImpl_readJPEGStream;
- Java_sun_awt_image_codec_JPEGImageEncoderImpl_initEncoder;
- Java_sun_awt_image_codec_JPEGImageEncoderImpl_writeJPEGStream;
Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_initReaderIDs;
Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_initJPEGImageReader;
--- a/jdk/make/profile-rtjar-includes.txt Thu May 22 20:24:42 2014 +0000
+++ b/jdk/make/profile-rtjar-includes.txt Fri May 23 23:55:14 2014 +0000
@@ -239,6 +239,4 @@
META-INF/services/javax.sound.sampled.spi.AudioFileReader \
META-INF/services/javax.sound.sampled.spi.AudioFileWriter \
META-INF/services/javax.sound.sampled.spi.FormatConversionProvider \
- META-INF/services/javax.sound.sampled.spi.MixerProvider \
- META-INF/services/sun.java2d.cmm.PCMM \
- META-INF/services/sun.java2d.pipe.RenderingEngine
+ META-INF/services/javax.sound.sampled.spi.MixerProvider
--- a/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxPopup.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxPopup.java Fri May 23 23:55:14 2014 +0000
@@ -121,6 +121,10 @@
public void show() {
final int startItemCount = comboBox.getItemCount();
+ if (startItemCount == 0) {
+ return;
+ }
+
final Rectangle popupBounds = adjustPopupAndGetBounds();
if (popupBounds == null) return; // null means don't show
--- a/jdk/src/macosx/classes/com/apple/laf/AquaImageFactory.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/classes/com/apple/laf/AquaImageFactory.java Fri May 23 23:55:14 2014 +0000
@@ -46,10 +46,8 @@
import com.apple.laf.AquaIcon.SystemIcon;
import com.apple.laf.AquaUtils.RecyclableObject;
import com.apple.laf.AquaUtils.RecyclableSingleton;
-import java.util.Arrays;
-import java.util.List;
-import sun.awt.image.MultiResolutionBufferedImage;
import sun.awt.image.MultiResolutionImage;
+import sun.awt.image.MultiResolutionCachedImage;
public class AquaImageFactory {
public static IconUIResource getConfirmImageIcon() {
@@ -57,7 +55,7 @@
return new IconUIResource(new AquaIcon.CachingScalingIcon(kAlertIconSize, kAlertIconSize) {
Image createImage() {
- return getThisApplicationsIcon(kAlertIconSize, kAlertIconSize);
+ return getGenericJavaIcon();
}
});
}
@@ -83,24 +81,6 @@
return getAppIconCompositedOn(lockIcon);
}
- static Image getThisApplicationsIcon(final int width, final int height) {
- final String path = getPathToThisApplication();
-
- if (path == null) {
- return getGenericJavaIcon();
- }
-
- if (path.endsWith("/Home/bin")) {
- return getGenericJavaIcon();
- }
-
- if (path.startsWith("/usr/bin")) {
- return getGenericJavaIcon();
- }
-
- return AquaUtils.getCImageCreator().createImageOfFile(path, height, width);
- }
-
static Image getGenericJavaIcon() {
return java.security.AccessController.doPrivileged(new PrivilegedAction<Image>() {
public Image run() {
@@ -125,9 +105,9 @@
private static final int kAlertIconSize = 64;
static IconUIResource getAppIconCompositedOn(final Image background) {
- if (background instanceof MultiResolutionBufferedImage) {
+ if (background instanceof MultiResolutionCachedImage) {
int width = background.getWidth(null);
- Image mrIconImage = ((MultiResolutionBufferedImage) background).map(
+ Image mrIconImage = ((MultiResolutionCachedImage) background).map(
rv -> getAppIconImageCompositedOn(rv, rv.getWidth(null) / width));
return new IconUIResource(new ImageIcon(mrIconImage));
}
@@ -144,7 +124,7 @@
final Icon smallAppIconScaled = new AquaIcon.CachingScalingIcon(
kAlertSubIconSize, kAlertSubIconSize) {
Image createImage() {
- return getThisApplicationsIcon(kAlertSubIconSize, kAlertSubIconSize);
+ return getGenericJavaIcon();
}
};
@@ -306,21 +286,7 @@
private static Image getNSIcon(String imageName) {
Image icon = Toolkit.getDefaultToolkit()
.getImage("NSImage://" + imageName);
-
- if (icon instanceof MultiResolutionImage) {
- return icon;
- }
-
- int w = icon.getWidth(null);
- int h = icon.getHeight(null);
-
- Dimension[] sizes = new Dimension[]{
- new Dimension(w, h), new Dimension(2 * w, 2 * h)
- };
-
- return new MultiResolutionBufferedImage(icon, sizes, (width, height) ->
- AquaUtils.getCImageCreator().createImageFromName(
- imageName, width, height));
+ return icon;
}
public static class NineSliceMetrics {
@@ -530,4 +496,4 @@
public static Color getSelectionInactiveForegroundColorUIResource() {
return new SystemColorProxy(LWCToolkit.getAppleColor(LWCToolkit.INACTIVE_SELECTION_FOREGROUND_COLOR));
}
-}
\ No newline at end of file
+}
--- a/jdk/src/macosx/classes/com/apple/laf/AquaPainter.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/classes/com/apple/laf/AquaPainter.java Fri May 23 23:55:14 2014 +0000
@@ -174,11 +174,7 @@
bounds, controlState);
Image img = cache.getImage(key);
if (img == null) {
-
- Image baseImage = createImage(imgX, imgY, imgW, imgH, bounds,
- control, controlState);
-
- img = new MultiResolutionBufferedImage(baseImage,
+ img = new MultiResolutionCachedImage(imgW, imgH,
(rvWidth, rvHeight) -> createImage(imgX, imgY,
rvWidth, rvHeight, bounds, control, controlState));
--- a/jdk/src/macosx/classes/com/apple/laf/AquaUtils.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/classes/com/apple/laf/AquaUtils.java Fri May 23 23:55:14 2014 +0000
@@ -48,7 +48,7 @@
import sun.swing.SwingUtilities2;
import com.apple.laf.AquaImageFactory.SlicedImageControl;
-import sun.awt.image.MultiResolutionBufferedImage;
+import sun.awt.image.MultiResolutionCachedImage;
final class AquaUtils {
@@ -124,8 +124,8 @@
static Image generateLightenedImage(final Image image, final int percent) {
final GrayFilter filter = new GrayFilter(true, percent);
- return (image instanceof MultiResolutionBufferedImage)
- ? ((MultiResolutionBufferedImage) image).map(
+ return (image instanceof MultiResolutionCachedImage)
+ ? ((MultiResolutionCachedImage) image).map(
rv -> generateLightenedImage(rv, filter))
: generateLightenedImage(image, filter);
}
--- a/jdk/src/macosx/classes/sun/font/CFontManager.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/classes/sun/font/CFontManager.java Fri May 23 23:55:14 2014 +0000
@@ -40,7 +40,7 @@
import sun.awt.FontConfiguration;
import sun.awt.HeadlessToolkit;
-import sun.misc.ThreadGroupUtils;
+import sun.awt.util.ThreadGroupUtils;
import sun.lwawt.macosx.*;
public class CFontManager extends SunFontManager {
--- a/jdk/src/macosx/classes/sun/lwawt/LWChoicePeer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/classes/sun/lwawt/LWChoicePeer.java Fri May 23 23:55:14 2014 +0000
@@ -171,7 +171,9 @@
SwingUtilities.invokeLater(() -> {
JPopupMenu popupMenu = getPopupMenu();
// Need to override the invoker for proper grab handling
- if (popupMenu != null && popupMenu.getInvoker() != getTarget()) {
+ if (popupMenu != null
+ && popupMenu.isShowing()
+ && popupMenu.getInvoker() != getTarget()) {
// The popup is now visible with correct location
// Save it and restore after toggling visibility and changing invoker
Point loc = popupMenu.getLocationOnScreen();
--- a/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java Fri May 23 23:55:14 2014 +0000
@@ -63,8 +63,6 @@
import javax.swing.SwingUtilities;
import javax.swing.RepaintManager;
-import sun.lwawt.macosx.CDropTarget;
-
import com.sun.java.swing.SwingUtilities3;
public abstract class LWComponentPeer<T extends Component, D extends JComponent>
@@ -137,7 +135,7 @@
private final Object dropTargetLock = new Object();
private int fNumDropTargets = 0;
- private CDropTarget fDropTarget = null;
+ private PlatformDropTarget fDropTarget = null;
private final PlatformComponent platformComponent;
@@ -1063,11 +1061,11 @@
// if it's the first (or last) one for the component. Otherwise this call is a no-op.
if (++fNumDropTargets == 1) {
// Having a non-null drop target would be an error but let's check just in case:
- if (fDropTarget != null)
- System.err.println("CComponent.addDropTarget(): current drop target is non-null.");
-
+ if (fDropTarget != null) {
+ throw new IllegalStateException("Current drop target is not null");
+ }
// Create a new drop target:
- fDropTarget = CDropTarget.createDropTarget(dt, target, this);
+ fDropTarget = LWToolkit.getLWToolkit().createDropTarget(dt, target, this);
}
}
}
--- a/jdk/src/macosx/classes/sun/lwawt/LWToolkit.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/classes/sun/lwawt/LWToolkit.java Fri May 23 23:55:14 2014 +0000
@@ -28,6 +28,7 @@
import java.awt.*;
import java.awt.List;
import java.awt.datatransfer.*;
+import java.awt.dnd.DropTarget;
import java.awt.image.*;
import java.awt.peer.*;
import java.security.*;
@@ -35,7 +36,7 @@
import sun.awt.*;
import sun.print.*;
-import sun.misc.ThreadGroupUtils;
+import sun.awt.util.ThreadGroupUtils;
import static sun.lwawt.LWWindowPeer.PeerType;
@@ -440,6 +441,10 @@
protected abstract FileDialogPeer createFileDialogPeer(FileDialog target);
+ protected abstract PlatformDropTarget createDropTarget(DropTarget dropTarget,
+ Component component,
+ LWComponentPeer<?, ?> peer);
+
// ---- UTILITY METHODS ---- //
/*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/macosx/classes/sun/lwawt/PlatformDropTarget.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,34 @@
+/*
+ * 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+
+package sun.lwawt;
+
+public interface PlatformDropTarget {
+
+ /**
+ * Release native dragging destination, if any
+ */
+ void dispose();
+}
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java Fri May 23 23:55:14 2014 +0000
@@ -31,6 +31,7 @@
import java.io.*;
import java.net.URL;
+import java.nio.charset.Charset;
import java.text.Normalizer;
import java.text.Normalizer.Form;
import java.util.*;
@@ -126,7 +127,7 @@
if (format == CF_URL && URL.class.equals(flavor.getRepresentationClass()))
{
- String charset = getDefaultTextCharset();
+ String charset = Charset.defaultCharset().name();
if (transferable != null && transferable.isDataFlavorSupported(javaTextEncodingFlavor)) {
try {
charset = new String((byte[])transferable.getTransferData(javaTextEncodingFlavor), "UTF-8");
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CDropTarget.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CDropTarget.java Fri May 23 23:55:14 2014 +0000
@@ -25,54 +25,37 @@
package sun.lwawt.macosx;
-import java.awt.Component;
-import java.awt.peer.ComponentPeer;
+import sun.lwawt.LWComponentPeer;
+import sun.lwawt.PlatformDropTarget;
+
+import java.awt.*;
import java.awt.dnd.DropTarget;
-import sun.lwawt.LWComponentPeer;
-import sun.lwawt.PlatformWindow;
-
-public final class CDropTarget {
-
- Component fComponent;
- ComponentPeer fPeer;
- DropTarget fDropTarget;
- private long fNativeDropTarget;
+final class CDropTarget implements PlatformDropTarget {
+ private long fNativeDropTarget;
- public static CDropTarget createDropTarget(DropTarget dropTarget, Component component, ComponentPeer peer) {
- return new CDropTarget(dropTarget, component, peer);
- }
-
- private CDropTarget(DropTarget dropTarget, Component component, ComponentPeer peer) {
- super();
-
- fDropTarget = dropTarget;
- fComponent = component;
- fPeer = peer;
-
- long nativePeer = CPlatformWindow.getNativeViewPtr(((LWComponentPeer) peer).getPlatformWindow());
+ CDropTarget(DropTarget dropTarget, Component component, LWComponentPeer<?, ?> peer) {
+ long nativePeer = CPlatformWindow.getNativeViewPtr(peer.getPlatformWindow());
if (nativePeer == 0L) return; // Unsupported for a window without a native view (plugin)
// Create native dragging destination:
- fNativeDropTarget = this.createNativeDropTarget(dropTarget, component, peer, nativePeer);
+ fNativeDropTarget = createNativeDropTarget(dropTarget, component, nativePeer);
if (fNativeDropTarget == 0) {
throw new IllegalStateException("CDropTarget.createNativeDropTarget() failed.");
}
}
- public DropTarget getDropTarget() {
- return fDropTarget;
- }
-
+ @Override
public void dispose() {
- // Release native dragging destination, if any:
if (fNativeDropTarget != 0) {
- this.releaseNativeDropTarget(fNativeDropTarget);
+ releaseNativeDropTarget(fNativeDropTarget);
fNativeDropTarget = 0;
}
}
- protected native long createNativeDropTarget(DropTarget dropTarget, Component component, ComponentPeer peer, long nativePeer);
+ protected native long createNativeDropTarget(DropTarget dropTarget,
+ Component component,
+ long nativePeer);
protected native void releaseNativeDropTarget(long nativeDropTarget);
}
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CImage.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CImage.java Fri May 23 23:55:14 2014 +0000
@@ -32,7 +32,7 @@
import java.util.Arrays;
import java.util.List;
import sun.awt.image.MultiResolutionImage;
-import sun.awt.image.MultiResolutionBufferedImage;
+import sun.awt.image.MultiResolutionCachedImage;
import sun.awt.image.SunWritableRaster;
@@ -62,41 +62,41 @@
// This is used to create a CImage with an NSImage pointer. It MUST be a CFRetained
// NSImage, and the CImage takes ownership of the non-GC retain. If callers need the
// NSImage themselves, they MUST call retain on the NSImage themselves.
- public BufferedImage createImageUsingNativeSize(final long image) {
+ public Image createImageUsingNativeSize(final long image) {
if (image == 0) return null;
final Dimension2D size = nativeGetNSImageSize(image);
- return createBufferedImage(image, size.getWidth(), size.getHeight());
+ return createImage(image, size.getWidth(), size.getHeight());
}
// the width and height passed in as a parameter could differ than the width and the height of the NSImage (image), in that case, the image will be scaled
- BufferedImage createBufferedImage(long image, double width, double height) {
+ Image createImage(long image, double width, double height) {
if (image == 0) throw new Error("Unable to instantiate CImage with null native image reference.");
return createImageWithSize(image, width, height);
}
- public BufferedImage createImageWithSize(final long image, final double width, final double height) {
+ public Image createImageWithSize(final long image, final double width, final double height) {
final CImage img = new CImage(image);
img.resize(width, height);
return img.toImage();
}
// This is used to create a CImage that represents the icon of the given file.
- public BufferedImage createImageOfFile(final String file, final int width, final int height) {
- return createBufferedImage(nativeCreateNSImageOfFileFromLaunchServices(file), width, height);
+ public Image createImageOfFile(final String file, final int width, final int height) {
+ return createImage(nativeCreateNSImageOfFileFromLaunchServices(file), width, height);
}
- public BufferedImage createImageFromFile(final String file, final double width, final double height) {
+ public Image createImageFromFile(final String file, final double width, final double height) {
final long image = nativeCreateNSImageFromFileContents(file);
nativeSetNSImageSize(image, width, height);
- return createBufferedImage(image, width, height);
+ return createImage(image, width, height);
}
- public BufferedImage createSystemImageFromSelector(final String iconSelector, final int width, final int height) {
- return createBufferedImage(nativeCreateNSImageFromIconSelector(getSelectorAsInt(iconSelector)), width, height);
+ public Image createSystemImageFromSelector(final String iconSelector, final int width, final int height) {
+ return createImage(nativeCreateNSImageFromIconSelector(getSelectorAsInt(iconSelector)), width, height);
}
public Image createImageFromName(final String name, final int width, final int height) {
- return createBufferedImage(nativeCreateNSImageFromImageName(name), width, height);
+ return createImage(nativeCreateNSImageFromImageName(name), width, height);
}
public Image createImageFromName(final String name) {
@@ -232,7 +232,7 @@
}
/** @return A MultiResolution image created from nsImagePtr, or null. */
- private BufferedImage toImage() {
+ private Image toImage() {
if (ptr == 0) return null;
final Dimension2D size = nativeGetNSImageSize(ptr);
@@ -243,11 +243,11 @@
= nativeGetNSImageRepresentationSizes(ptr,
size.getWidth(), size.getHeight());
- BufferedImage baseImage = toImage(w, h, w, h);
-
- return sizes == null || sizes.length < 2 ? baseImage
- : new MultiResolutionBufferedImage(baseImage, sizes,
- (width, height) -> toImage(w, h, width, height));
+ return sizes == null || sizes.length < 2 ?
+ new MultiResolutionCachedImage(w, h, (width, height)
+ -> toImage(w, h, width, height))
+ : new MultiResolutionCachedImage(w, h, sizes, (width, height)
+ -> toImage(w, h, width, height));
}
private BufferedImage toImage(int srcWidth, int srcHeight, int dstWidth, int dstHeight) {
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CWarningWindow.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CWarningWindow.java Fri May 23 23:55:14 2014 +0000
@@ -309,6 +309,10 @@
@Override
public void dispose() {
cancelTasks();
+ SurfaceData surfaceData = contentView.getSurfaceData();
+ if (surfaceData != null) {
+ surfaceData.invalidate();
+ }
super.dispose();
}
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Fri May 23 23:55:14 2014 +0000
@@ -611,19 +611,20 @@
}
/**
- * Kicks an event over to the appropriate eventqueue and waits for it to
+ * Kicks an event over to the appropriate event queue and waits for it to
* finish To avoid deadlocking, we manually run the NSRunLoop while waiting
* Any selector invoked using ThreadUtilities performOnMainThread will be
* processed in doAWTRunLoop The InvocationEvent will call
* LWCToolkit.stopAWTRunLoop() when finished, which will stop our manual
- * runloop Does not dispatch native events while in the loop
+ * run loop. Does not dispatch native events while in the loop
*/
public static void invokeAndWait(Runnable runnable, Component component)
throws InvocationTargetException {
- final long mediator = createAWTRunLoopMediator();
+ Objects.requireNonNull(component, "Null component provided to invokeAndWait");
+ long mediator = createAWTRunLoopMediator();
InvocationEvent invocationEvent =
- new InvocationEvent(component != null ? component : Toolkit.getDefaultToolkit(),
+ new InvocationEvent(component,
runnable,
() -> {
if (mediator != 0) {
@@ -632,49 +633,42 @@
},
true);
- if (component != null) {
- AppContext appContext = SunToolkit.targetToAppContext(component);
- SunToolkit.postEvent(appContext, invocationEvent);
-
- // 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock
- SunToolkit.flushPendingEvents(appContext);
- } else {
- // This should be the equivalent to EventQueue.invokeAndWait
- ((LWCToolkit)Toolkit.getDefaultToolkit()).getSystemEventQueueForInvokeAndWait().postEvent(invocationEvent);
- }
-
+ AppContext appContext = SunToolkit.targetToAppContext(component);
+ SunToolkit.postEvent(appContext, invocationEvent);
+ // 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock
+ SunToolkit.flushPendingEvents(appContext);
doAWTRunLoop(mediator, false);
- Throwable eventException = invocationEvent.getException();
- if (eventException != null) {
- if (eventException instanceof UndeclaredThrowableException) {
- eventException = ((UndeclaredThrowableException)eventException).getUndeclaredThrowable();
- }
- throw new InvocationTargetException(eventException);
- }
+ checkException(invocationEvent);
}
public static void invokeLater(Runnable event, Component component)
throws InvocationTargetException {
- final InvocationEvent invocationEvent =
- new InvocationEvent(component != null ? component : Toolkit.getDefaultToolkit(), event);
+ Objects.requireNonNull(component, "Null component provided to invokeLater");
+
+ InvocationEvent invocationEvent = new InvocationEvent(component, event);
- if (component != null) {
- final AppContext appContext = SunToolkit.targetToAppContext(component);
- SunToolkit.postEvent(appContext, invocationEvent);
+ AppContext appContext = SunToolkit.targetToAppContext(component);
+ SunToolkit.postEvent(SunToolkit.targetToAppContext(component), invocationEvent);
+ // 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock
+ SunToolkit.flushPendingEvents(appContext);
- // 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock
- SunToolkit.flushPendingEvents(appContext);
- } else {
- // This should be the equivalent to EventQueue.invokeAndWait
- ((LWCToolkit)Toolkit.getDefaultToolkit()).getSystemEventQueueForInvokeAndWait().postEvent(invocationEvent);
- }
+ checkException(invocationEvent);
+ }
- final Throwable eventException = invocationEvent.getException();
+ /**
+ * Checks if exception occurred while {@code InvocationEvent} was processed and rethrows it as
+ * an {@code InvocationTargetException}
+ *
+ * @param event the event to check for an exception
+ * @throws InvocationTargetException if exception occurred when event was processed
+ */
+ private static void checkException(InvocationEvent event) throws InvocationTargetException {
+ Throwable eventException = event.getException();
if (eventException == null) return;
if (eventException instanceof UndeclaredThrowableException) {
- throw new InvocationTargetException(((UndeclaredThrowableException)eventException).getUndeclaredThrowable());
+ eventException = ((UndeclaredThrowableException)eventException).getUndeclaredThrowable();
}
throw new InvocationTargetException(eventException);
}
@@ -686,11 +680,6 @@
*/
native static void performOnMainThreadAfterDelay(Runnable r, long delay);
- // This exists purely to get around permissions issues with getSystemEventQueueImpl
- EventQueue getSystemEventQueueForInvokeAndWait() {
- return getSystemEventQueueImpl();
- }
-
// DnD support
@Override
@@ -712,7 +701,14 @@
return (T)dgr;
}
-// InputMethodSupport Method
+ @Override
+ protected PlatformDropTarget createDropTarget(DropTarget dropTarget,
+ Component component,
+ LWComponentPeer<?, ?> peer) {
+ return new CDropTarget(dropTarget, component, peer);
+ }
+
+ // InputMethodSupport Method
/**
* Returns the default keyboard locale of the underlying operating system
*/
--- a/jdk/src/macosx/native/sun/awt/AWTView.m Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/native/sun/awt/AWTView.m Fri May 23 23:55:14 2014 +0000
@@ -27,6 +27,7 @@
#import <JavaNativeFoundation/JavaNativeFoundation.h>
#import <JavaRuntimeSupport/JavaRuntimeSupport.h>
+#import "jni_util.h"
#import "ThreadUtilities.h"
#import "AWTView.h"
@@ -391,14 +392,12 @@
(jint)absP.x, (jint)absP.y,
[event deltaY],
[event deltaX]);
- if (jEvent == nil) {
- // Unable to create event by some reason.
- return;
- }
+ CHECK_NULL(jEvent);
static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
static JNF_MEMBER_CACHE(jm_deliverMouseEvent, jc_PlatformView, "deliverMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V");
JNFCallVoidMethod(env, m_cPlatformView, jm_deliverMouseEvent, jEvent);
+ (*env)->DeleteLocalRef(env, jEvent);
}
- (void) resetTrackingArea {
@@ -447,20 +446,22 @@
static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent");
static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IISLjava/lang/String;)V");
- jobject jevent = JNFNewObject(env, jctor_NSEvent,
+ jobject jEvent = JNFNewObject(env, jctor_NSEvent,
[event type],
[event modifierFlags],
[event keyCode],
characters);
+ CHECK_NULL(jEvent);
static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
static JNF_MEMBER_CACHE(jm_deliverKeyEvent, jc_PlatformView,
"deliverKeyEvent", "(Lsun/lwawt/macosx/NSEvent;)V");
- JNFCallVoidMethod(env, m_cPlatformView, jm_deliverKeyEvent, jevent);
+ JNFCallVoidMethod(env, m_cPlatformView, jm_deliverKeyEvent, jEvent);
if (characters != NULL) {
(*env)->DeleteLocalRef(env, characters);
}
+ (*env)->DeleteLocalRef(env, jEvent);
}
-(void) deliverResize: (NSRect) rect {
--- a/jdk/src/macosx/native/sun/awt/AWTWindow.m Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/native/sun/awt/AWTWindow.m Fri May 23 23:55:14 2014 +0000
@@ -261,7 +261,8 @@
// returns id for the topmost window under mouse
+ (NSInteger) getTopmostWindowUnderMouseID {
-
+ NSInteger result = -1;
+
NSRect screenRect = [[NSScreen mainScreen] frame];
NSPoint nsMouseLocation = [NSEvent mouseLocation];
CGPoint cgMouseLocation = CGPointMake(nsMouseLocation.x, screenRect.size.height - nsMouseLocation.y);
@@ -274,11 +275,13 @@
CGRect rect;
CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)[window objectForKey:(id)kCGWindowBounds], &rect);
if (CGRectContainsPoint(rect, cgMouseLocation)) {
- return [[window objectForKey:(id)kCGWindowNumber] integerValue];
+ result = [[window objectForKey:(id)kCGWindowNumber] integerValue];
+ break;
}
}
}
- return -1;
+ [windows release];
+ return result;
}
// checks that this window is under the mouse cursor and this point is not overlapped by others windows
--- a/jdk/src/macosx/native/sun/awt/CDropTarget.h Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/native/sun/awt/CDropTarget.h Fri May 23 23:55:14 2014 +0000
@@ -48,7 +48,7 @@
+ (CDropTarget *) currentDropTarget;
// Common methods:
-- (id)init:(jobject)dropTarget component:(jobject)jcomponent peer:(jobject)jpeer control:(id)control;
+- (id)init:(jobject)dropTarget component:(jobject)jcomponent control:(id)control;
- (void)controlModelControlValid;
- (void)removeFromView:(JNIEnv *)env;
--- a/jdk/src/macosx/native/sun/awt/CDropTarget.m Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/native/sun/awt/CDropTarget.m Fri May 23 23:55:14 2014 +0000
@@ -65,7 +65,7 @@
return sCurrentDropTarget;
}
-- (id)init:(jobject)jdropTarget component:(jobject)jcomponent peer:(jobject)jpeer control:(id)control
+- (id)init:(jobject)jdropTarget component:(jobject)jcomponent control:(id)control
{
self = [super init];
DLog2(@"[CDropTarget init]: %@\n", self);
@@ -714,13 +714,13 @@
* Signature: (Ljava/awt/dnd/DropTarget;Ljava/awt/Component;Ljava/awt/peer/ComponentPeer;J)J
*/
JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CDropTarget_createNativeDropTarget
- (JNIEnv *env, jobject jthis, jobject jdroptarget, jobject jcomponent, jobject jpeer, jlong jnativepeer)
+ (JNIEnv *env, jobject jthis, jobject jdroptarget, jobject jcomponent, jlong jnativepeer)
{
CDropTarget* dropTarget = nil;
JNF_COCOA_ENTER(env);
id controlObj = (id) jlong_to_ptr(jnativepeer);
- dropTarget = [[CDropTarget alloc] init:jdroptarget component:jcomponent peer:jpeer control:controlObj];
+ dropTarget = [[CDropTarget alloc] init:jdroptarget component:jcomponent control:controlObj];
JNF_COCOA_EXIT(env);
return ptr_to_jlong(dropTarget);
--- a/jdk/src/macosx/native/sun/awt/CGraphicsDevice.m Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/native/sun/awt/CGraphicsDevice.m Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -66,7 +66,8 @@
CFArrayAppendValue(validModes, cRef);
}
}
-
+ CFRelease(allModes);
+
CGDisplayModeRef currentMode = CGDisplayCopyDisplayMode(displayID);
BOOL containsCurrentMode = NO;
@@ -81,6 +82,7 @@
if (!containsCurrentMode) {
CFArrayAppendValue(validModes, currentMode);
}
+ CGDisplayModeRelease(currentMode);
return validModes;
}
@@ -154,14 +156,12 @@
Java_sun_awt_CGraphicsDevice_nativeGetXResolution
(JNIEnv *env, jclass class, jint displayID)
{
- // TODO: this is the physically correct answer, but we probably want
- // to use NSScreen API instead...
+ // CGDisplayScreenSize can return 0 if displayID is invalid
CGSize size = CGDisplayScreenSize(displayID);
CGRect rect = CGDisplayBounds(displayID);
// 1 inch == 25.4 mm
jfloat inches = size.width / 25.4f;
- jfloat dpi = rect.size.width / inches;
- return dpi;
+ return inches > 0 ? rect.size.width / inches : 72;
}
/*
@@ -173,14 +173,12 @@
Java_sun_awt_CGraphicsDevice_nativeGetYResolution
(JNIEnv *env, jclass class, jint displayID)
{
- // TODO: this is the physically correct answer, but we probably want
- // to use NSScreen API instead...
+ // CGDisplayScreenSize can return 0 if displayID is invalid
CGSize size = CGDisplayScreenSize(displayID);
CGRect rect = CGDisplayBounds(displayID);
// 1 inch == 25.4 mm
jfloat inches = size.height / 25.4f;
- jfloat dpi = rect.size.height / inches;
- return dpi;
+ return inches > 0 ? rect.size.height / inches : 72;
}
/*
@@ -235,17 +233,19 @@
{
JNF_COCOA_ENTER(env);
CFArrayRef allModes = getAllValidDisplayModes(displayID);
-
CGDisplayModeRef closestMatch = getBestModeForParameters(allModes, (int)w, (int)h, (int)bpp, (int)refrate);
+
__block CGError retCode = kCGErrorSuccess;
if (closestMatch != NULL) {
- [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+ CGDisplayModeRetain(closestMatch);
+ [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
CGDisplayConfigRef config;
retCode = CGBeginDisplayConfiguration(&config);
if (retCode == kCGErrorSuccess) {
CGConfigureDisplayWithDisplayMode(config, displayID, closestMatch, NULL);
retCode = CGCompleteDisplayConfiguration(config, kCGConfigureForAppOnly);
}
+ CGDisplayModeRelease(closestMatch);
}];
} else {
[JNFException raise:env as:kIllegalArgumentException reason:"Invalid display mode"];
@@ -253,8 +253,7 @@
if (retCode != kCGErrorSuccess){
[JNFException raise:env as:kIllegalArgumentException reason:"Unable to set display mode!"];
- }
-
+ }
CFRelease(allModes);
JNF_COCOA_EXIT(env);
}
--- a/jdk/src/macosx/native/sun/awt/CImage.m Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/native/sun/awt/CImage.m Fri May 23 23:55:14 2014 +0000
@@ -76,17 +76,17 @@
static NSBitmapImageRep* CImage_CreateImageRep(JNIEnv *env, jintArray buffer, jint width, jint height)
{
- NSBitmapImageRep* imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
- pixelsWide:width
- pixelsHigh:height
- bitsPerSample:8
- samplesPerPixel:4
- hasAlpha:YES
- isPlanar:NO
- colorSpaceName:NSDeviceRGBColorSpace
- bitmapFormat:NSAlphaFirstBitmapFormat
- bytesPerRow:width*4 // TODO: use explicit scanStride
- bitsPerPixel:32];
+ NSBitmapImageRep* imageRep = [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
+ pixelsWide:width
+ pixelsHigh:height
+ bitsPerSample:8
+ samplesPerPixel:4
+ hasAlpha:YES
+ isPlanar:NO
+ colorSpaceName:NSDeviceRGBColorSpace
+ bitmapFormat:NSAlphaFirstBitmapFormat
+ bytesPerRow:width*4 // TODO: use explicit scanStride
+ bitsPerPixel:32] autorelease];
jint *imgData = (jint *)[imageRep bitmapData];
if (imgData == NULL) return 0L;
@@ -115,9 +115,8 @@
NSBitmapImageRep* imageRep = CImage_CreateImageRep(env, buffer, width, height);
if (imageRep) {
- NSImage *nsImage = [[[NSImage alloc] initWithSize:NSMakeSize(width, height)] retain];
+ NSImage *nsImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
[nsImage addRepresentation:imageRep];
- [imageRep release];
result = ptr_to_jlong(nsImage);
}
@@ -160,7 +159,7 @@
(*env)->ReleaseIntArrayElements(env, widths, ws, JNI_ABORT);
}
if ([reps count]) {
- NSImage *nsImage = [[[NSImage alloc] initWithSize:NSMakeSize(0, 0)] retain];
+ NSImage *nsImage = [[NSImage alloc] initWithSize:NSMakeSize(0, 0)];
[nsImage addRepresentations: reps];
result = ptr_to_jlong(nsImage);
}
@@ -184,7 +183,7 @@
IconRef iconRef;
if (noErr == GetIconRef(kOnSystemDisk, kSystemIconsCreator, selector, &iconRef)) {
- image = [[[NSImage alloc] initWithIconRef:iconRef] retain];
+ image = [[NSImage alloc] initWithIconRef:iconRef];
ReleaseIconRef(iconRef);
}
@@ -206,7 +205,7 @@
JNF_COCOA_ENTER(env);
NSString *path = JNFNormalizedNSStringForPath(env, file);
- image = [[[NSImage alloc] initByReferencingFile:path] retain];
+ image = [[NSImage alloc] initByReferencingFile:path];
JNF_COCOA_EXIT(env);
@@ -435,7 +434,7 @@
JNF_COCOA_ENTER(env);
- NSBitmapImageRep* imageRep = [CImage_CreateImageRep(env, buffer, width, height) autorelease];
+ NSBitmapImageRep* imageRep = CImage_CreateImageRep(env, buffer, width, height);
if (imageRep) {
NSData *tiffImage = [imageRep TIFFRepresentation];
jsize tiffSize = (jsize)[tiffImage length];
--- a/jdk/src/macosx/native/sun/awt/CTrayIcon.m Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/native/sun/awt/CTrayIcon.m Fri May 23 23:55:14 2014 +0000
@@ -25,6 +25,7 @@
#import <AppKit/AppKit.h>
#import <JavaNativeFoundation/JavaNativeFoundation.h>
+#import "jni_util.h"
#import "CTrayIcon.h"
#import "ThreadUtilities.h"
@@ -146,14 +147,12 @@
(jint)absP.x, (jint)absP.y,
[event deltaY],
[event deltaX]);
- if (jEvent == nil) {
- // Unable to create event by some reason.
- return;
- }
+ CHECK_NULL(jEvent);
static JNF_CLASS_CACHE(jc_TrayIcon, "sun/lwawt/macosx/CTrayIcon");
static JNF_MEMBER_CACHE(jm_handleMouseEvent, jc_TrayIcon, "handleMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V");
JNFCallVoidMethod(env, peer, jm_handleMouseEvent, jEvent);
+ (*env)->DeleteLocalRef(env, jEvent);
}
@end //AWTTrayIcon
--- a/jdk/src/macosx/native/sun/awt/LWCToolkit.m Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/native/sun/awt/LWCToolkit.m Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, 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
@@ -157,61 +157,6 @@
JNF_COCOA_EXIT(env);
}
-static JNF_CLASS_CACHE(jc_Component, "java/awt/Component");
-static JNF_MEMBER_CACHE(jf_Component_appContext, jc_Component, "appContext", "Lsun/awt/AppContext;");
-static JNF_CLASS_CACHE(jc_MenuComponent, "java/awt/MenuComponent");
-static JNF_MEMBER_CACHE(jf_MenuComponent_appContext, jc_MenuComponent, "appContext", "Lsun/awt/AppContext;");
-
-/*
- * Class: sun_awt_SunToolkit
- * Method: getAppContext
- * Signature: (Ljava/awt/Object;)Lsun/awt/AppContext;
- */
-JNIEXPORT jobject JNICALL
-Java_sun_awt_SunToolkit_getAppContext
-(JNIEnv *env, jclass cls, jobject obj)
-{
- jobject appContext = NULL;
-
-JNF_COCOA_ENTER(env);
-
- if (JNFIsInstanceOf(env, obj, &jc_Component)) {
- appContext = JNFGetObjectField(env, obj, jf_Component_appContext);
- } else if (JNFIsInstanceOf(env, obj, &jc_MenuComponent)) {
- appContext = JNFGetObjectField(env, obj, jf_MenuComponent_appContext);
- }
-
-JNF_COCOA_EXIT(env);
-
- return appContext;
-}
-
-/*
- * Class: sun_awt_SunToolkit
- * Method: setAppContext
- * Signature: (Ljava/lang/Object;Lsun/awt/AppContext;)Z
- */
-JNIEXPORT jboolean JNICALL
-Java_sun_awt_SunToolkit_setAppContext
-(JNIEnv *env, jclass cls, jobject obj, jobject appContext)
-{
- jboolean isComponent;
-
-JNF_COCOA_ENTER(env);
-
- if (JNFIsInstanceOf(env, obj, &jc_Component)) {
- JNFSetObjectField(env, obj, jf_Component_appContext, appContext);
- isComponent = JNI_TRUE;
- } else if (JNFIsInstanceOf(env, obj, &jc_MenuComponent)) {
- JNFSetObjectField(env, obj, jf_MenuComponent_appContext, appContext);
- isComponent = JNI_FALSE;
- }
-
-JNF_COCOA_EXIT(env);
-
- return isComponent;
-}
-
/*
* Class: sun_lwawt_macosx_LWCToolkit
* Method: beep
--- a/jdk/src/macosx/native/sun/awt/awt.m Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/native/sun/awt/awt.m Fri May 23 23:55:14 2014 +0000
@@ -435,7 +435,7 @@
forceEmbeddedMode = YES;
}
JNIEnv* env = [ThreadUtilities getJNIEnvUncached];
- jclass jc_ThreadGroupUtils = (*env)->FindClass(env, "sun/misc/ThreadGroupUtils");
+ jclass jc_ThreadGroupUtils = (*env)->FindClass(env, "sun/awt/util/ThreadGroupUtils");
jmethodID sjm_getRootThreadGroup = (*env)->GetStaticMethodID(env, jc_ThreadGroupUtils, "getRootThreadGroup", "()Ljava/lang/ThreadGroup;");
jobject rootThreadGroup = (*env)->CallStaticObjectMethod(env, jc_ThreadGroupUtils, sjm_getRootThreadGroup);
[ThreadUtilities setAppkitThreadGroup:(*env)->NewGlobalRef(env, rootThreadGroup)];
--- a/jdk/src/macosx/native/sun/osxapp/AWT_debug.h Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/macosx/native/sun/osxapp/AWT_debug.h Fri May 23 23:55:14 2014 +0000
@@ -32,9 +32,10 @@
#define kInternalError "java/lang/InternalError"
#define AWT_DEBUG_LOG(str) \
- NSLog(@"Cocoa AWT: %@ %@", str, [NSThread callStackSymbols])
+ NSLog(@"\tCocoa AWT: %@ %@", str, [NSThread callStackSymbols])
#define AWT_DEBUG_BUG_REPORT_MESSAGE \
- NSLog(@"\tPlease file a bug report at http://java.net/jira/browse/MACOSX_PORT with this message and a reproducible test case.")
+ NSLog(@"\tPlease file a bug report at http://bugreport.java.com/bugreport \
+with this message and a reproducible test case.")
#endif
--- a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java Fri May 23 23:55:14 2014 +0000
@@ -664,6 +664,12 @@
try {
while (true) {
int chunkLength = stream.readInt();
+
+ // verify the chunk length first
+ if (chunkLength < 0 || chunkLength + 4 < 0) {
+ throw new IIOException("Invalid chunk length " + chunkLength);
+ }
+
int chunkType = stream.readInt();
if (chunkType == IDAT_TYPE) {
@@ -692,7 +698,7 @@
// verify the chunk length
if (chunkLength < 0) {
- throw new IIOException("Invalid chunk lenght " + chunkLength);
+ throw new IIOException("Invalid chunk length " + chunkLength);
};
try {
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java Fri May 23 23:55:14 2014 +0000
@@ -1683,6 +1683,7 @@
* adjustments that windows/metal do. This is because gtk doesn't
* provide margins/insets for checkbox/radiobuttons.
*/
+ @SuppressWarnings("fallthrough")
private static class GnomeLayoutStyle extends DefaultLayoutStyle {
private static GnomeLayoutStyle INSTANCE = new GnomeLayoutStyle();
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java Fri May 23 23:55:14 2014 +0000
@@ -2409,6 +2409,7 @@
// Windows LayoutStyle. From:
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch14e.asp
+ @SuppressWarnings("fallthrough")
private class WindowsLayoutStyle extends DefaultLayoutStyle {
@Override
public int getPreferredGap(JComponent component1,
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsScrollBarUI.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsScrollBarUI.java Fri May 23 23:55:14 2014 +0000
@@ -51,6 +51,8 @@
public class WindowsScrollBarUI extends BasicScrollBarUI {
private Grid thumbGrid;
private Grid highlightGrid;
+ private Dimension horizontalThumbSize;
+ private Dimension verticalThumbSize;
/**
* Creates a UI for a JScrollBar.
@@ -65,11 +67,32 @@
protected void installDefaults() {
super.installDefaults();
- if (XPStyle.getXP() != null) {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
scrollbar.setBorder(null);
+ horizontalThumbSize = getSize(scrollbar, xp, Part.SBP_THUMBBTNHORZ);
+ verticalThumbSize = getSize(scrollbar, xp, Part.SBP_THUMBBTNVERT);
+ } else {
+ horizontalThumbSize = null;
+ verticalThumbSize = null;
}
}
+ private static Dimension getSize(Component component, XPStyle xp, Part part) {
+ Skin skin = xp.getSkin(component, part);
+ return new Dimension(skin.getWidth(), skin.getHeight());
+ }
+
+ @Override
+ protected Dimension getMinimumThumbSize() {
+ if ((horizontalThumbSize == null) || (verticalThumbSize == null)) {
+ return super.getMinimumThumbSize();
+ }
+ return JScrollBar.HORIZONTAL == scrollbar.getOrientation()
+ ? horizontalThumbSize
+ : verticalThumbSize;
+ }
+
public void uninstallUI(JComponent c) {
super.uninstallUI(c);
thumbGrid = highlightGrid = null;
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTableHeaderUI.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTableHeaderUI.java Fri May 23 23:55:14 2014 +0000
@@ -182,7 +182,6 @@
if (sortOrder != null) {
switch(sortOrder) {
case ASCENDING:
- /* falls through */
case DESCENDING:
switch (state) {
case NORMAL:
@@ -197,6 +196,7 @@
default:
/* do nothing */
}
+ break;
default :
/* do nothing */
}
--- a/jdk/src/share/classes/com/sun/jndi/ldap/Connection.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/jndi/ldap/Connection.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -459,10 +459,10 @@
// will be woken up before readTimeout only if reply is
// available
ldr.wait(readTimeout);
- waited = true;
} else {
ldr.wait(15 * 1000); // 15 second timeout
}
+ waited = true;
} else {
break;
}
@@ -474,7 +474,7 @@
}
if ((rber == null) && waited) {
- removeRequest(ldr);
+ abandonRequest(ldr, null);
throw new NamingException("LDAP response read timed out, timeout used:"
+ readTimeout + "ms." );
--- a/jdk/src/share/classes/com/sun/media/sound/AbstractLine.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/media/sound/AbstractLine.java Fri May 23 23:55:14 2014 +0000
@@ -48,7 +48,7 @@
protected Control[] controls;
AbstractMixer mixer;
private boolean open = false;
- private final Vector listeners = new Vector();
+ private final Vector<Object> listeners = new Vector<>();
/**
* Contains event dispatcher per thread group.
--- a/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java Fri May 23 23:55:14 2014 +0000
@@ -70,7 +70,7 @@
/** List of Receivers and Transmitters that opened the device implicitely.
*/
- private List openKeepingObjects;
+ private List<Object> openKeepingObjects;
/**
* This is the device handle returned from native code
@@ -284,6 +284,7 @@
}
+ @SuppressWarnings("unchecked") // Cast of result of clone
public final List<Receiver> getReceivers() {
List<Receiver> recs;
synchronized (traRecLock) {
@@ -313,6 +314,7 @@
}
+ @SuppressWarnings("unchecked") // Cast of result of clone
public final List<Transmitter> getTransmitters() {
List<Transmitter> tras;
synchronized (traRecLock) {
@@ -372,9 +374,9 @@
/** Return the list of objects that have opened the device implicitely.
*/
- private synchronized List getOpenKeepingObjects() {
+ private synchronized List<Object> getOpenKeepingObjects() {
if (openKeepingObjects == null) {
- openKeepingObjects = new ArrayList();
+ openKeepingObjects = new ArrayList<>();
}
return openKeepingObjects;
}
--- a/jdk/src/share/classes/com/sun/media/sound/AbstractMixer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/media/sound/AbstractMixer.java Fri May 23 23:55:14 2014 +0000
@@ -90,13 +90,13 @@
/**
* Source lines (ports) currently open
*/
- private final Vector sourceLines = new Vector();
+ private final Vector<Line> sourceLines = new Vector<>();
/**
* Target lines currently open.
*/
- private final Vector targetLines = new Vector();
+ private final Vector<Line> targetLines = new Vector<>();
/**
@@ -151,7 +151,7 @@
public final Line.Info[] getSourceLineInfo(Line.Info info) {
int i;
- Vector vec = new Vector();
+ Vector<Line.Info> vec = new Vector<>();
for (i = 0; i < sourceLineInfo.length; i++) {
@@ -162,7 +162,7 @@
Line.Info[] returnedArray = new Line.Info[vec.size()];
for (i = 0; i < returnedArray.length; i++) {
- returnedArray[i] = (Line.Info)vec.elementAt(i);
+ returnedArray[i] = vec.elementAt(i);
}
return returnedArray;
@@ -172,7 +172,7 @@
public final Line.Info[] getTargetLineInfo(Line.Info info) {
int i;
- Vector vec = new Vector();
+ Vector<Line.Info> vec = new Vector<>();
for (i = 0; i < targetLineInfo.length; i++) {
@@ -183,7 +183,7 @@
Line.Info[] returnedArray = new Line.Info[vec.size()];
for (i = 0; i < returnedArray.length; i++) {
- returnedArray[i] = (Line.Info)vec.elementAt(i);
+ returnedArray[i] = vec.elementAt(i);
}
return returnedArray;
@@ -231,7 +231,7 @@
localLines = new Line[sourceLines.size()];
for (int i = 0; i < localLines.length; i++) {
- localLines[i] = (Line)sourceLines.elementAt(i);
+ localLines[i] = sourceLines.elementAt(i);
}
}
@@ -248,7 +248,7 @@
localLines = new Line[targetLines.size()];
for (int i = 0; i < localLines.length; i++) {
- localLines[i] = (Line)targetLines.elementAt(i);
+ localLines[i] = targetLines.elementAt(i);
}
}
@@ -453,7 +453,8 @@
return;
}
- Vector localSourceLines = (Vector)sourceLines.clone();
+ @SuppressWarnings("unchecked")
+ Vector<Line> localSourceLines = (Vector<Line>)sourceLines.clone();
for (int i = 0; i < localSourceLines.size(); i++) {
// if any other open line is running, return
@@ -468,7 +469,8 @@
}
}
- Vector localTargetLines = (Vector)targetLines.clone();
+ @SuppressWarnings("unchecked")
+ Vector<Line> localTargetLines = (Vector<Line>)targetLines.clone();
for (int i = 0; i < localTargetLines.size(); i++) {
// if any other open line is running, return
--- a/jdk/src/share/classes/com/sun/media/sound/AlawCodec.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/media/sound/AlawCodec.java Fri May 23 23:55:14 2014 +0000
@@ -213,7 +213,7 @@
private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
- Vector formats = new Vector();
+ Vector<AudioFormat> formats = new Vector<>();
AudioFormat format;
if ( AudioFormat.Encoding.PCM_SIGNED.equals(inputFormat.getEncoding())) {
@@ -248,7 +248,7 @@
AudioFormat[] formatArray = new AudioFormat[formats.size()];
for (int i = 0; i < formatArray.length; i++) {
- formatArray[i] = (AudioFormat)(formats.elementAt(i));
+ formatArray[i] = formats.elementAt(i);
}
return formatArray;
}
--- a/jdk/src/share/classes/com/sun/media/sound/AudioSynthesizerPropertyInfo.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/media/sound/AudioSynthesizerPropertyInfo.java Fri May 23 23:55:14 2014 +0000
@@ -68,7 +68,7 @@
* The <code>valueClass</code> field specifies class
* used in <code>value</code> field.
*/
- public Class valueClass = null;
+ public Class<?> valueClass = null;
/**
* An array of possible values if the value for the field
* <code>AudioSynthesizerPropertyInfo.value</code> may be selected
--- a/jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java Fri May 23 23:55:14 2014 +0000
@@ -94,7 +94,7 @@
}
private DirectDLI createDataLineInfo(boolean isSource) {
- Vector formats = new Vector();
+ Vector<AudioFormat> formats = new Vector<>();
AudioFormat[] hardwareFormatArray = null;
AudioFormat[] formatArray = null;
@@ -107,7 +107,7 @@
int formatArraySize = size;
hardwareFormatArray = new AudioFormat[size];
for (int i = 0; i < size; i++) {
- AudioFormat format = (AudioFormat)formats.elementAt(i);
+ AudioFormat format = formats.elementAt(i);
hardwareFormatArray[i] = format;
int bits = format.getSampleSizeInBits();
boolean isSigned = format.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED);
@@ -265,7 +265,7 @@
return ((DirectAudioDeviceProvider.DirectAudioDeviceInfo) getMixerInfo()).getMaxSimulLines();
}
- private static void addFormat(Vector v, int bits, int frameSizeInBytes, int channels, float sampleRate,
+ private static void addFormat(Vector<AudioFormat> v, int bits, int frameSizeInBytes, int channels, float sampleRate,
int encoding, boolean signed, boolean bigEndian) {
AudioFormat.Encoding enc = null;
switch (encoding) {
@@ -338,7 +338,7 @@
private static final class DirectDLI extends DataLine.Info {
final AudioFormat[] hardwareFormats;
- private DirectDLI(Class clazz, AudioFormat[] formatArray,
+ private DirectDLI(Class<?> clazz, AudioFormat[] formatArray,
AudioFormat[] hardwareFormatArray,
int minBuffer, int maxBuffer) {
super(clazz, formatArray, minBuffer, maxBuffer);
@@ -1457,7 +1457,7 @@
} // class DirectBAOS
-
+ @SuppressWarnings("rawtypes")
private static native void nGetFormats(int mixerIndex, int deviceID,
boolean isSource, Vector formats);
--- a/jdk/src/share/classes/com/sun/media/sound/EventDispatcher.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/media/sound/EventDispatcher.java Fri May 23 23:55:14 2014 +0000
@@ -57,7 +57,7 @@
/**
* List of events
*/
- private final ArrayList eventQueue = new ArrayList();
+ private final ArrayList<EventInfo> eventQueue = new ArrayList<>();
/**
@@ -186,7 +186,7 @@
}
if (eventQueue.size() > 0) {
// Remove the event from the queue and dispatch it to the listeners.
- eventInfo = (EventInfo) eventQueue.remove(0);
+ eventInfo = eventQueue.remove(0);
}
} // end of synchronized
@@ -230,7 +230,7 @@
/**
* Send audio and MIDI events.
*/
- void sendAudioEvents(Object event, List listeners) {
+ void sendAudioEvents(Object event, List<Object> listeners) {
if ((listeners == null)
|| (listeners.size() == 0)) {
// nothing to do
@@ -392,7 +392,7 @@
* @param event the event to be dispatched
* @param listeners listener list; will be copied
*/
- EventInfo(Object event, List listeners) {
+ EventInfo(Object event, List<Object> listeners) {
this.event = event;
this.listeners = listeners.toArray();
}
--- a/jdk/src/share/classes/com/sun/media/sound/JDK13Services.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/media/sound/JDK13Services.java Fri May 23 23:55:14 2014 +0000
@@ -118,7 +118,7 @@
(the part before the hash sign), if available. If the property is
not set or the value has no provider class name part, null is returned.
*/
- public static synchronized String getDefaultProviderClassName(Class typeClass) {
+ public static synchronized String getDefaultProviderClassName(Class<?> typeClass) {
String value = null;
String defaultProviderSpec = getDefaultProvider(typeClass);
if (defaultProviderSpec != null) {
@@ -144,7 +144,7 @@
part after the hash sign), if available. If the property is not set
or the value has no instance name part, null is returned.
*/
- public static synchronized String getDefaultInstanceName(Class typeClass) {
+ public static synchronized String getDefaultInstanceName(Class<?> typeClass) {
String value = null;
String defaultProviderSpec = getDefaultProvider(typeClass);
if (defaultProviderSpec != null) {
@@ -165,7 +165,7 @@
@return The complete value of the property, if available.
If the property is not set, null is returned.
*/
- private static synchronized String getDefaultProvider(Class typeClass) {
+ private static synchronized String getDefaultProvider(Class<?> typeClass) {
if (!SourceDataLine.class.equals(typeClass)
&& !TargetDataLine.class.equals(typeClass)
&& !Clip.class.equals(typeClass)
--- a/jdk/src/share/classes/com/sun/media/sound/MidiInDeviceProvider.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/media/sound/MidiInDeviceProvider.java Fri May 23 23:55:14 2014 +0000
@@ -106,9 +106,9 @@
* the new instance will not reflect that state...
*/
static final class MidiInDeviceInfo extends AbstractMidiDeviceProvider.Info {
- private final Class providerClass;
+ private final Class<?> providerClass;
- private MidiInDeviceInfo(int index, Class providerClass) {
+ private MidiInDeviceInfo(int index, Class<?> providerClass) {
super(nGetName(index), nGetVendor(index), nGetDescription(index), nGetVersion(index), index);
this.providerClass = providerClass;
}
--- a/jdk/src/share/classes/com/sun/media/sound/MidiOutDeviceProvider.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/media/sound/MidiOutDeviceProvider.java Fri May 23 23:55:14 2014 +0000
@@ -104,9 +104,9 @@
* the new instance will not reflect that state...
*/
static final class MidiOutDeviceInfo extends AbstractMidiDeviceProvider.Info {
- private final Class providerClass;
+ private final Class<?> providerClass;
- private MidiOutDeviceInfo(int index, Class providerClass) {
+ private MidiOutDeviceInfo(int index, Class<?> providerClass) {
super(nGetName(index), nGetVendor(index), nGetDescription(index), nGetVersion(index), index);
this.providerClass = providerClass;
}
--- a/jdk/src/share/classes/com/sun/media/sound/MidiUtils.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/media/sound/MidiUtils.java Fri May 23 23:55:14 2014 +0000
@@ -295,7 +295,7 @@
public synchronized void refresh(Sequence seq) {
- ArrayList list = new ArrayList();
+ ArrayList<MidiEvent> list = new ArrayList<>();
Track[] tracks = seq.getTracks();
if (tracks.length > 0) {
// tempo events only occur in track 0
@@ -313,7 +313,7 @@
int size = list.size() + 1;
firstTempoIsFake = true;
if ((size > 1)
- && (((MidiEvent) list.get(0)).getTick() == 0)) {
+ && (list.get(0).getTick() == 0)) {
// do not need to add an initial tempo event at the beginning
size--;
firstTempoIsFake = false;
@@ -328,7 +328,7 @@
e++;
}
for (int i = 0; i < list.size(); i++, e++) {
- MidiEvent evt = (MidiEvent) list.get(i);
+ MidiEvent evt = list.get(i);
ticks[e] = evt.getTick();
tempos[e] = getTempoMPQ(evt.getMessage());
}
--- a/jdk/src/share/classes/com/sun/media/sound/PCMtoPCMCodec.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/media/sound/PCMtoPCMCodec.java Fri May 23 23:55:14 2014 +0000
@@ -91,7 +91,7 @@
// filter out targetEncoding from the old getOutputFormats( sourceFormat ) method
AudioFormat[] formats = getOutputFormats( sourceFormat );
- Vector newFormats = new Vector();
+ Vector<AudioFormat> newFormats = new Vector<>();
for(int i=0; i<formats.length; i++ ) {
if( formats[i].getEncoding().equals( targetEncoding ) ) {
newFormats.addElement( formats[i] );
@@ -101,7 +101,7 @@
AudioFormat[] formatArray = new AudioFormat[newFormats.size()];
for (int i = 0; i < formatArray.length; i++) {
- formatArray[i] = (AudioFormat)(newFormats.elementAt(i));
+ formatArray[i] = newFormats.elementAt(i);
}
return formatArray;
@@ -181,7 +181,7 @@
/* public AudioFormat[] getOutputFormats(AudioFormat inputFormat) { */
private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
- Vector formats = new Vector();
+ Vector<AudioFormat> formats = new Vector<>();
AudioFormat format;
int sampleSize = inputFormat.getSampleSizeInBits();
@@ -335,7 +335,7 @@
for (int i = 0; i < formatArray.length; i++) {
- formatArray[i] = (AudioFormat)(formats.elementAt(i));
+ formatArray[i] = formats.elementAt(i);
}
}
--- a/jdk/src/share/classes/com/sun/media/sound/PortMixer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/media/sound/PortMixer.java Fri May 23 23:55:14 2014 +0000
@@ -253,12 +253,12 @@
long newID = ((PortMixer) mixer).getID();
if ((id == 0) || (newID != id) || (controls.length == 0)) {
id = newID;
- Vector vector = new Vector();
+ Vector<Control> vector = new Vector<>();
synchronized (vector) {
nGetControls(id, portIndex, vector);
controls = new Control[vector.size()];
for (int i = 0; i < controls.length; i++) {
- controls[i] = (Control) vector.elementAt(i);
+ controls[i] = vector.elementAt(i);
}
}
} else {
@@ -494,6 +494,7 @@
private static native String nGetPortName(long id, int portIndex);
// fills the vector with the controls for this port
+ @SuppressWarnings("rawtypes")
private static native void nGetControls(long id, int portIndex, Vector vector);
// getters/setters for controls
--- a/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java Fri May 23 23:55:14 2014 +0000
@@ -122,7 +122,7 @@
/**
* List of tracks to which we're recording
*/
- private final List recordingTracks = new ArrayList();
+ private final List<RecordingTrack> recordingTracks = new ArrayList<>();
private long loopStart = 0;
@@ -133,13 +133,13 @@
/**
* Meta event listeners
*/
- private final ArrayList metaEventListeners = new ArrayList();
+ private final ArrayList<Object> metaEventListeners = new ArrayList<>();
/**
* Control change listeners
*/
- private final ArrayList controllerEventListeners = new ArrayList();
+ private final ArrayList<ControllerListElement> controllerEventListeners = new ArrayList<>();
/** automatic connection support */
@@ -645,7 +645,7 @@
boolean flag = false;
for(int i=0; i < controllerEventListeners.size(); i++) {
- cve = (ControllerListElement) controllerEventListeners.get(i);
+ cve = controllerEventListeners.get(i);
if (cve.listener.equals(listener)) {
cve.addControllers(controllers);
@@ -669,7 +669,7 @@
ControllerListElement cve = null;
boolean flag = false;
for (int i=0; i < controllerEventListeners.size(); i++) {
- cve = (ControllerListElement) controllerEventListeners.get(i);
+ cve = controllerEventListeners.get(i);
if (cve.listener.equals(listener)) {
cve.removeControllers(controllers);
flag = true;
@@ -940,9 +940,9 @@
}
ShortMessage msg = (ShortMessage) message;
int controller = msg.getData1();
- List sendToListeners = new ArrayList();
+ List<Object> sendToListeners = new ArrayList<>();
for (int i = 0; i < size; i++) {
- ControllerListElement cve = (ControllerListElement) controllerEventListeners.get(i);
+ ControllerListElement cve = controllerEventListeners.get(i);
for(int j = 0; j < cve.controllers.length; j++) {
if (cve.controllers[j] == controller) {
sendToListeners.add(cve.listener);
@@ -1213,13 +1213,13 @@
this.channel = channel;
}
- static RecordingTrack get(List recordingTracks, Track track) {
+ static RecordingTrack get(List<RecordingTrack> recordingTracks, Track track) {
synchronized(recordingTracks) {
int size = recordingTracks.size();
for (int i = 0; i < size; i++) {
- RecordingTrack current = (RecordingTrack)recordingTracks.get(i);
+ RecordingTrack current = recordingTracks.get(i);
if (current.track == track) {
return current;
}
@@ -1228,12 +1228,12 @@
return null;
}
- static Track get(List recordingTracks, int channel) {
+ static Track get(List<RecordingTrack> recordingTracks, int channel) {
synchronized(recordingTracks) {
int size = recordingTracks.size();
for (int i = 0; i < size; i++) {
- RecordingTrack current = (RecordingTrack)recordingTracks.get(i);
+ RecordingTrack current = recordingTracks.get(i);
if ((current.channel == channel) || (current.channel == -1)) {
return current.track;
}
--- a/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java Fri May 23 23:55:14 2014 +0000
@@ -949,7 +949,7 @@
Object v = (info == null) ? null : info.get(item2.name);
v = (v != null) ? v : storedProperties.getProperty(item2.name);
if (v != null) {
- Class c = (item2.valueClass);
+ Class<?> c = (item2.valueClass);
if (c.isInstance(v))
item2.value = v;
else if (v instanceof String) {
--- a/jdk/src/share/classes/com/sun/media/sound/UlawCodec.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/com/sun/media/sound/UlawCodec.java Fri May 23 23:55:14 2014 +0000
@@ -198,7 +198,7 @@
/* public AudioFormat[] getOutputFormats(AudioFormat inputFormat) { */
private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
- Vector formats = new Vector();
+ Vector<AudioFormat> formats = new Vector<>();
AudioFormat format;
if ((inputFormat.getSampleSizeInBits() == 16)
@@ -235,7 +235,7 @@
AudioFormat[] formatArray = new AudioFormat[formats.size()];
for (int i = 0; i < formatArray.length; i++) {
- formatArray[i] = (AudioFormat)(formats.elementAt(i));
+ formatArray[i] = formats.elementAt(i);
}
return formatArray;
}
--- a/jdk/src/share/classes/java/awt/AWTKeyStroke.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/AWTKeyStroke.java Fri May 23 23:55:14 2014 +0000
@@ -86,7 +86,8 @@
* Must be called under locked AWTKeyStro
*/
private static Class<AWTKeyStroke> getAWTKeyStrokeClass() {
- Class<AWTKeyStroke> clazz = (Class)AppContext.getAppContext().get(AWTKeyStroke.class);
+ @SuppressWarnings("unchecked")
+ Class<AWTKeyStroke> clazz = (Class<AWTKeyStroke>)AppContext.getAppContext().get(AWTKeyStroke.class);
if (clazz == null) {
clazz = AWTKeyStroke.class;
AppContext.getAppContext().put(AWTKeyStroke.class, AWTKeyStroke.class);
@@ -182,6 +183,7 @@
throw new IllegalArgumentException("subclass cannot be null");
}
synchronized (AWTKeyStroke.class) {
+ @SuppressWarnings("unchecked")
Class<AWTKeyStroke> keyStrokeClass = (Class)AppContext.getAppContext().get(AWTKeyStroke.class);
if (keyStrokeClass != null && keyStrokeClass.equals(subclass)){
// Already registered
@@ -192,7 +194,7 @@
throw new ClassCastException("subclass is not derived from AWTKeyStroke");
}
- Constructor ctor = getCtor(subclass);
+ Constructor<?> ctor = getCtor(subclass);
String couldNotInstantiate = "subclass could not be instantiated";
@@ -227,12 +229,12 @@
threat as accessible flag is set only for this Constructor object,
not for Class constructor.
*/
- private static Constructor getCtor(final Class clazz)
+ private static Constructor<?> getCtor(final Class<?> clazz)
{
- Constructor ctor = AccessController.doPrivileged(new PrivilegedAction<Constructor>() {
- public Constructor run() {
+ Constructor<?> ctor = AccessController.doPrivileged(new PrivilegedAction<Constructor<?>>() {
+ public Constructor<?> run() {
try {
- Constructor ctor = clazz.getDeclaredConstructor((Class[]) null);
+ Constructor<?> ctor = clazz.getDeclaredConstructor((Class<?>[]) null);
if (ctor != null) {
ctor.setAccessible(true);
}
@@ -249,6 +251,7 @@
private static synchronized AWTKeyStroke getCachedStroke
(char keyChar, int keyCode, int modifiers, boolean onKeyRelease)
{
+ @SuppressWarnings("unchecked")
Map<AWTKeyStroke, AWTKeyStroke> cache = (Map)AppContext.getAppContext().get(APP_CONTEXT_CACHE_KEY);
AWTKeyStroke cacheKey = (AWTKeyStroke)AppContext.getAppContext().get(APP_CONTEXT_KEYSTROKE_KEY);
--- a/jdk/src/share/classes/java/awt/CardLayout.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/CardLayout.java Fri May 23 23:55:14 2014 +0000
@@ -560,6 +560,7 @@
/**
* Reads serializable fields from stream.
*/
+ @SuppressWarnings("unchecked")
private void readObject(ObjectInputStream s)
throws ClassNotFoundException, IOException
{
--- a/jdk/src/share/classes/java/awt/Component.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/Component.java Fri May 23 23:55:14 2014 +0000
@@ -6184,7 +6184,7 @@
/**
* Parameter types of coalesceEvents(AWTEvent,AWTEVent).
*/
- private static final Class[] coalesceEventsParams = {
+ private static final Class<?>[] coalesceEventsParams = {
AWTEvent.class, AWTEvent.class
};
--- a/jdk/src/share/classes/java/awt/GraphicsEnvironment.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/GraphicsEnvironment.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -95,18 +95,18 @@
String nm = AccessController.doPrivileged(new GetPropertyAction("java.awt.graphicsenv", null));
try {
// long t0 = System.currentTimeMillis();
- Class<GraphicsEnvironment> geCls;
+ Class<?> geCls;
try {
// First we try if the bootclassloader finds the requested
// class. This way we can avoid to run in a privileged block.
- geCls = (Class<GraphicsEnvironment>)Class.forName(nm);
+ geCls = Class.forName(nm);
} catch (ClassNotFoundException ex) {
// If the bootclassloader fails, we try again with the
// application classloader.
ClassLoader cl = ClassLoader.getSystemClassLoader();
- geCls = (Class<GraphicsEnvironment>)Class.forName(nm, true, cl);
+ geCls = Class.forName(nm, true, cl);
}
- ge = geCls.newInstance();
+ ge = (GraphicsEnvironment)geCls.newInstance();
// long t1 = System.currentTimeMillis();
// System.out.println("GE creation took " + (t1-t0)+ "ms.");
if (isHeadless()) {
--- a/jdk/src/share/classes/java/awt/KeyboardFocusManager.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/KeyboardFocusManager.java Fri May 23 23:55:14 2014 +0000
@@ -348,6 +348,7 @@
* Component of those Windows that has no such array of its own explicitly
* set.
*/
+ @SuppressWarnings({"unchecked", "rawtypes"})
private Set<AWTKeyStroke>[] defaultFocusTraversalKeys = new Set[4];
/**
@@ -422,7 +423,7 @@
targetSet.add(AWTKeyStroke.getAWTKeyStroke(tokens.nextToken()));
}
return (targetSet.isEmpty())
- ? Collections.EMPTY_SET
+ ? Collections.emptySet()
: Collections.unmodifiableSet(targetSet);
}
@@ -436,7 +437,7 @@
work_set.add(defaultFocusTraversalKeyStrokes[i][j]);
}
defaultFocusTraversalKeys[i] = (work_set.isEmpty())
- ? Collections.EMPTY_SET
+ ? Collections.emptySet()
: Collections.unmodifiableSet(work_set);
}
initPeer();
@@ -1750,11 +1751,12 @@
* @see #addKeyEventDispatcher
* @see #removeKeyEventDispatcher
*/
+ @SuppressWarnings("unchecked") // Cast of result of clone
protected synchronized java.util.List<KeyEventDispatcher>
getKeyEventDispatchers()
{
return (keyEventDispatchers != null)
- ? (java.util.List)keyEventDispatchers.clone()
+ ? (java.util.List<KeyEventDispatcher>)keyEventDispatchers.clone()
: null;
}
@@ -1841,11 +1843,12 @@
* @see #addKeyEventPostProcessor
* @see #removeKeyEventPostProcessor
*/
+ @SuppressWarnings("unchecked") // Cast of result of clone
protected java.util.List<KeyEventPostProcessor>
getKeyEventPostProcessors()
{
return (keyEventPostProcessors != null)
- ? (java.util.List)keyEventPostProcessors.clone()
+ ? (java.util.List<KeyEventPostProcessor>)keyEventPostProcessors.clone()
: null;
}
@@ -1907,8 +1910,7 @@
* javax.swing.JComponent.runInputVerifier() using reflection.
*/
static synchronized Component getMostRecentFocusOwner(Window window) {
- WeakReference<Component> weakValue =
- (WeakReference)mostRecentFocusOwners.get(window);
+ WeakReference<Component> weakValue = mostRecentFocusOwners.get(window);
return weakValue == null ? null : weakValue.get();
}
--- a/jdk/src/share/classes/java/awt/Menu.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/Menu.java Fri May 23 23:55:14 2014 +0000
@@ -66,7 +66,7 @@
AWTAccessor.setMenuAccessor(
new AWTAccessor.MenuAccessor() {
- public Vector<MenuComponent> getItems(Menu menu) {
+ public Vector<MenuItem> getItems(Menu menu) {
return menu.items;
}
});
@@ -78,7 +78,7 @@
* @serial
* @see #countItems()
*/
- Vector<MenuComponent> items = new Vector<>();
+ Vector<MenuItem> items = new Vector<>();
/**
* This field indicates whether the menu has the
@@ -252,7 +252,7 @@
* be called on the toolkit thread.
*/
final MenuItem getItemImpl(int index) {
- return (MenuItem)items.elementAt(index);
+ return items.elementAt(index);
}
/**
@@ -544,7 +544,7 @@
// HeadlessException will be thrown from MenuComponent's readObject
s.defaultReadObject();
for(int i = 0; i < items.size(); i++) {
- MenuItem item = (MenuItem)items.elementAt(i);
+ MenuItem item = items.elementAt(i);
item.parent = this;
}
}
--- a/jdk/src/share/classes/java/awt/SystemTray.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/SystemTray.java Fri May 23 23:55:14 2014 +0000
@@ -259,7 +259,9 @@
Vector<TrayIcon> icons = null;
synchronized (this) {
oldArray = systemTray.getTrayIcons();
- icons = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
+ @SuppressWarnings("unchecked")
+ Vector<TrayIcon> tmp = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
+ icons = tmp;
if (icons == null) {
icons = new Vector<TrayIcon>(3);
AppContext.getAppContext().put(TrayIcon.class, icons);
@@ -304,6 +306,7 @@
TrayIcon[] oldArray = null, newArray = null;
synchronized (this) {
oldArray = systemTray.getTrayIcons();
+ @SuppressWarnings("unchecked")
Vector<TrayIcon> icons = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
// TrayIcon with no peer is not contained in the array.
if (icons == null || !icons.remove(trayIcon)) {
@@ -335,6 +338,7 @@
* @see TrayIcon
*/
public TrayIcon[] getTrayIcons() {
+ @SuppressWarnings("unchecked")
Vector<TrayIcon> icons = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
if (icons != null) {
return icons.toArray(new TrayIcon[icons.size()]);
--- a/jdk/src/share/classes/java/awt/datatransfer/MimeTypeParameterList.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/datatransfer/MimeTypeParameterList.java Fri May 23 23:55:14 2014 +0000
@@ -296,14 +296,14 @@
/**
* @return a clone of this object
*/
-
+ @SuppressWarnings("unchecked") // Cast from clone
public Object clone() {
MimeTypeParameterList newObj = null;
try {
newObj = (MimeTypeParameterList)super.clone();
} catch (CloneNotSupportedException cannotHappen) {
}
- newObj.parameters = (Hashtable)parameters.clone();
+ newObj.parameters = (Hashtable<String, String>)parameters.clone();
return newObj;
}
--- a/jdk/src/share/classes/java/awt/datatransfer/SystemFlavorMap.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/datatransfer/SystemFlavorMap.java Fri May 23 23:55:14 2014 +0000
@@ -38,13 +38,14 @@
import java.net.MalformedURLException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
-import java.util.WeakHashMap;
import sun.awt.AppContext;
import sun.awt.datatransfer.DataTransferer;
@@ -102,19 +103,11 @@
private static final String HTML_TEXT_BASE_TYPE = "text/html";
/**
- * This constant is passed to flavorToNativeLookup() to indicate that a
- * a native should be synthesized, stored, and returned by encoding the
- * DataFlavor's MIME type in case if the DataFlavor is not found in
- * 'flavorToNative' map.
- */
- private static final boolean SYNTHESIZE_IF_NOT_FOUND = true;
-
- /**
* Maps native Strings to Lists of DataFlavors (or base type Strings for
* text DataFlavors).
* Do not use the field directly, use getNativeToFlavor() instead.
*/
- private final Map<String, List<DataFlavor>> nativeToFlavor = new HashMap<>();
+ private final Map<String, LinkedHashSet<DataFlavor>> nativeToFlavor = new HashMap<>();
/**
* Accessor to nativeToFlavor map. Since we use lazy initialization we must
@@ -123,7 +116,7 @@
*
* @return nativeToFlavor
*/
- private Map<String, List<DataFlavor>> getNativeToFlavor() {
+ private Map<String, LinkedHashSet<DataFlavor>> getNativeToFlavor() {
if (!isMapInitialized) {
initSystemFlavorMap();
}
@@ -135,7 +128,7 @@
* native Strings.
* Do not use the field directly, use getFlavorToNative() instead.
*/
- private final Map<DataFlavor, List<String>> flavorToNative = new HashMap<>();
+ private final Map<DataFlavor, LinkedHashSet<String>> flavorToNative = new HashMap<>();
/**
* Accessor to flavorToNative map. Since we use lazy initialization we must
@@ -144,7 +137,7 @@
*
* @return flavorToNative
*/
- private synchronized Map<DataFlavor, List<String>> getFlavorToNative() {
+ private synchronized Map<DataFlavor, LinkedHashSet<String>> getFlavorToNative() {
if (!isMapInitialized) {
initSystemFlavorMap();
}
@@ -152,21 +145,44 @@
}
/**
+ * Maps a text DataFlavor primary mime-type to the native. Used only to store
+ * standard mappings registered in the flavormap.properties
+ * Do not use this field directly, use getTextTypeToNative() instead.
+ */
+ private Map<String, LinkedHashSet<String>> textTypeToNative = new HashMap<>();
+
+ /**
* Shows if the object has been initialized.
*/
private boolean isMapInitialized = false;
/**
+ * An accessor to textTypeToNative map. Since we use lazy initialization we
+ * must use this accessor instead of direct access to the field which may not
+ * be initialized yet. This method will initialize the field if needed.
+ *
+ * @return textTypeToNative
+ */
+ private synchronized Map<String, LinkedHashSet<String>> getTextTypeToNative() {
+ if (!isMapInitialized) {
+ initSystemFlavorMap();
+ // From this point the map should not be modified
+ textTypeToNative = Collections.unmodifiableMap(textTypeToNative);
+ }
+ return textTypeToNative;
+ }
+
+ /**
* Caches the result of getNativesForFlavor(). Maps DataFlavors to
- * SoftReferences which reference Lists of String natives.
+ * SoftReferences which reference LinkedHashSet of String natives.
*/
- private Map<DataFlavor, SoftReference<List<String>>> getNativesForFlavorCache = new HashMap<>();
+ private final SoftCache<DataFlavor, String> nativesForFlavorCache = new SoftCache<>();
/**
* Caches the result getFlavorsForNative(). Maps String natives to
- * SoftReferences which reference Lists of DataFlavors.
+ * SoftReferences which reference LinkedHashSet of DataFlavors.
*/
- private Map<String, SoftReference<List<DataFlavor>>> getFlavorsForNativeCache = new HashMap<>();
+ private final SoftCache<String, DataFlavor> flavorsForNativeCache = new SoftCache<>();
/**
* Dynamic mapping generation used for text mappings should not be applied
@@ -174,7 +190,7 @@
* explicitly specified with setFlavorsForNative() or
* setNativesForFlavor(). This keeps all such keys.
*/
- private Set disabledMappingGenerationKeys = new HashSet();
+ private Set<Object> disabledMappingGenerationKeys = new HashSet<>();
/**
* Returns the default FlavorMap for this thread's ClassLoader.
@@ -404,7 +420,7 @@
flavor = new DataFlavor(value);
} catch (Exception e) {
try {
- flavor = new DataFlavor(value, (String)null);
+ flavor = new DataFlavor(value, null);
} catch (Exception ee) {
ee.printStackTrace();
continue;
@@ -412,11 +428,11 @@
}
final LinkedHashSet<DataFlavor> dfs = new LinkedHashSet<>();
-
dfs.add(flavor);
if ("text".equals(flavor.getPrimaryType())) {
dfs.addAll(convertMimeTypeToDataFlavors(value));
+ store(flavor.mimeType.getBaseType(), key, getTextTypeToNative());
}
for (DataFlavor df : dfs) {
@@ -505,10 +521,10 @@
* the appropriate Map location, but rather will be appended to a List
* stored in that location.
*/
- private <H, L> void store(H hashed, L listed, Map<H, List<L>> map) {
- List<L> list = map.get(hashed);
+ private <H, L> void store(H hashed, L listed, Map<H, LinkedHashSet<L>> map) {
+ LinkedHashSet<L> list = map.get(hashed);
if (list == null) {
- list = new ArrayList<>(1);
+ list = new LinkedHashSet<>(1);
map.put(hashed, list);
}
if (!list.contains(listed)) {
@@ -522,17 +538,16 @@
* case, a new DataFlavor is synthesized, stored, and returned, if and
* only if the specified native is encoded as a Java MIME type.
*/
- private List<DataFlavor> nativeToFlavorLookup(String nat) {
- List<DataFlavor> flavors = getNativeToFlavor().get(nat);
+ private LinkedHashSet<DataFlavor> nativeToFlavorLookup(String nat) {
+ LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(nat);
if (nat != null && !disabledMappingGenerationKeys.contains(nat)) {
DataTransferer transferer = DataTransferer.getInstance();
if (transferer != null) {
- List<DataFlavor> platformFlavors =
+ LinkedHashSet<DataFlavor> platformFlavors =
transferer.getPlatformMappingsForNative(nat);
if (!platformFlavors.isEmpty()) {
if (flavors != null) {
- platformFlavors.removeAll(new HashSet<>(flavors));
// Prepending the platform-specific mappings ensures
// that the flavors added with
// addFlavorForUnencodedNative() are at the end of
@@ -558,24 +573,22 @@
}
if (flavor != null) {
- flavors = new ArrayList<>(1);
+ flavors = new LinkedHashSet<>(1);
getNativeToFlavor().put(nat, flavors);
flavors.add(flavor);
- getFlavorsForNativeCache.remove(nat);
- getFlavorsForNativeCache.remove(null);
+ flavorsForNativeCache.remove(nat);
- List<String> natives = getFlavorToNative().get(flavor);
+ LinkedHashSet<String> natives = getFlavorToNative().get(flavor);
if (natives == null) {
- natives = new ArrayList<>(1);
+ natives = new LinkedHashSet<>(1);
getFlavorToNative().put(flavor, natives);
}
natives.add(nat);
- getNativesForFlavorCache.remove(flavor);
- getNativesForFlavorCache.remove(null);
+ nativesForFlavorCache.remove(flavor);
}
}
- return (flavors != null) ? flavors : new ArrayList<>(0);
+ return (flavors != null) ? flavors : new LinkedHashSet<>(0);
}
/**
@@ -586,18 +599,18 @@
* encoding the DataFlavor's MIME type. Otherwise an empty List is returned
* and 'flavorToNative' remains unaffected.
*/
- private List<String> flavorToNativeLookup(final DataFlavor flav,
- final boolean synthesize) {
- List<String> natives = getFlavorToNative().get(flav);
+ private LinkedHashSet<String> flavorToNativeLookup(final DataFlavor flav,
+ final boolean synthesize) {
+
+ LinkedHashSet<String> natives = getFlavorToNative().get(flav);
if (flav != null && !disabledMappingGenerationKeys.contains(flav)) {
DataTransferer transferer = DataTransferer.getInstance();
if (transferer != null) {
- List<String> platformNatives =
+ LinkedHashSet<String> platformNatives =
transferer.getPlatformMappingsForFlavor(flav);
if (!platformNatives.isEmpty()) {
if (natives != null) {
- platformNatives.removeAll(new HashSet<>(natives));
// Prepend the platform-specific mappings to ensure
// that the natives added with
// addUnencodedNativeForFlavor() are at the end of
@@ -612,26 +625,25 @@
if (natives == null) {
if (synthesize) {
String encoded = encodeDataFlavor(flav);
- natives = new ArrayList<>(1);
+ natives = new LinkedHashSet<>(1);
getFlavorToNative().put(flav, natives);
natives.add(encoded);
- getNativesForFlavorCache.remove(flav);
- getNativesForFlavorCache.remove(null);
- List<DataFlavor> flavors = getNativeToFlavor().get(encoded);
+ LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(encoded);
if (flavors == null) {
- flavors = new ArrayList<>(1);
+ flavors = new LinkedHashSet<>(1);
getNativeToFlavor().put(encoded, flavors);
}
flavors.add(flav);
- getFlavorsForNativeCache.remove(encoded);
- getFlavorsForNativeCache.remove(null);
+
+ nativesForFlavorCache.remove(flav);
+ flavorsForNativeCache.remove(encoded);
} else {
- natives = new ArrayList<>(0);
+ natives = new LinkedHashSet<>(0);
}
}
- return natives;
+ return new LinkedHashSet<>(natives);
}
/**
@@ -659,103 +671,63 @@
* @see #encodeDataFlavor
* @since 1.4
*/
+ @Override
public synchronized List<String> getNativesForFlavor(DataFlavor flav) {
- List<String> retval = null;
-
- // Check cache, even for null flav
- SoftReference<List<String>> ref = getNativesForFlavorCache.get(flav);
- if (ref != null) {
- retval = ref.get();
- if (retval != null) {
- // Create a copy, because client code can modify the returned
- // list.
- return new ArrayList<>(retval);
- }
+ LinkedHashSet<String> retval = nativesForFlavorCache.check(flav);
+ if (retval != null) {
+ return new ArrayList<>(retval);
}
if (flav == null) {
- retval = new ArrayList<>(getNativeToFlavor().keySet());
+ retval = new LinkedHashSet<>(getNativeToFlavor().keySet());
} else if (disabledMappingGenerationKeys.contains(flav)) {
// In this case we shouldn't synthesize a native for this flavor,
// since its mappings were explicitly specified.
- retval = flavorToNativeLookup(flav, !SYNTHESIZE_IF_NOT_FOUND);
+ retval = flavorToNativeLookup(flav, false);
} else if (DataTransferer.isFlavorCharsetTextType(flav)) {
+ retval = new LinkedHashSet<>(0);
// For text/* flavors, flavor-to-native mappings specified in
// flavormap.properties are stored per flavor's base type.
if ("text".equals(flav.getPrimaryType())) {
- retval = getAllNativesForType(flav.mimeType.getBaseType());
- if (retval != null) {
- // To prevent the List stored in the map from modification.
- retval = new ArrayList(retval);
+ LinkedHashSet<String> textTypeNatives =
+ getTextTypeToNative().get(flav.mimeType.getBaseType());
+ if (textTypeNatives != null) {
+ retval.addAll(textTypeNatives);
}
}
// Also include text/plain natives, but don't duplicate Strings
- List<String> textPlainList = getAllNativesForType(TEXT_PLAIN_BASE_TYPE);
-
- if (textPlainList != null && !textPlainList.isEmpty()) {
- // To prevent the List stored in the map from modification.
- // This also guarantees that removeAll() is supported.
- textPlainList = new ArrayList<>(textPlainList);
- if (retval != null && !retval.isEmpty()) {
- // Use HashSet to get constant-time performance for search.
- textPlainList.removeAll(new HashSet<>(retval));
- retval.addAll(textPlainList);
- } else {
- retval = textPlainList;
- }
+ LinkedHashSet<String> textTypeNatives =
+ getTextTypeToNative().get(TEXT_PLAIN_BASE_TYPE);
+ if (textTypeNatives != null) {
+ retval.addAll(textTypeNatives);
}
- if (retval == null || retval.isEmpty()) {
- retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND);
+ if (retval.isEmpty()) {
+ retval = flavorToNativeLookup(flav, true);
} else {
// In this branch it is guaranteed that natives explicitly
// listed for flav's MIME type were added with
// addUnencodedNativeForFlavor(), so they have lower priority.
- List<String> explicitList =
- flavorToNativeLookup(flav, !SYNTHESIZE_IF_NOT_FOUND);
-
- // flavorToNativeLookup() never returns null.
- // It can return an empty List, however.
- if (!explicitList.isEmpty()) {
- // To prevent the List stored in the map from modification.
- // This also guarantees that removeAll() is supported.
- explicitList = new ArrayList<>(explicitList);
- // Use HashSet to get constant-time performance for search.
- explicitList.removeAll(new HashSet<>(retval));
- retval.addAll(explicitList);
- }
+ retval.addAll(flavorToNativeLookup(flav, false));
}
} else if (DataTransferer.isFlavorNoncharsetTextType(flav)) {
- retval = getAllNativesForType(flav.mimeType.getBaseType());
+ retval = getTextTypeToNative().get(flav.mimeType.getBaseType());
if (retval == null || retval.isEmpty()) {
- retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND);
+ retval = flavorToNativeLookup(flav, true);
} else {
// In this branch it is guaranteed that natives explicitly
// listed for flav's MIME type were added with
// addUnencodedNativeForFlavor(), so they have lower priority.
- List<String> explicitList =
- flavorToNativeLookup(flav, !SYNTHESIZE_IF_NOT_FOUND);
-
- // flavorToNativeLookup() never returns null.
- // It can return an empty List, however.
- if (!explicitList.isEmpty()) {
- // To prevent the List stored in the map from modification.
- // This also guarantees that add/removeAll() are supported.
- retval = new ArrayList<>(retval);
- explicitList = new ArrayList<>(explicitList);
- // Use HashSet to get constant-time performance for search.
- explicitList.removeAll(new HashSet<>(retval));
- retval.addAll(explicitList);
- }
+ retval.addAll(flavorToNativeLookup(flav, false));
}
} else {
- retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND);
+ retval = flavorToNativeLookup(flav, true);
}
- getNativesForFlavorCache.put(flav, new SoftReference<>(retval));
+ nativesForFlavorCache.put(flav, retval);
// Create a copy, because client code can modify the returned list.
return new ArrayList<>(retval);
}
@@ -791,62 +763,38 @@
* @see #encodeJavaMIMEType
* @since 1.4
*/
+ @Override
public synchronized List<DataFlavor> getFlavorsForNative(String nat) {
-
- // Check cache, even for null nat
- SoftReference<List<DataFlavor>> ref = getFlavorsForNativeCache.get(nat);
- if (ref != null) {
- List<DataFlavor> retval = ref.get();
- if (retval != null) {
- return new ArrayList<>(retval);
- }
+ LinkedHashSet<DataFlavor> returnValue = flavorsForNativeCache.check(nat);
+ if (returnValue != null) {
+ return new ArrayList<>(returnValue);
+ } else {
+ returnValue = new LinkedHashSet<>();
}
- final LinkedHashSet <DataFlavor> returnValue =
- new LinkedHashSet<>();
-
if (nat == null) {
- final List<String> natives = getNativesForFlavor(null);
-
- for (String n : natives)
- {
- final List<DataFlavor> flavors = getFlavorsForNative(n);
-
- for (DataFlavor df : flavors)
- {
- returnValue.add(df);
- }
+ for (String n : getNativesForFlavor(null)) {
+ returnValue.addAll(getFlavorsForNative(n));
}
} else {
-
- final List<DataFlavor> flavors = nativeToFlavorLookup(nat);
-
+ final LinkedHashSet<DataFlavor> flavors = nativeToFlavorLookup(nat);
if (disabledMappingGenerationKeys.contains(nat)) {
- return flavors;
+ return new ArrayList<>(flavors);
}
- final List<DataFlavor> flavorsAndBaseTypes =
- nativeToFlavorLookup(nat);
+ final LinkedHashSet<DataFlavor> flavorsWithSynthesized =
+ nativeToFlavorLookup(nat);
- for (DataFlavor df : flavorsAndBaseTypes) {
+ for (DataFlavor df : flavorsWithSynthesized) {
returnValue.add(df);
if ("text".equals(df.getPrimaryType())) {
- try {
- returnValue.addAll(
- convertMimeTypeToDataFlavors(
- new MimeType(df.getMimeType()
- ).getBaseType()));
- } catch (MimeTypeParseException e) {
- e.printStackTrace();
- }
+ String baseType = df.mimeType.getBaseType();
+ returnValue.addAll(convertMimeTypeToDataFlavors(baseType));
}
}
-
}
-
- final List<DataFlavor> arrayList = new ArrayList<>(returnValue);
- getFlavorsForNativeCache.put(nat, new SoftReference<>(arrayList));
- return new ArrayList<>(arrayList);
+ flavorsForNativeCache.put(nat, returnValue);
+ return new ArrayList<>(returnValue);
}
private static Set<DataFlavor> convertMimeTypeToDataFlavors(
@@ -862,7 +810,6 @@
} catch (MimeTypeParseException mtpe) {
// Cannot happen, since we checked all mappings
// on load from flavormap.properties.
- assert(false);
}
if (DataTransferer.doesSubtypeSupportCharset(subType, null)) {
@@ -941,10 +888,10 @@
}
private static final String [] htmlDocumntTypes =
- new String [] {"all", "selection", "fragment"};
+ new String [] {"all", "selection", "fragment"};
- private static LinkedHashSet<String> handleHtmlMimeTypes(
- String baseType, String mimeType) {
+ private static LinkedHashSet<String> handleHtmlMimeTypes(String baseType,
+ String mimeType) {
LinkedHashSet<String> returnValues = new LinkedHashSet<>();
@@ -981,14 +928,14 @@
* @see #getNativesForFlavor
* @see #encodeDataFlavor
*/
- public synchronized Map<DataFlavor,String>
- getNativesForFlavors(DataFlavor[] flavors)
+ @Override
+ public synchronized Map<DataFlavor,String> getNativesForFlavors(DataFlavor[] flavors)
{
// Use getNativesForFlavor to generate extra natives for text flavors
// and stringFlavor
if (flavors == null) {
- List flavor_list = getFlavorsForNative(null);
+ List<DataFlavor> flavor_list = getFlavorsForNative(null);
flavors = new DataFlavor[flavor_list.size()];
flavor_list.toArray(flavors);
}
@@ -1027,15 +974,14 @@
* @see #getFlavorsForNative
* @see #encodeJavaMIMEType
*/
- public synchronized Map<String,DataFlavor>
- getFlavorsForNatives(String[] natives)
+ @Override
+ public synchronized Map<String,DataFlavor> getFlavorsForNatives(String[] natives)
{
// Use getFlavorsForNative to generate extra flavors for text natives
-
if (natives == null) {
- List native_list = getNativesForFlavor(null);
- natives = new String[native_list.size()];
- native_list.toArray(natives);
+ List<String> nativesList = getNativesForFlavor(null);
+ natives = new String[nativesList.size()];
+ nativesList.toArray(natives);
}
Map<String, DataFlavor> retval = new HashMap<>(natives.length, 1.0f);
@@ -1044,7 +990,6 @@
DataFlavor flav = (flavors.isEmpty())? null : flavors.get(0);
retval.put(aNative, flav);
}
-
return retval;
}
@@ -1070,20 +1015,16 @@
*/
public synchronized void addUnencodedNativeForFlavor(DataFlavor flav,
String nat) {
- if (flav == null || nat == null) {
- throw new NullPointerException("null arguments not permitted");
- }
+ Objects.requireNonNull(nat, "Null native not permitted");
+ Objects.requireNonNull(flav, "Null flavor not permitted");
- List<String> natives = getFlavorToNative().get(flav);
+ LinkedHashSet<String> natives = getFlavorToNative().get(flav);
if (natives == null) {
- natives = new ArrayList<>(1);
+ natives = new LinkedHashSet<>(1);
getFlavorToNative().put(flav, natives);
- } else if (natives.contains(nat)) {
- return;
}
natives.add(nat);
- getNativesForFlavorCache.remove(flav);
- getNativesForFlavorCache.remove(null);
+ nativesForFlavorCache.remove(flav);
}
/**
@@ -1116,18 +1057,15 @@
*/
public synchronized void setNativesForFlavor(DataFlavor flav,
String[] natives) {
- if (flav == null || natives == null) {
- throw new NullPointerException("null arguments not permitted");
- }
+ Objects.requireNonNull(natives, "Null natives not permitted");
+ Objects.requireNonNull(flav, "Null flavors not permitted");
getFlavorToNative().remove(flav);
for (String aNative : natives) {
addUnencodedNativeForFlavor(flav, aNative);
}
disabledMappingGenerationKeys.add(flav);
- // Clear the cache to handle the case of empty natives.
- getNativesForFlavorCache.remove(flav);
- getNativesForFlavorCache.remove(null);
+ nativesForFlavorCache.remove(flav);
}
/**
@@ -1150,20 +1088,16 @@
*/
public synchronized void addFlavorForUnencodedNative(String nat,
DataFlavor flav) {
- if (nat == null || flav == null) {
- throw new NullPointerException("null arguments not permitted");
- }
+ Objects.requireNonNull(nat, "Null native not permitted");
+ Objects.requireNonNull(flav, "Null flavor not permitted");
- List<DataFlavor> flavors = getNativeToFlavor().get(nat);
+ LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(nat);
if (flavors == null) {
- flavors = new ArrayList<>(1);
+ flavors = new LinkedHashSet<>(1);
getNativeToFlavor().put(nat, flavors);
- } else if (flavors.contains(flav)) {
- return;
}
flavors.add(flav);
- getFlavorsForNativeCache.remove(nat);
- getFlavorsForNativeCache.remove(null);
+ flavorsForNativeCache.remove(nat);
}
/**
@@ -1195,18 +1129,15 @@
*/
public synchronized void setFlavorsForNative(String nat,
DataFlavor[] flavors) {
- if (nat == null || flavors == null) {
- throw new NullPointerException("null arguments not permitted");
- }
+ Objects.requireNonNull(nat, "Null native not permitted");
+ Objects.requireNonNull(flavors, "Null flavors not permitted");
getNativeToFlavor().remove(nat);
for (DataFlavor flavor : flavors) {
addFlavorForUnencodedNative(nat, flavor);
}
disabledMappingGenerationKeys.add(nat);
- // Clear the cache to handle the case of empty flavors.
- getFlavorsForNativeCache.remove(nat);
- getFlavorsForNativeCache.remove(null);
+ flavorsForNativeCache.remove(nat);
}
/**
@@ -1307,17 +1238,29 @@
: null;
}
- private List<String> getAllNativesForType(String type) {
- Set<String> retval = null;
- for (DataFlavor dataFlavor : convertMimeTypeToDataFlavors(type)) {
- List<String> natives = getFlavorToNative().get(dataFlavor);
- if (natives != null && !natives.isEmpty()) {
- if (retval == null) {
- retval = new LinkedHashSet<>();
- }
- retval.addAll(natives);
+ private static final class SoftCache<K, V> {
+ Map<K, SoftReference<LinkedHashSet<V>>> cache;
+
+ public void put(K key, LinkedHashSet<V> value) {
+ if (cache == null) {
+ cache = new HashMap<>(1);
}
+ cache.put(key, new SoftReference<>(value));
}
- return retval == null ? null : new ArrayList<>(retval);
+
+ public void remove(K key) {
+ if (cache == null) return;
+ cache.remove(null);
+ cache.remove(key);
+ }
+
+ public LinkedHashSet<V> check(K key) {
+ if (cache == null) return null;
+ SoftReference<LinkedHashSet<V>> ref = cache.get(key);
+ if (ref != null) {
+ return ref.get();
+ }
+ return null;
+ }
}
}
--- a/jdk/src/share/classes/java/awt/dnd/DragGestureEvent.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/dnd/DragGestureEvent.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2013, 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
@@ -357,6 +357,7 @@
action = newAction;
// Pre-1.4 support. 'events' was previously non-transient
+ @SuppressWarnings("rawtypes")
List newEvents;
try {
newEvents = (List)f.get("events", null);
--- a/jdk/src/share/classes/java/awt/geom/Area.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/geom/Area.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2006, 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
@@ -97,9 +97,9 @@
* @since 1.2
*/
public class Area implements Shape, Cloneable {
- private static Vector EmptyCurves = new Vector();
+ private static Vector<Curve> EmptyCurves = new Vector<>();
- private Vector curves;
+ private Vector<Curve> curves;
/**
* Default constructor which creates an empty area.
@@ -127,8 +127,8 @@
}
}
- private static Vector pathToCurves(PathIterator pi) {
- Vector curves = new Vector();
+ private static Vector<Curve> pathToCurves(PathIterator pi) {
+ Vector<Curve> curves = new Vector<>();
int windingRule = pi.getWindingRule();
// coords array is big enough for holding:
// coordinates returned from currentSegment (6)
@@ -334,7 +334,7 @@
* @since 1.2
*/
public void reset() {
- curves = new Vector();
+ curves = new Vector<>();
invalidateBounds();
}
@@ -357,9 +357,9 @@
* @since 1.2
*/
public boolean isPolygonal() {
- Enumeration enum_ = curves.elements();
+ Enumeration<Curve> enum_ = curves.elements();
while (enum_.hasMoreElements()) {
- if (((Curve) enum_.nextElement()).getOrder() > 1) {
+ if (enum_.nextElement().getOrder() > 1) {
return false;
}
}
@@ -381,8 +381,8 @@
if (size > 3) {
return false;
}
- Curve c1 = (Curve) curves.get(1);
- Curve c2 = (Curve) curves.get(2);
+ Curve c1 = curves.get(1);
+ Curve c2 = curves.get(2);
if (c1.getOrder() != 1 || c2.getOrder() != 1) {
return false;
}
@@ -411,10 +411,10 @@
if (curves.size() < 3) {
return true;
}
- Enumeration enum_ = curves.elements();
+ Enumeration<Curve> enum_ = curves.elements();
enum_.nextElement(); // First Order0 "moveto"
while (enum_.hasMoreElements()) {
- if (((Curve) enum_.nextElement()).getOrder() == 0) {
+ if (enum_.nextElement().getOrder() == 0) {
return false;
}
}
@@ -431,11 +431,11 @@
}
Rectangle2D r = new Rectangle2D.Double();
if (curves.size() > 0) {
- Curve c = (Curve) curves.get(0);
+ Curve c = curves.get(0);
// First point is always an order 0 curve (moveto)
r.setRect(c.getX0(), c.getY0(), 0, 0);
for (int i = 1; i < curves.size(); i++) {
- ((Curve) curves.get(i)).enlarge(r);
+ curves.get(i).enlarge(r);
}
}
return (cachedBounds = r);
@@ -507,7 +507,7 @@
if (other == null) {
return false;
}
- Vector c = new AreaOp.XorOp().calculate(this.curves, other.curves);
+ Vector<Curve> c = new AreaOp.XorOp().calculate(this.curves, other.curves);
return c.isEmpty();
}
@@ -555,10 +555,10 @@
if (!getCachedBounds().contains(x, y)) {
return false;
}
- Enumeration enum_ = curves.elements();
+ Enumeration<Curve> enum_ = curves.elements();
int crossings = 0;
while (enum_.hasMoreElements()) {
- Curve c = (Curve) enum_.nextElement();
+ Curve c = enum_.nextElement();
crossings += c.crossingsFor(x, y);
}
return ((crossings & 1) == 1);
@@ -658,16 +658,16 @@
class AreaIterator implements PathIterator {
private AffineTransform transform;
- private Vector curves;
+ private Vector<Curve> curves;
private int index;
private Curve prevcurve;
private Curve thiscurve;
- public AreaIterator(Vector curves, AffineTransform at) {
+ public AreaIterator(Vector<Curve> curves, AffineTransform at) {
this.curves = curves;
this.transform = at;
if (curves.size() >= 1) {
- thiscurve = (Curve) curves.get(0);
+ thiscurve = curves.get(0);
}
}
@@ -689,7 +689,7 @@
prevcurve = thiscurve;
index++;
if (index < curves.size()) {
- thiscurve = (Curve) curves.get(index);
+ thiscurve = curves.get(index);
if (thiscurve.getOrder() != 0 &&
prevcurve.getX1() == thiscurve.getX0() &&
prevcurve.getY1() == thiscurve.getY0())
--- a/jdk/src/share/classes/java/awt/image/BufferedImage.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/image/BufferedImage.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -76,7 +76,7 @@
ColorModel colorModel;
WritableRaster raster;
OffScreenImageSource osis;
- Hashtable properties;
+ Hashtable<?, ?> properties;
boolean isAlphaPremultiplied;// If true, alpha has been premultiplied in
// color channels
@@ -1106,7 +1106,7 @@
public ImageProducer getSource() {
if (osis == null) {
if (properties == null) {
- properties = new Hashtable();
+ properties = new Hashtable<>();
}
osis = new OffScreenImageSource(this, properties);
}
--- a/jdk/src/share/classes/java/awt/image/CropImageFilter.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/image/CropImageFilter.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -79,6 +79,7 @@
* with the filtering operation.
*/
public void setProperties(Hashtable<?,?> props) {
+ @SuppressWarnings("unchecked")
Hashtable<Object,Object> p = (Hashtable<Object,Object>)props.clone();
p.put("croprect", new Rectangle(cropX, cropY, cropW, cropH));
super.setProperties(p);
--- a/jdk/src/share/classes/java/awt/image/FilteredImageSource.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/image/FilteredImageSource.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -68,7 +68,7 @@
filter = imgf;
}
- private Hashtable proxies;
+ private Hashtable<ImageConsumer, ImageFilter> proxies;
/**
* Adds the specified <code>ImageConsumer</code>
@@ -94,7 +94,7 @@
*/
public synchronized void addConsumer(ImageConsumer ic) {
if (proxies == null) {
- proxies = new Hashtable();
+ proxies = new Hashtable<>();
}
if (!proxies.containsKey(ic)) {
ImageFilter imgf = filter.getFilterInstance(ic);
@@ -137,7 +137,7 @@
*/
public synchronized void removeConsumer(ImageConsumer ic) {
if (proxies != null) {
- ImageFilter imgf = (ImageFilter) proxies.get(ic);
+ ImageFilter imgf = proxies.get(ic);
if (imgf != null) {
src.removeConsumer(imgf);
proxies.remove(ic);
@@ -173,9 +173,9 @@
*/
public void startProduction(ImageConsumer ic) {
if (proxies == null) {
- proxies = new Hashtable();
+ proxies = new Hashtable<>();
}
- ImageFilter imgf = (ImageFilter) proxies.get(ic);
+ ImageFilter imgf = proxies.get(ic);
if (imgf == null) {
imgf = filter.getFilterInstance(ic);
proxies.put(ic, imgf);
@@ -200,7 +200,7 @@
*/
public void requestTopDownLeftRightResend(ImageConsumer ic) {
if (proxies != null) {
- ImageFilter imgf = (ImageFilter) proxies.get(ic);
+ ImageFilter imgf = proxies.get(ic);
if (imgf != null) {
imgf.resendTopDownLeftRight(src);
}
--- a/jdk/src/share/classes/java/awt/image/ImageFilter.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/image/ImageFilter.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -104,6 +104,7 @@
* @exception NullPointerException if <code>props</code> is null
*/
public void setProperties(Hashtable<?,?> props) {
+ @SuppressWarnings("unchecked")
Hashtable<Object,Object> p = (Hashtable<Object,Object>)props.clone();
Object o = p.get("filters");
if (o == null) {
--- a/jdk/src/share/classes/java/awt/image/MemoryImageSource.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/image/MemoryImageSource.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -111,8 +111,8 @@
Object pixels;
int pixeloffset;
int pixelscan;
- Hashtable properties;
- Vector theConsumers = new Vector();
+ Hashtable<?, ?> properties;
+ Vector<ImageConsumer> theConsumers = new Vector<>();
boolean animating;
boolean fullbuffers;
@@ -197,7 +197,7 @@
}
private void initialize(int w, int h, ColorModel cm,
- Object pix, int off, int scan, Hashtable props) {
+ Object pix, int off, int scan, Hashtable<?,?> props) {
width = w;
height = h;
model = cm;
@@ -205,7 +205,7 @@
pixeloffset = off;
pixelscan = scan;
if (props == null) {
- props = new Hashtable();
+ props = new Hashtable<>();
}
properties = props;
}
@@ -343,9 +343,9 @@
public synchronized void setAnimated(boolean animated) {
this.animating = animated;
if (!animating) {
- Enumeration enum_ = theConsumers.elements();
+ Enumeration<ImageConsumer> enum_ = theConsumers.elements();
while (enum_.hasMoreElements()) {
- ImageConsumer ic = (ImageConsumer) enum_.nextElement();
+ ImageConsumer ic = enum_.nextElement();
ic.imageComplete(ImageConsumer.STATICIMAGEDONE);
if (isConsumer(ic)) {
ic.imageComplete(ImageConsumer.IMAGEERROR);
@@ -376,9 +376,9 @@
}
this.fullbuffers = fullbuffers;
if (animating) {
- Enumeration enum_ = theConsumers.elements();
+ Enumeration<ImageConsumer> enum_ = theConsumers.elements();
while (enum_.hasMoreElements()) {
- ImageConsumer ic = (ImageConsumer) enum_.nextElement();
+ ImageConsumer ic = enum_.nextElement();
ic.setHints(fullbuffers
? (ImageConsumer.TOPDOWNLEFTRIGHT |
ImageConsumer.COMPLETESCANLINES)
@@ -474,9 +474,9 @@
if ((w <= 0 || h <= 0) && !framenotify) {
return;
}
- Enumeration enum_ = theConsumers.elements();
+ Enumeration<ImageConsumer> enum_ = theConsumers.elements();
while (enum_.hasMoreElements()) {
- ImageConsumer ic = (ImageConsumer) enum_.nextElement();
+ ImageConsumer ic = enum_.nextElement();
if (w > 0 && h > 0) {
sendPixels(ic, x, y, w, h);
}
--- a/jdk/src/share/classes/java/awt/image/ReplicateScaleFilter.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/image/ReplicateScaleFilter.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -121,6 +121,7 @@
* with the filtering operation.
*/
public void setProperties(Hashtable<?,?> props) {
+ @SuppressWarnings("unchecked")
Hashtable<Object,Object> p = (Hashtable<Object,Object>)props.clone();
String key = "rescale";
String val = destWidth + "x" + destHeight;
--- a/jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java Fri May 23 23:55:14 2014 +0000
@@ -153,6 +153,7 @@
*
* @return an Object clone of the <code>ParameterBlock</code>.
*/
+ @SuppressWarnings("unchecked") // casts from clone
public Object clone() {
ParameterBlock theClone;
@@ -164,10 +165,10 @@
}
if (sources != null) {
- theClone.setSources((Vector)sources.clone());
+ theClone.setSources((Vector<Object>)sources.clone());
}
if (parameters != null) {
- theClone.setParameters((Vector)parameters.clone());
+ theClone.setParameters((Vector<Object>)parameters.clone());
}
return (Object) theClone;
}
@@ -280,7 +281,7 @@
/** Clears the list of source images. */
public void removeSources() {
- sources = new Vector();
+ sources = new Vector<>();
}
/**
@@ -313,7 +314,7 @@
/** Clears the list of parameters. */
public void removeParameters() {
- parameters = new Vector();
+ parameters = new Vector<>();
}
/**
@@ -696,9 +697,9 @@
* of the parameters.
* @return an array of <code>Class</code> objects.
*/
- public Class [] getParamClasses() {
+ public Class<?>[] getParamClasses() {
int numParams = getNumParameters();
- Class [] classes = new Class[numParams];
+ Class<?>[] classes = new Class<?>[numParams];
int i;
for (i = 0; i < numParams; i++) {
--- a/jdk/src/share/classes/java/awt/image/renderable/RenderableImageOp.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/image/renderable/RenderableImageOp.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2013, 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
@@ -87,11 +87,11 @@
return getRenderableSources();
}
- private Vector getRenderableSources() {
- Vector sources = null;
+ private Vector<RenderableImage> getRenderableSources() {
+ Vector<RenderableImage> sources = null;
if (paramBlock.getNumSources() > 0) {
- sources = new Vector();
+ sources = new Vector<>();
int i = 0;
while (i < paramBlock.getNumSources()) {
Object o = paramBlock.getSource(i);
@@ -314,19 +314,19 @@
// contains RenderableImage sources, they will be replaced by
// RenderedImages.
ParameterBlock renderedParamBlock = (ParameterBlock)paramBlock.clone();
- Vector sources = getRenderableSources();
+ Vector<? extends Object> sources = getRenderableSources();
try {
// This assumes that if there is no renderable source, that there
// is a rendered source in paramBlock
if (sources != null) {
- Vector renderedSources = new Vector();
+ Vector<Object> renderedSources = new Vector<>();
for (int i = 0; i < sources.size(); i++) {
rcOut = myCRIF.mapRenderContext(i, renderContext,
paramBlock, this);
RenderedImage rdrdImage =
- ((RenderableImage)sources.elementAt(i)).createRendering(rcOut);
+ ((RenderableImage)sources.elementAt(i)).createRendering(rcOut);
if (rdrdImage == null) {
return null;
}
--- a/jdk/src/share/classes/java/awt/image/renderable/RenderableImageProducer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/image/renderable/RenderableImageProducer.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2008, 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
@@ -68,7 +68,7 @@
RenderContext rc;
/** A Vector of image consumers. */
- Vector ics = new Vector();
+ Vector<ImageConsumer> ics = new Vector<>();
/**
* Constructs a new RenderableImageProducer from a RenderableImage
@@ -177,12 +177,12 @@
int width = raster.getWidth();
int height = raster.getHeight();
- Enumeration icList;
+ Enumeration<ImageConsumer> icList;
ImageConsumer ic;
// Set up the ImageConsumers
icList = ics.elements();
while (icList.hasMoreElements()) {
- ic = (ImageConsumer)icList.nextElement();
+ ic = icList.nextElement();
ic.setDimensions(width,height);
ic.setHints(ImageConsumer.TOPDOWNLEFTRIGHT |
ImageConsumer.COMPLETESCANLINES |
@@ -204,7 +204,7 @@
// Now send the scanline to the Consumers
icList = ics.elements();
while (icList.hasMoreElements()) {
- ic = (ImageConsumer)icList.nextElement();
+ ic = icList.nextElement();
ic.setPixels(0, j, width, 1, colorModel, pix, 0, width);
}
}
@@ -212,7 +212,7 @@
// Now tell the consumers we're done.
icList = ics.elements();
while (icList.hasMoreElements()) {
- ic = (ImageConsumer)icList.nextElement();
+ ic = icList.nextElement();
ic.imageComplete(ImageConsumer.STATICIMAGEDONE);
}
}
--- a/jdk/src/share/classes/java/awt/print/Book.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/print/Book.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -47,7 +47,7 @@
/**
* The set of pages that make up the Book.
*/
- private Vector mPages;
+ private Vector<BookPage> mPages;
/* Instance Methods */
@@ -55,7 +55,7 @@
* Creates a new, empty <code>Book</code>.
*/
public Book() {
- mPages = new Vector();
+ mPages = new Vector<>();
}
/**
@@ -167,7 +167,7 @@
private BookPage getPage(int pageIndex)
throws ArrayIndexOutOfBoundsException
{
- return (BookPage) mPages.elementAt(pageIndex);
+ return mPages.elementAt(pageIndex);
}
/**
--- a/jdk/src/share/classes/java/awt/print/PrinterJob.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/awt/print/PrinterJob.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -74,9 +74,9 @@
if (security != null) {
security.checkPrintJobAccess();
}
- return (PrinterJob) java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Object run() {
+ return java.security.AccessController.doPrivileged(
+ new java.security.PrivilegedAction<PrinterJob>() {
+ public PrinterJob run() {
String nm = System.getProperty("java.awt.printerjob", null);
try {
return (PrinterJob)Class.forName(nm).newInstance();
--- a/jdk/src/share/classes/java/beans/MethodDescriptor.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/java/beans/MethodDescriptor.java Fri May 23 23:55:14 2014 +0000
@@ -162,6 +162,16 @@
: null;
}
+ private static Method resolve(Method oldMethod, Method newMethod) {
+ if (oldMethod == null) {
+ return newMethod;
+ }
+ if (newMethod == null) {
+ return oldMethod;
+ }
+ return !oldMethod.isSynthetic() && newMethod.isSynthetic() ? oldMethod : newMethod;
+ }
+
/*
* Package-private constructor
* Merge two method descriptors. Where they conflict, give the
@@ -173,8 +183,7 @@
MethodDescriptor(MethodDescriptor x, MethodDescriptor y) {
super(x, y);
- Method method = y.methodRef.get();
- this.methodRef.set(null != method ? method : x.methodRef.get());
+ this.methodRef.set(resolve(x.methodRef.get(), y.methodRef.get()));
params = x.params;
if (y.params != null) {
params = y.params;
--- a/jdk/src/share/classes/javax/accessibility/AccessibleContext.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/javax/accessibility/AccessibleContext.java Fri May 23 23:55:14 2014 +0000
@@ -25,6 +25,9 @@
package javax.accessibility;
+import sun.awt.AWTAccessor;
+import sun.awt.AppContext;
+
import java.util.Locale;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
@@ -79,6 +82,26 @@
*/
public abstract class AccessibleContext {
+ /**
+ * The AppContext that should be used to dispatch events for this
+ * AccessibleContext
+ */
+ private volatile AppContext targetAppContext;
+
+ static {
+ AWTAccessor.setAccessibleContextAccessor(new AWTAccessor.AccessibleContextAccessor() {
+ @Override
+ public void setAppContext(AccessibleContext accessibleContext, AppContext appContext) {
+ accessibleContext.targetAppContext = appContext;
+ }
+
+ @Override
+ public AppContext getAppContext(AccessibleContext accessibleContext) {
+ return accessibleContext.targetAppContext;
+ }
+ });
+ }
+
/**
* Constant used to determine when the accessibleName property has
* changed. The old value in the PropertyChangeEvent will be the old
--- a/jdk/src/share/classes/javax/sound/sampled/spi/AudioFileReader.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/javax/sound/sampled/spi/AudioFileReader.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -35,7 +35,7 @@
import javax.sound.sampled.UnsupportedAudioFileException;
/**
- * Provider for audio file reading services. Classes providing concrete
+ * Provider for audio file reading services. Classes providing concrete
* implementations can parse the format information from one or more types of
* audio file, and can produce audio input streams from files of these types.
*
@@ -45,93 +45,106 @@
public abstract class AudioFileReader {
/**
- * Obtains the audio file format of the input stream provided. The stream must
- * point to valid audio file data. In general, audio file readers may
+ * Obtains the audio file format of the input stream provided. The stream
+ * must point to valid audio file data. In general, audio file readers may
* need to read some data from the stream before determining whether they
- * support it. These parsers must
- * be able to mark the stream, read enough data to determine whether they
- * support the stream, and, if not, reset the stream's read pointer to its original
- * position. If the input stream does not support this, this method may fail
- * with an <code>IOException</code>.
- * @param stream the input stream from which file format information should be
- * extracted
- * @return an <code>AudioFileFormat</code> object describing the audio file format
- * @throws UnsupportedAudioFileException if the stream does not point to valid audio
- * file data recognized by the system
+ * support it. These parsers must be able to mark the stream, read enough
+ * data to determine whether they support the stream, and, if not, reset the
+ * stream's read pointer to its original position. If the input stream does
+ * not support this, this method may fail with an {@code IOException}.
+ *
+ * @param stream the input stream from which file format information should
+ * be extracted
+ * @return an {@code AudioFileFormat} object describing the audio file
+ * format
+ * @throws UnsupportedAudioFileException if the stream does not point to
+ * valid audio file data recognized by the system
* @throws IOException if an I/O exception occurs
* @see InputStream#markSupported
* @see InputStream#mark
*/
- public abstract AudioFileFormat getAudioFileFormat(InputStream stream) throws UnsupportedAudioFileException, IOException;
+ public abstract AudioFileFormat getAudioFileFormat(InputStream stream)
+ throws UnsupportedAudioFileException, IOException;
/**
- * Obtains the audio file format of the URL provided. The URL must
- * point to valid audio file data.
- * @param url the URL from which file format information should be
- * extracted
- * @return an <code>AudioFileFormat</code> object describing the audio file format
- * @throws UnsupportedAudioFileException if the URL does not point to valid audio
- * file data recognized by the system
+ * Obtains the audio file format of the URL provided. The URL must point to
+ * valid audio file data.
+ *
+ * @param url the URL from which file format information should be
+ * extracted
+ * @return an {@code AudioFileFormat} object describing the audio file
+ * format
+ * @throws UnsupportedAudioFileException if the URL does not point to valid
+ * audio file data recognized by the system
* @throws IOException if an I/O exception occurs
*/
- public abstract AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException;
+ public abstract AudioFileFormat getAudioFileFormat(URL url)
+ throws UnsupportedAudioFileException, IOException;
/**
- * Obtains the audio file format of the <code>File</code> provided. The <code>File</code> must
- * point to valid audio file data.
- * @param file the <code>File</code> from which file format information should be
- * extracted
- * @return an <code>AudioFileFormat</code> object describing the audio file format
- * @throws UnsupportedAudioFileException if the <code>File</code> does not point to valid audio
- * file data recognized by the system
+ * Obtains the audio file format of the {@code File} provided.
+ * The {@code File} must point to valid audio file data.
+ *
+ * @param file the {@code File} from which file format information
+ * should be extracted
+ * @return an {@code AudioFileFormat} object describing the audio file
+ * format
+ * @throws UnsupportedAudioFileException if the {@code File} does not point
+ * to valid audio file data recognized by the system
* @throws IOException if an I/O exception occurs
*/
- public abstract AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException;
+ public abstract AudioFileFormat getAudioFileFormat(File file)
+ throws UnsupportedAudioFileException, IOException;
/**
- * Obtains an audio input stream from the input stream provided. The stream must
- * point to valid audio file data. In general, audio file readers may
+ * Obtains an audio input stream from the input stream provided. The stream
+ * must point to valid audio file data. In general, audio file readers may
* need to read some data from the stream before determining whether they
- * support it. These parsers must
- * be able to mark the stream, read enough data to determine whether they
- * support the stream, and, if not, reset the stream's read pointer to its original
- * position. If the input stream does not support this, this method may fail
- * with an <code>IOException</code>.
- * @param stream the input stream from which the <code>AudioInputStream</code> should be
- * constructed
- * @return an <code>AudioInputStream</code> object based on the audio file data contained
- * in the input stream.
- * @throws UnsupportedAudioFileException if the stream does not point to valid audio
- * file data recognized by the system
+ * support it. These parsers must be able to mark the stream, read enough
+ * data to determine whether they support the stream, and, if not, reset the
+ * stream's read pointer to its original position. If the input stream does
+ * not support this, this method may fail with an {@code IOException}.
+ *
+ * @param stream the input stream from which the {@code AudioInputStream}
+ * should be constructed
+ * @return an {@code AudioInputStream} object based on the audio file data
+ * contained in the input stream.
+ * @throws UnsupportedAudioFileException if the stream does not point to
+ * valid audio file data recognized by the system
* @throws IOException if an I/O exception occurs
* @see InputStream#markSupported
* @see InputStream#mark
*/
- public abstract AudioInputStream getAudioInputStream(InputStream stream) throws UnsupportedAudioFileException, IOException;
+ public abstract AudioInputStream getAudioInputStream(InputStream stream)
+ throws UnsupportedAudioFileException, IOException;
/**
- * Obtains an audio input stream from the URL provided. The URL must
- * point to valid audio file data.
- * @param url the URL for which the <code>AudioInputStream</code> should be
- * constructed
- * @return an <code>AudioInputStream</code> object based on the audio file data pointed
- * to by the URL
- * @throws UnsupportedAudioFileException if the URL does not point to valid audio
- * file data recognized by the system
+ * Obtains an audio input stream from the URL provided. The URL must point
+ * to valid audio file data.
+ *
+ * @param url the URL for which the {@code AudioInputStream} should be
+ * constructed
+ * @return an {@code AudioInputStream} object based on the audio file data
+ * pointed to by the URL
+ * @throws UnsupportedAudioFileException if the URL does not point to valid
+ * audio file data recognized by the system
* @throws IOException if an I/O exception occurs
*/
- public abstract AudioInputStream getAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException;
+ public abstract AudioInputStream getAudioInputStream(URL url)
+ throws UnsupportedAudioFileException, IOException;
/**
- * Obtains an audio input stream from the <code>File</code> provided. The <code>File</code> must
- * point to valid audio file data.
- * @param file the <code>File</code> for which the <code>AudioInputStream</code> should be
- * constructed
- * @return an <code>AudioInputStream</code> object based on the audio file data pointed
- * to by the File
- * @throws UnsupportedAudioFileException if the <code>File</code> does not point to valid audio
- * file data recognized by the system
+ * Obtains an audio input stream from the {@code File} provided.
+ * The {@code File} must point to valid audio file data.
+ *
+ * @param file the {@code File} for which the {@code AudioInputStream}
+ * should be constructed
+ * @return an {@code AudioInputStream} object based on the audio file data
+ * pointed to by the File
+ * @throws UnsupportedAudioFileException if the {@code File} does not point
+ * to valid audio file data recognized by the system
* @throws IOException if an I/O exception occurs
*/
- public abstract AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException;
+ public abstract AudioInputStream getAudioInputStream(File file)
+ throws UnsupportedAudioFileException, IOException;
}
--- a/jdk/src/share/classes/javax/sound/sampled/spi/AudioFileWriter.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/javax/sound/sampled/spi/AudioFileWriter.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -26,16 +26,15 @@
package javax.sound.sampled.spi;
import java.io.File;
-import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
-import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioInputStream;
+import static javax.sound.sampled.AudioFileFormat.Type;
/**
- * Provider for audio file writing services. Classes providing concrete
+ * Provider for audio file writing services. Classes providing concrete
* implementations can write one or more types of audio file from an audio
* stream.
*
@@ -47,22 +46,23 @@
/**
* Obtains the file types for which file writing support is provided by this
* audio file writer.
- * @return array of file types. If no file types are supported,
- * an array of length 0 is returned.
+ *
+ * @return array of file types. If no file types are supported, an array of
+ * length 0 is returned.
*/
- public abstract AudioFileFormat.Type[] getAudioFileTypes();
-
+ public abstract Type[] getAudioFileTypes();
/**
- * Indicates whether file writing support for the specified file type is provided
- * by this audio file writer.
- * @param fileType the file type for which write capabilities are queried
- * @return <code>true</code> if the file type is supported,
- * otherwise <code>false</code>
+ * Indicates whether file writing support for the specified file type is
+ * provided by this audio file writer.
+ *
+ * @param fileType the file type for which write capabilities are queried
+ * @return {@code true} if the file type is supported, otherwise
+ * {@code false}
*/
- public boolean isFileTypeSupported(AudioFileFormat.Type fileType) {
+ public boolean isFileTypeSupported(Type fileType) {
- AudioFileFormat.Type types[] = getAudioFileTypes();
+ Type types[] = getAudioFileTypes();
for(int i=0; i<types.length; i++) {
if( fileType.equals( types[i] ) ) {
@@ -72,29 +72,29 @@
return false;
}
-
/**
* Obtains the file types that this audio file writer can write from the
* audio input stream specified.
- * @param stream the audio input stream for which audio file type support
- * is queried
- * @return array of file types. If no file types are supported,
- * an array of length 0 is returned.
+ *
+ * @param stream the audio input stream for which audio file type support
+ * is queried
+ * @return array of file types. If no file types are supported, an array of
+ * length 0 is returned.
*/
- public abstract AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream stream);
-
+ public abstract Type[] getAudioFileTypes(AudioInputStream stream);
/**
- * Indicates whether an audio file of the type specified can be written
- * from the audio input stream indicated.
- * @param fileType file type for which write capabilities are queried
- * @param stream for which file writing support is queried
- * @return <code>true</code> if the file type is supported for this audio input stream,
- * otherwise <code>false</code>
+ * Indicates whether an audio file of the type specified can be written from
+ * the audio input stream indicated.
+ *
+ * @param fileType file type for which write capabilities are queried
+ * @param stream for which file writing support is queried
+ * @return {@code true} if the file type is supported for this audio input
+ * stream, otherwise {@code false}
*/
- public boolean isFileTypeSupported(AudioFileFormat.Type fileType, AudioInputStream stream) {
+ public boolean isFileTypeSupported(Type fileType, AudioInputStream stream) {
- AudioFileFormat.Type types[] = getAudioFileTypes( stream );
+ Type types[] = getAudioFileTypes( stream );
for(int i=0; i<types.length; i++) {
if( fileType.equals( types[i] ) ) {
@@ -104,44 +104,44 @@
return false;
}
-
/**
* Writes a stream of bytes representing an audio file of the file type
- * indicated to the output stream provided. Some file types require that
+ * indicated to the output stream provided. Some file types require that
* the length be written into the file header, and cannot be written from
- * start to finish unless the length is known in advance. An attempt
- * to write such a file type will fail with an IOException if the length in
- * the audio file format is
- * {@link javax.sound.sampled.AudioSystem#NOT_SPECIFIED AudioSystem.NOT_SPECIFIED}.
- * @param stream the audio input stream containing audio data to be
- * written to the output stream
- * @param fileType file type to be written to the output stream
- * @param out stream to which the file data should be written
+ * start to finish unless the length is known in advance. An attempt to
+ * write such a file type will fail with an IOException if the length in the
+ * audio file format is {@link javax.sound.sampled.AudioSystem#NOT_SPECIFIED
+ * AudioSystem.NOT_SPECIFIED}.
+ *
+ * @param stream the audio input stream containing audio data to be written
+ * to the output stream
+ * @param fileType file type to be written to the output stream
+ * @param out stream to which the file data should be written
* @return the number of bytes written to the output stream
* @throws IOException if an I/O exception occurs
- * @throws IllegalArgumentException if the file type is not supported by
- * the system
- * @see #isFileTypeSupported(AudioFileFormat.Type, AudioInputStream)
+ * @throws IllegalArgumentException if the file type is not supported by the
+ * system
+ * @see #isFileTypeSupported(Type, AudioInputStream)
* @see #getAudioFileTypes
*/
- public abstract int write(AudioInputStream stream, AudioFileFormat.Type fileType, OutputStream out) throws IOException;
-
+ public abstract int write(AudioInputStream stream, Type fileType,
+ OutputStream out) throws IOException;
/**
* Writes a stream of bytes representing an audio file of the file format
* indicated to the external file provided.
- * @param stream the audio input stream containing audio data to be
- * written to the file
- * @param fileType file type to be written to the file
- * @param out external file to which the file data should be written
+ *
+ * @param stream the audio input stream containing audio data to be written
+ * to the file
+ * @param fileType file type to be written to the file
+ * @param out external file to which the file data should be written
* @return the number of bytes written to the file
* @throws IOException if an I/O exception occurs
* @throws IllegalArgumentException if the file format is not supported by
- * the system
+ * the system
* @see #isFileTypeSupported
* @see #getAudioFileTypes
*/
- public abstract int write(AudioInputStream stream, AudioFileFormat.Type fileType, File out) throws IOException;
-
-
+ public abstract int write(AudioInputStream stream, Type fileType, File out)
+ throws IOException;
}
--- a/jdk/src/share/classes/javax/sound/sampled/spi/FormatConversionProvider.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/javax/sound/sampled/spi/FormatConversionProvider.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -25,63 +25,62 @@
package javax.sound.sampled.spi;
-import java.io.InputStream;
-
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
+import static javax.sound.sampled.AudioFormat.Encoding;
+
/**
- * A format conversion provider provides format conversion services
- * from one or more input formats to one or more output formats.
- * Converters include codecs, which encode and/or decode audio data,
- * as well as transcoders, etc. Format converters provide methods for
- * determining what conversions are supported and for obtaining an audio
- * stream from which converted data can be read.
+ * A format conversion provider provides format conversion services from one or
+ * more input formats to one or more output formats. Converters include codecs,
+ * which encode and/or decode audio data, as well as transcoders, etc. Format
+ * converters provide methods for determining what conversions are supported and
+ * for obtaining an audio stream from which converted data can be read.
* <p>
- * The source format represents the format of the incoming
- * audio data, which will be converted.
+ * The source format represents the format of the incoming audio data, which
+ * will be converted.
* <p>
- * The target format represents the format of the processed, converted
- * audio data. This is the format of the data that can be read from
- * the stream returned by one of the <code>getAudioInputStream</code> methods.
+ * The target format represents the format of the processed, converted audio
+ * data. This is the format of the data that can be read from the stream
+ * returned by one of the {@code getAudioInputStream} methods.
*
* @author Kara Kytle
* @since 1.3
*/
public abstract class FormatConversionProvider {
-
- // NEW METHODS
+ /**
+ * Obtains the set of source format encodings from which format conversion
+ * services are provided by this provider.
+ *
+ * @return array of source format encodings. If for some reason provider
+ * does not provide any conversion services, an array of length 0 is
+ * returned.
+ */
+ public abstract Encoding[] getSourceEncodings();
/**
- * Obtains the set of source format encodings from which format
- * conversion services are provided by this provider.
- * @return array of source format encodings. If for some reason provider
- * does not provide any conversion services, an array of length 0 is
- * returned.
+ * Obtains the set of target format encodings to which format conversion
+ * services are provided by this provider.
+ *
+ * @return array of target format encodings. If for some reason provider
+ * does not provide any conversion services, an array of length 0 is
+ * returned.
*/
- public abstract AudioFormat.Encoding[] getSourceEncodings();
-
-
- /**
- * Obtains the set of target format encodings to which format
- * conversion services are provided by this provider.
- * @return array of target format encodings. If for some reason provider
- * does not provide any conversion services, an array of length 0 is
- * returned.
- */
- public abstract AudioFormat.Encoding[] getTargetEncodings();
-
+ public abstract Encoding[] getTargetEncodings();
/**
* Indicates whether the format converter supports conversion from the
* specified source format encoding.
- * @param sourceEncoding the source format encoding for which support is queried
- * @return <code>true</code> if the encoding is supported, otherwise <code>false</code>
+ *
+ * @param sourceEncoding the source format encoding for which support is
+ * queried
+ * @return {@code true} if the encoding is supported, otherwise
+ * {@code false}
*/
- public boolean isSourceEncodingSupported(AudioFormat.Encoding sourceEncoding){
+ public boolean isSourceEncodingSupported(Encoding sourceEncoding) {
- AudioFormat.Encoding sourceEncodings[] = getSourceEncodings();
+ Encoding sourceEncodings[] = getSourceEncodings();
for(int i=0; i<sourceEncodings.length; i++) {
if( sourceEncoding.equals( sourceEncodings[i]) ) {
@@ -91,16 +90,18 @@
return false;
}
-
/**
* Indicates whether the format converter supports conversion to the
* specified target format encoding.
- * @param targetEncoding the target format encoding for which support is queried
- * @return <code>true</code> if the encoding is supported, otherwise <code>false</code>
+ *
+ * @param targetEncoding the target format encoding for which support is
+ * queried
+ * @return {@code true} if the encoding is supported, otherwise
+ * {@code false}
*/
- public boolean isTargetEncodingSupported(AudioFormat.Encoding targetEncoding){
+ public boolean isTargetEncodingSupported(Encoding targetEncoding) {
- AudioFormat.Encoding targetEncodings[] = getTargetEncodings();
+ Encoding targetEncodings[] = getTargetEncodings();
for(int i=0; i<targetEncodings.length; i++) {
if( targetEncoding.equals( targetEncodings[i]) ) {
@@ -110,28 +111,29 @@
return false;
}
-
/**
- * Obtains the set of target format encodings supported by the format converter
- * given a particular source format.
- * If no target format encodings are supported for this source format,
- * an array of length 0 is returned.
- * @param sourceFormat format of the incoming data
+ * Obtains the set of target format encodings supported by the format
+ * converter given a particular source format. If no target format encodings
+ * are supported for this source format, an array of length 0 is returned.
+ *
+ * @param sourceFormat format of the incoming data
* @return array of supported target format encodings.
*/
- public abstract AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat);
-
+ public abstract Encoding[] getTargetEncodings(AudioFormat sourceFormat);
/**
- * Indicates whether the format converter supports conversion to a particular encoding
- * from a particular format.
- * @param targetEncoding desired encoding of the outgoing data
- * @param sourceFormat format of the incoming data
- * @return <code>true</code> if the conversion is supported, otherwise <code>false</code>
+ * Indicates whether the format converter supports conversion to a
+ * particular encoding from a particular format.
+ *
+ * @param targetEncoding desired encoding of the outgoing data
+ * @param sourceFormat format of the incoming data
+ * @return {@code true} if the conversion is supported, otherwise
+ * {@code false}
*/
- public boolean isConversionSupported(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat){
+ public boolean isConversionSupported(Encoding targetEncoding,
+ AudioFormat sourceFormat) {
- AudioFormat.Encoding targetEncodings[] = getTargetEncodings(sourceFormat);
+ Encoding targetEncodings[] = getTargetEncodings(sourceFormat);
for(int i=0; i<targetEncodings.length; i++) {
if( targetEncoding.equals( targetEncodings[i]) ) {
@@ -141,27 +143,29 @@
return false;
}
-
/**
- * Obtains the set of target formats with the encoding specified
- * supported by the format converter
- * If no target formats with the specified encoding are supported
- * for this source format, an array of length 0 is returned.
- * @param targetEncoding desired encoding of the stream after processing
- * @param sourceFormat format of the incoming data
+ * Obtains the set of target formats with the encoding specified supported
+ * by the format converter If no target formats with the specified encoding
+ * are supported for this source format, an array of length 0 is returned.
+ *
+ * @param targetEncoding desired encoding of the stream after processing
+ * @param sourceFormat format of the incoming data
* @return array of supported target formats.
*/
- public abstract AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat);
-
+ public abstract AudioFormat[] getTargetFormats(Encoding targetEncoding,
+ AudioFormat sourceFormat);
/**
* Indicates whether the format converter supports conversion to one
* particular format from another.
- * @param targetFormat desired format of outgoing data
- * @param sourceFormat format of the incoming data
- * @return <code>true</code> if the conversion is supported, otherwise <code>false</code>
+ *
+ * @param targetFormat desired format of outgoing data
+ * @param sourceFormat format of the incoming data
+ * @return {@code true} if the conversion is supported, otherwise
+ * {@code false}
*/
- public boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat){
+ public boolean isConversionSupported(AudioFormat targetFormat,
+ AudioFormat sourceFormat) {
AudioFormat targetFormats[] = getTargetFormats( targetFormat.getEncoding(), sourceFormat );
@@ -173,28 +177,33 @@
return false;
}
+ /**
+ * Obtains an audio input stream with the specified encoding from the given
+ * audio input stream.
+ *
+ * @param targetEncoding desired encoding of the stream after processing
+ * @param sourceStream stream from which data to be processed should be
+ * read
+ * @return stream from which processed data with the specified target
+ * encoding may be read
+ * @throws IllegalArgumentException if the format combination supplied is
+ * not supported.
+ */
+ public abstract AudioInputStream getAudioInputStream(
+ Encoding targetEncoding, AudioInputStream sourceStream);
/**
- * Obtains an audio input stream with the specified encoding from the given audio
- * input stream.
- * @param targetEncoding desired encoding of the stream after processing
- * @param sourceStream stream from which data to be processed should be read
- * @return stream from which processed data with the specified target encoding may be read
+ * Obtains an audio input stream with the specified format from the given
+ * audio input stream.
+ *
+ * @param targetFormat desired data format of the stream after processing
+ * @param sourceStream stream from which data to be processed should be
+ * read
+ * @return stream from which processed data with the specified format may be
+ * read
* @throws IllegalArgumentException if the format combination supplied is
- * not supported.
+ * not supported.
*/
- public abstract AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, AudioInputStream sourceStream);
-
-
- /**
- * Obtains an audio input stream with the specified format from the given audio
- * input stream.
- * @param targetFormat desired data format of the stream after processing
- * @param sourceStream stream from which data to be processed should be read
- * @return stream from which processed data with the specified format may be read
- * @throws IllegalArgumentException if the format combination supplied is
- * not supported.
- */
- public abstract AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream);
-
+ public abstract AudioInputStream getAudioInputStream(
+ AudioFormat targetFormat, AudioInputStream sourceStream);
}
--- a/jdk/src/share/classes/javax/sound/sampled/spi/MixerProvider.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/javax/sound/sampled/spi/MixerProvider.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -28,28 +28,27 @@
import javax.sound.sampled.Mixer;
/**
- * A provider or factory for a particular mixer type.
- * This mechanism allows the implementation to determine
- * how resources are managed in creation / management of
- * a mixer.
+ * A provider or factory for a particular mixer type. This mechanism allows the
+ * implementation to determine how resources are managed in creation /
+ * management of a mixer.
*
* @author Kara Kytle
* @since 1.3
*/
public abstract class MixerProvider {
-
/**
* Indicates whether the mixer provider supports the mixer represented by
* the specified mixer info object.
* <p>
- * The full set of mixer info objects that represent the mixers supported
- * by this {@code MixerProvider} may be obtained
- * through the {@code getMixerInfo} method.
+ * The full set of mixer info objects that represent the mixers supported by
+ * this {@code MixerProvider} may be obtained through the
+ * {@code getMixerInfo} method.
*
- * @param info an info object that describes the mixer for which support is queried
- * @return {@code true} if the specified mixer is supported,
- * otherwise {@code false}
+ * @param info an info object that describes the mixer for which support is
+ * queried
+ * @return {@code true} if the specified mixer is supported, otherwise
+ * {@code false}
* @see #getMixerInfo()
*/
public boolean isMixerSupported(Mixer.Info info) {
@@ -64,38 +63,34 @@
return false;
}
-
/**
- * Obtains the set of info objects representing the mixer
- * or mixers provided by this MixerProvider.
+ * Obtains the set of info objects representing the mixer or mixers provided
+ * by this MixerProvider.
* <p>
- * The {@code isMixerSupported} method returns {@code true}
- * for all the info objects returned by this method.
- * The corresponding mixer instances for the info objects
- * are returned by the {@code getMixer} method.
+ * The {@code isMixerSupported} method returns {@code true} for all the info
+ * objects returned by this method. The corresponding mixer instances for
+ * the info objects are returned by the {@code getMixer} method.
*
* @return a set of mixer info objects
- * @see #getMixer(javax.sound.sampled.Mixer.Info) getMixer(Mixer.Info)
- * @see #isMixerSupported(javax.sound.sampled.Mixer.Info) isMixerSupported(Mixer.Info)
+ * @see #getMixer(Mixer.Info)
+ * @see #isMixerSupported(Mixer.Info)
*/
public abstract Mixer.Info[] getMixerInfo();
-
/**
* Obtains an instance of the mixer represented by the info object.
* <p>
* The full set of the mixer info objects that represent the mixers
- * supported by this {@code MixerProvider} may be obtained
- * through the {@code getMixerInfo} method.
- * Use the {@code isMixerSupported} method to test whether
- * this {@code MixerProvider} supports a particular mixer.
+ * supported by this {@code MixerProvider} may be obtained through the
+ * {@code getMixerInfo} method. Use the {@code isMixerSupported} method to
+ * test whether this {@code MixerProvider} supports a particular mixer.
*
- * @param info an info object that describes the desired mixer
+ * @param info an info object that describes the desired mixer
* @return mixer instance
* @throws IllegalArgumentException if the info object specified does not
- * match the info object for a mixer supported by this MixerProvider.
+ * match the info object for a mixer supported by this MixerProvider
* @see #getMixerInfo()
- * @see #isMixerSupported(javax.sound.sampled.Mixer.Info) isMixerSupported(Mixer.Info)
+ * @see #isMixerSupported(Mixer.Info)
*/
public abstract Mixer getMixer(Mixer.Info info);
}
--- a/jdk/src/share/classes/javax/swing/JComponent.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/javax/swing/JComponent.java Fri May 23 23:55:14 2014 +0000
@@ -3986,7 +3986,18 @@
* @see AccessibleKeyBinding
* @since 1.4
*/
- public AccessibleKeyBinding getAccessibleKeyBinding() {
+ public AccessibleKeyBinding getAccessibleKeyBinding(){
+ // Try to get the linked label's mnemonic if it exists
+ Object o = getClientProperty(JLabel.LABELED_BY_PROPERTY);
+ if (o instanceof Accessible){
+ AccessibleContext ac = ((Accessible) o).getAccessibleContext();
+ if (ac != null){
+ AccessibleComponent comp = ac.getAccessibleComponent();
+ if (! (comp instanceof AccessibleExtendedComponent))
+ return null;
+ return ((AccessibleExtendedComponent)comp).getAccessibleKeyBinding();
+ }
+ }
return null;
}
} // inner class AccessibleJComponent
--- a/jdk/src/share/classes/javax/swing/border/LineBorder.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/javax/swing/border/LineBorder.java Fri May 23 23:55:14 2014 +0000
@@ -144,8 +144,8 @@
int offs = this.thickness;
int size = offs + offs;
if (this.roundedCorners) {
- int arc = offs + size;
- outer = new RoundRectangle2D.Float(x, y, width, height, arc, arc);
+ float arc = .2f * offs;
+ outer = new RoundRectangle2D.Float(x, y, width, height, offs, offs);
inner = new RoundRectangle2D.Float(x + offs, y + offs, width - size, height - size, arc, arc);
}
else {
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java Fri May 23 23:55:14 2014 +0000
@@ -2271,6 +2271,7 @@
// From the JLF Design Guidelines:
// http://www.oracle.com/technetwork/java/jlf-135985.html
+ @SuppressWarnings("fallthrough")
private static class MetalLayoutStyle extends DefaultLayoutStyle {
private static MetalLayoutStyle INSTANCE = new MetalLayoutStyle();
@@ -2407,4 +2408,4 @@
return 0;
}
}
-}
\ No newline at end of file
+}
--- a/jdk/src/share/classes/javax/swing/plaf/nimbus/skin.laf Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/skin.laf Fri May 23 23:55:14 2014 +0000
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright (c) 1998, 2010, 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
@@ -13424,10 +13424,10 @@
<state stateKeys="Selected">
<style>
<textForeground>
- <matte red="255" green="255" blue="255" alpha="255" uiDefaultParentName="nimbusLightBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0" uiResource="false"/>
+ <matte red="255" green="255" blue="255" alpha="255" uiDefaultParentName="nimbusLightBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0"/>
</textForeground>
<textBackground>
- <matte red="57" green="105" blue="138" alpha="255" uiDefaultParentName="nimbusSelectionBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0" uiResource="false"/>
+ <matte red="57" green="105" blue="138" alpha="255" uiDefaultParentName="nimbusSelectionBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0"/>
</textBackground>
<background/>
<inherit-textForeground>false</inherit-textForeground>
@@ -13453,7 +13453,7 @@
<style>
<textForeground/>
<textBackground>
- <matte red="57" green="105" blue="138" alpha="255" uiDefaultParentName="nimbusSelectionBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0" uiResource="false"/>
+ <matte red="57" green="105" blue="138" alpha="255" uiDefaultParentName="nimbusSelectionBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0"/>
</textBackground>
<background/>
<inherit-textBackground>false</inherit-textBackground>
@@ -13477,7 +13477,7 @@
<state stateKeys="Disabled">
<style>
<textForeground>
- <matte red="142" green="143" blue="145" alpha="255" uiDefaultParentName="nimbusDisabledText" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0" uiResource="false"/>
+ <matte red="142" green="143" blue="145" alpha="255" uiDefaultParentName="nimbusDisabledText" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0"/>
</textForeground>
<textBackground/>
<background/>
@@ -13520,7 +13520,7 @@
</textForeground>
<textBackground/>
<background>
- <matte red="57" green="105" blue="138" alpha="255" uiDefaultParentName="nimbusSelectionBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0" uiResource="false"/>
+ <matte red="57" green="105" blue="138" alpha="255" uiDefaultParentName="nimbusSelectionBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0"/>
</background>
<inherit-textForeground>false</inherit-textForeground>
<inherit-background>false</inherit-background>
--- a/jdk/src/share/classes/javax/swing/text/JTextComponent.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/javax/swing/text/JTextComponent.java Fri May 23 23:55:14 2014 +0000
@@ -4473,6 +4473,7 @@
// composed(uncommitted) text is done here after all input
// method listeners get called for stealing the events.
//
+ @SuppressWarnings("fallthrough")
protected void processInputMethodEvent(InputMethodEvent e) {
// let listeners handle the events
super.processInputMethodEvent(e);
--- a/jdk/src/share/classes/javax/swing/text/html/StyleSheet.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/javax/swing/text/html/StyleSheet.java Fri May 23 23:55:14 2014 +0000
@@ -2324,6 +2324,7 @@
* @param itemNum number to format
* @param type type of ordered list
*/
+ @SuppressWarnings("fallthrough")
String formatItemNum(int itemNum, char type) {
String numStyle = "1";
--- a/jdk/src/share/classes/javax/swing/text/html/parser/ContentModelState.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/javax/swing/text/html/parser/ContentModelState.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2000, 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
@@ -92,12 +92,14 @@
* tokens required in the input stream.
* @return true if the model can terminate without further input
*/
+ @SuppressWarnings("fallthrough")
public boolean terminate() {
switch (model.type) {
case '+':
if ((value == 0) && !(model).empty()) {
return false;
}
+ // Fall through
case '*':
case '?':
return (next == null) || next.terminate();
--- a/jdk/src/share/classes/javax/swing/text/html/parser/Parser.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/javax/swing/text/html/parser/Parser.java Fri May 23 23:55:14 2014 +0000
@@ -906,6 +906,7 @@
if (lower) {
ch = 'a' + (ch - 'A');
}
+ break;
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
@@ -930,6 +931,7 @@
if (lower) {
ch = 'a' + (ch - 'A');
}
+ break;
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
@@ -1268,6 +1270,7 @@
/**
* Parse attribute value. [33] 331:1
*/
+ @SuppressWarnings("fallthrough")
String parseAttributeValue(boolean lower) throws IOException {
int delim = -1;
@@ -1312,6 +1315,7 @@
case '\t':
if (delim < 0)
c = ' ';
+ // Fall through
case ' ':
ch = readCh();
if (delim < 0) {
@@ -1621,6 +1625,7 @@
/**
* Parse a start or end tag.
*/
+ @SuppressWarnings("fallthrough")
void parseTag() throws IOException {
Element elem;
boolean net = false;
@@ -1664,6 +1669,7 @@
continue;
case '>':
ch = readCh();
+ return;
case -1:
return;
default:
@@ -1688,6 +1694,7 @@
switch(ch) {
case '>':
ch = readCh();
+ // Fall through
case -1:
error("invalid.markup");
return;
@@ -1719,6 +1726,7 @@
switch (ch = readCh()) {
case '>':
ch = readCh();
+ // Fall through
case '<':
// empty end tag. either </> or </<
if (recent == null) {
@@ -1737,6 +1745,7 @@
switch (ch) {
case '>':
ch = readCh();
+ break;
case '<':
break;
@@ -1937,6 +1946,7 @@
switch (ch) {
case '/':
net = true;
+ // Fall through
case '>':
ch = readCh();
if (ch == '>' && net) {
--- a/jdk/src/share/classes/javax/swing/text/rtf/RTFGenerator.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/javax/swing/text/rtf/RTFGenerator.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2008, 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
@@ -868,6 +868,7 @@
afterKeyword = false;
}
+@SuppressWarnings("fallthrough")
public void writeCharacter(char ch)
throws IOException
{
--- a/jdk/src/share/classes/javax/swing/text/rtf/RTFParser.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/javax/swing/text/rtf/RTFParser.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2008, 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
@@ -148,6 +148,7 @@
handleText(s);
}
+ @SuppressWarnings("fallthrough")
public void write(char ch)
throws IOException
{
--- a/jdk/src/share/classes/sun/awt/AWTAccessor.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/AWTAccessor.java Fri May 23 23:55:14 2014 +0000
@@ -27,6 +27,7 @@
import sun.misc.Unsafe;
+import javax.accessibility.AccessibleContext;
import java.awt.*;
import java.awt.KeyboardFocusManager;
import java.awt.DefaultKeyboardFocusManager;
@@ -620,7 +621,7 @@
/**
* Returns menus
*/
- Vector getMenus(MenuBar menuBar);
+ Vector<Menu> getMenus(MenuBar menuBar);
}
/**
@@ -662,7 +663,7 @@
/**
* Returns vector of the items that are part of the Menu
*/
- Vector getItems(Menu menu);
+ Vector<MenuItem> getItems(Menu menu);
}
/**
@@ -762,6 +763,14 @@
}
/*
+ * An accessor object for the AccessibleContext class
+ */
+ public interface AccessibleContextAccessor {
+ void setAppContext(AccessibleContext accessibleContext, AppContext appContext);
+ AppContext getAppContext(AccessibleContext accessibleContext);
+ }
+
+ /*
* Accessor instances are initialized in the static initializers of
* corresponding AWT classes by using setters defined below.
*/
@@ -791,6 +800,7 @@
private static ToolkitAccessor toolkitAccessor;
private static InvocationEventAccessor invocationEventAccessor;
private static SystemColorAccessor systemColorAccessor;
+ private static AccessibleContextAccessor accessibleContextAccessor;
/*
* Set an accessor object for the java.awt.Component class.
@@ -1234,4 +1244,21 @@
public static void setSystemColorAccessor(SystemColorAccessor systemColorAccessor) {
AWTAccessor.systemColorAccessor = systemColorAccessor;
}
+
+ /*
+ * Get the accessor object for the javax.accessibility.AccessibleContext class.
+ */
+ public static AccessibleContextAccessor getAccessibleContextAccessor() {
+ if (accessibleContextAccessor == null) {
+ unsafe.ensureClassInitialized(AccessibleContext.class);
+ }
+ return accessibleContextAccessor;
+ }
+
+ /*
+ * Set the accessor object for the javax.accessibility.AccessibleContext class.
+ */
+ public static void setAccessibleContextAccessor(AccessibleContextAccessor accessor) {
+ AWTAccessor.accessibleContextAccessor = accessor;
+ }
}
--- a/jdk/src/share/classes/sun/awt/AWTAutoShutdown.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/AWTAutoShutdown.java Fri May 23 23:55:14 2014 +0000
@@ -35,7 +35,7 @@
import java.util.Set;
import sun.util.logging.PlatformLogger;
-import sun.misc.ThreadGroupUtils;
+import sun.awt.util.ThreadGroupUtils;
/**
* This class is to let AWT shutdown automatically when a user is done
--- a/jdk/src/share/classes/sun/awt/AppContext.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/AppContext.java Fri May 23 23:55:14 2014 +0000
@@ -890,6 +890,7 @@
Supplier<T> supplier) {
final AppContext appContext = AppContext.getAppContext();
+ @SuppressWarnings("unchecked")
SoftReference<T> ref = (SoftReference<T>) appContext.get(key);
if (ref != null) {
final T object = ref.get();
--- a/jdk/src/share/classes/sun/awt/FontConfiguration.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/FontConfiguration.java Fri May 23 23:55:14 2014 +0000
@@ -64,7 +64,7 @@
protected static String osName;
protected static String encoding; // canonical name of default nio charset
protected static Locale startupLocale = null;
- protected static Hashtable localeMap = null;
+ protected static Hashtable<String, String> localeMap = null;
private static FontConfiguration fontConfig;
private static PlatformLogger logger;
protected static boolean isProperties = true;
@@ -159,15 +159,15 @@
short fontNameID = compFontNameIDs[0][0][0];
short fileNameID = getComponentFileID(fontNameID);
final String fileName = mapFileName(getComponentFileName(fileNameID));
- Boolean exists = (Boolean)java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Object run() {
+ Boolean exists = java.security.AccessController.doPrivileged(
+ new java.security.PrivilegedAction<Boolean>() {
+ public Boolean run() {
try {
File f = new File(fileName);
return Boolean.valueOf(f.exists());
}
catch (Exception e) {
- return false;
+ return Boolean.FALSE;
}
}
});
@@ -534,11 +534,11 @@
private short remapLocaleMap(int fontIndex, int styleIndex, short scriptID, short fontID) {
String scriptName = getString(table_scriptIDs[scriptID]);
- String value = (String)localeMap.get(scriptName);
+ String value = localeMap.get(scriptName);
if (value == null) {
String fontName = fontNames[fontIndex];
String styleName = styleNames[styleIndex];
- value = (String)localeMap.get(fontName + "." + styleName + "." + scriptName);
+ value = localeMap.get(fontName + "." + styleName + "." + scriptName);
}
if (value == null) {
return fontID;
@@ -746,7 +746,7 @@
/* Mappings from file encoding to font config name for font supporting
* the corresponding language. This is filled in by initReorderMap()
*/
- protected HashMap reorderMap = null;
+ protected HashMap<String, Object> reorderMap = null;
/* Platform-specific mappings */
protected abstract void initReorderMap();
@@ -777,7 +777,7 @@
if (fontConfig.reorderMap == null) {
fontConfig.initReorderMap();
}
- HashMap reorderMap = fontConfig.reorderMap;
+ HashMap<String, Object> reorderMap = fontConfig.reorderMap;
/* Find the most specific mapping */
String language = startupLocale.getLanguage();
@@ -817,9 +817,9 @@
}
}
- private static Vector splitSequence(String sequence) {
+ private static Vector<String> splitSequence(String sequence) {
//String.split would be more convenient, but incurs big performance penalty
- Vector parts = new Vector();
+ Vector<String> parts = new Vector<>();
int start = 0;
int end;
while ((end = sequence.indexOf(',', start)) >= 0) {
@@ -833,14 +833,14 @@
}
protected String[] split(String sequence) {
- Vector v = splitSequence(sequence);
- return (String[])v.toArray(new String[0]);
+ Vector<String> v = splitSequence(sequence);
+ return v.toArray(new String[0]);
}
////////////////////////////////////////////////////////////////////////
// Methods for extracting information from the fontconfig data for AWT//
////////////////////////////////////////////////////////////////////////
- private Hashtable charsetRegistry = new Hashtable(5);
+ private Hashtable<String, Charset> charsetRegistry = new Hashtable<>(5);
/**
* Returns FontDescriptors describing the physical fonts used for the
@@ -932,9 +932,9 @@
Charset fc = null;
if (charsetName.equals("default")) {
- fc = (Charset) charsetRegistry.get(fontName);
+ fc = charsetRegistry.get(fontName);
} else {
- fc = (Charset) charsetRegistry.get(charsetName);
+ fc = charsetRegistry.get(charsetName);
}
if (fc != null) {
return fc.newEncoder();
@@ -943,8 +943,8 @@
if (!charsetName.startsWith("sun.awt.") && !charsetName.equals("default")) {
fc = Charset.forName(charsetName);
} else {
- Class fcc = (Class) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ Class<?> fcc = AccessController.doPrivileged(new PrivilegedAction<Class<?>>() {
+ public Class<?> run() {
try {
return Class.forName(charsetName, true,
ClassLoader.getSystemClassLoader());
@@ -1377,9 +1377,9 @@
//This method will only be called during build time, do we
//need do PrivilegedAction?
- String osName = (String)java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Object run() {
+ String osName = java.security.AccessController.doPrivileged(
+ new java.security.PrivilegedAction<String>() {
+ public String run() {
return System.getProperty("os.name");
}
});
@@ -2139,7 +2139,7 @@
boolean has1252 = false;
//get the scriptID list
- String[] ss = (String[])splitSequence(value).toArray(EMPTY_STRING_ARRAY);
+ String[] ss = splitSequence(value).toArray(EMPTY_STRING_ARRAY);
short [] sa = new short[ss.length];
for (int i = 0; i < ss.length; i++) {
if ("alphabetic/default".equals(ss[i])) {
--- a/jdk/src/share/classes/sun/awt/HToolkit.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/HToolkit.java Fri May 23 23:55:14 2014 +0000
@@ -214,7 +214,8 @@
throw new HeadlessException();
}
- public Map mapInputMethodHighlight(InputMethodHighlight highlight)
+ public Map<java.awt.font.TextAttribute, ?> mapInputMethodHighlight(
+ InputMethodHighlight highlight)
throws HeadlessException {
throw new HeadlessException();
}
--- a/jdk/src/share/classes/sun/awt/HeadlessToolkit.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/HeadlessToolkit.java Fri May 23 23:55:14 2014 +0000
@@ -29,6 +29,7 @@
import java.awt.dnd.*;
import java.awt.dnd.peer.DragSourceContextPeer;
import java.awt.event.*;
+import java.awt.font.TextAttribute;
import java.awt.im.InputMethodHighlight;
import java.awt.image.*;
import java.awt.datatransfer.Clipboard;
@@ -224,7 +225,7 @@
throw new HeadlessException();
}
- public Map mapInputMethodHighlight(InputMethodHighlight highlight)
+ public Map<TextAttribute, ?> mapInputMethodHighlight(InputMethodHighlight highlight)
throws HeadlessException {
throw new HeadlessException();
}
--- a/jdk/src/share/classes/sun/awt/PlatformFont.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/PlatformFont.java Fri May 23 23:55:14 2014 +0000
@@ -143,7 +143,7 @@
if (len < 1) {
return new CharsetString[0];
}
- Vector mcs = null;
+ Vector<CharsetString> mcs = null;
char[] tmpStr = new char[len];
char tmpChar = defaultChar;
boolean encoded = false;
@@ -198,7 +198,7 @@
}
if (currentFont != fd){
if (mcs == null) {
- mcs = new Vector(3);
+ mcs = new Vector<>(3);
}
mcs.addElement(new CharsetString(tmpStr, lastIndex,
i-lastIndex, currentFont));
@@ -209,16 +209,13 @@
}
CharsetString[] result;
CharsetString cs = new CharsetString(tmpStr, lastIndex,
- len-lastIndex, currentFont);
+ len-lastIndex, currentFont);
if (mcs == null) {
result = new CharsetString[1];
result[0] = cs;
} else {
mcs.addElement(cs);
- result = new CharsetString[mcs.size()];
- for (int i = 0; i < mcs.size(); i++){
- result[i] = (CharsetString)mcs.elementAt(i);
- }
+ result = mcs.toArray(new CharsetString[mcs.size()]);
}
return result;
}
--- a/jdk/src/share/classes/sun/awt/SunToolkit.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/SunToolkit.java Fri May 23 23:55:14 2014 +0000
@@ -1915,6 +1915,7 @@
public synchronized void setWindowDeactivationTime(Window w, long time) {
AppContext ctx = getAppContext(w);
+ @SuppressWarnings("unchecked")
WeakHashMap<Window, Long> map = (WeakHashMap<Window, Long>)ctx.get(DEACTIVATION_TIMES_MAP_KEY);
if (map == null) {
map = new WeakHashMap<Window, Long>();
@@ -1925,6 +1926,7 @@
public synchronized long getWindowDeactivationTime(Window w) {
AppContext ctx = getAppContext(w);
+ @SuppressWarnings("unchecked")
WeakHashMap<Window, Long> map = (WeakHashMap<Window, Long>)ctx.get(DEACTIVATION_TIMES_MAP_KEY);
if (map == null) {
return -1;
--- a/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java Fri May 23 23:55:14 2014 +0000
@@ -57,6 +57,7 @@
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.IllegalCharsetNameException;
+import java.nio.charset.StandardCharsets;
import java.nio.charset.UnsupportedCharsetException;
import java.lang.reflect.Constructor;
@@ -70,22 +71,7 @@
import java.security.PrivilegedExceptionAction;
import java.security.ProtectionDomain;
-import java.util.AbstractMap;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.SortedSet;
-import java.util.Set;
-import java.util.Stack;
-import java.util.TreeMap;
-import java.util.TreeSet;
+import java.util.*;
import sun.util.logging.PlatformLogger;
@@ -164,7 +150,7 @@
tempSet.add("UTF-16BE");
tempSet.add("UTF-16LE");
tempSet.add("UTF-16");
- tempSet.add(getDefaultTextCharset());
+ tempSet.add(Charset.defaultCharset().name());
return Collections.unmodifiableSortedSet(tempSet);
}
}
@@ -178,12 +164,6 @@
private static final Map<String, Boolean> textMIMESubtypeCharsetSupport;
/**
- * Cache of the platform default encoding as specified in the
- * "file.encoding" system property.
- */
- private static String defaultEncoding;
-
- /**
* A collection of all natives listed in flavormap.properties with
* a primary MIME type of "text".
*/
@@ -281,17 +261,7 @@
String encoding = flavor.getParameter("charset");
- return (encoding != null) ? encoding : getDefaultTextCharset();
- }
-
- /**
- * Returns the platform's default character encoding.
- */
- public static String getDefaultTextCharset() {
- if (defaultEncoding != null) {
- return defaultEncoding;
- }
- return defaultEncoding = Charset.defaultCharset().name();
+ return (encoding != null) ? encoding : Charset.defaultCharset().name();
}
/**
@@ -354,7 +324,7 @@
return false;
}
- Class rep_class = flavor.getRepresentationClass();
+ Class<?> rep_class = flavor.getRepresentationClass();
if (flavor.isRepresentationClassReader() ||
String.class.equals(rep_class) ||
@@ -485,7 +455,7 @@
textNatives.add(format);
nativeCharsets.put(format, (charset != null && charset.length() != 0)
- ? charset : getDefaultTextCharset());
+ ? charset : Charset.defaultCharset().name());
if (eoln != null && eoln.length() != 0 && !eoln.equals("\n")) {
nativeEOLNs.put(format, eoln);
}
@@ -726,7 +696,7 @@
* DataFlavors and data formats
* @throws NullPointerException if formats or map is <code>null</code>
*/
- public Set getFlavorsForFormatsAsSet(long[] formats, FlavorTable map) {
+ public Set<DataFlavor> getFlavorsForFormatsAsSet(long[] formats, FlavorTable map) {
Set<DataFlavor> flavorSet = new HashSet<>(formats.length);
for (long format : formats) {
@@ -786,19 +756,17 @@
* clipboard string encoding/decoding, basing on clipboard
* format and localeTransferable(on decoding, if available)
*/
- private String getBestCharsetForTextFormat(Long lFormat,
+ protected String getBestCharsetForTextFormat(Long lFormat,
Transferable localeTransferable) throws IOException
{
String charset = null;
if (localeTransferable != null &&
isLocaleDependentTextFormat(lFormat) &&
- localeTransferable.isDataFlavorSupported(javaTextEncodingFlavor))
- {
+ localeTransferable.isDataFlavorSupported(javaTextEncodingFlavor)) {
try {
- charset = new String(
- (byte[])localeTransferable.getTransferData(javaTextEncodingFlavor),
- "UTF-8"
- );
+ byte[] charsetNameBytes = (byte[])localeTransferable
+ .getTransferData(javaTextEncodingFlavor);
+ charset = new String(charsetNameBytes, StandardCharsets.UTF_8);
} catch (UnsupportedFlavorException cannotHappen) {
}
} else {
@@ -806,7 +774,7 @@
}
if (charset == null) {
// Only happens when we have a custom text type.
- charset = getDefaultTextCharset();
+ charset = Charset.defaultCharset().name();
}
return charset;
}
@@ -1117,7 +1085,7 @@
throw new IOException("data translation failed");
}
- final List list = (List)obj;
+ final List<?> list = (List<?>)obj;
final ProtectionDomain userProtectionDomain = getUserProtectionDomain(contents);
@@ -1145,7 +1113,7 @@
if (targetCharset == null) {
targetCharset = "UTF-8";
}
- final List list = (List)obj;
+ final List<?> list = (List<?>)obj;
final ProtectionDomain userProtectionDomain = getUserProtectionDomain(contents);
final ArrayList<String> fileList = castToFiles(list, userProtectionDomain);
final ArrayList<String> uriList = new ArrayList<>(fileList.size());
@@ -1290,7 +1258,7 @@
return true;
}
- private ArrayList<String> castToFiles(final List files,
+ private ArrayList<String> castToFiles(final List<?> files,
final ProtectionDomain userProtectionDomain) throws IOException {
try {
return AccessController.doPrivileged((PrivilegedExceptionAction<ArrayList<String>>) () -> {
@@ -1668,7 +1636,7 @@
* instance of the Class as its sole parameter.
*/
private Object constructFlavoredObject(Object arg, DataFlavor flavor,
- Class clazz)
+ Class<?> clazz)
throws IOException
{
final Class<?> dfrc = flavor.getRepresentationClass();
@@ -1676,19 +1644,19 @@
if (clazz.equals(dfrc)) {
return arg; // simple case
} else {
- Constructor[] constructors;
+ Constructor<?>[] constructors;
try {
constructors = AccessController.doPrivileged(
- (PrivilegedAction<Constructor[]>) dfrc::getConstructors);
+ (PrivilegedAction<Constructor<?>[]>) dfrc::getConstructors);
} catch (SecurityException se) {
throw new IOException(se.getMessage());
}
- Constructor constructor = Stream.of(constructors)
+ Constructor<?> constructor = Stream.of(constructors)
.filter(c -> Modifier.isPublic(c.getModifiers()))
.filter(c -> {
- Class[] ptypes = c.getParameterTypes();
+ Class<?>[] ptypes = c.getParameterTypes();
return ptypes != null
&& ptypes.length == 1
&& clazz.equals(ptypes[0]);
@@ -1731,28 +1699,8 @@
{
Long lFormat = format;
- String sourceEncoding = null;
- if (isLocaleDependentTextFormat(format) &&
- localeTransferable != null &&
- localeTransferable.
- isDataFlavorSupported(javaTextEncodingFlavor))
- {
- try {
- sourceEncoding = new String((byte[])localeTransferable.
- getTransferData(javaTextEncodingFlavor),
- "UTF-8");
- } catch (UnsupportedFlavorException cannotHappen) {
- }
- } else {
- sourceEncoding = getCharsetForTextFormat(lFormat);
- }
-
- if (sourceEncoding == null) {
- // Only happens when we have a custom text type.
- sourceEncoding = getDefaultTextCharset();
- }
- wrapped = new BufferedReader
- (new InputStreamReader(bytestream, sourceEncoding));
+ String sourceEncoding = getBestCharsetForTextFormat(format, localeTransferable);
+ wrapped = new BufferedReader(new InputStreamReader(bytestream, sourceEncoding));
if (targetEncoding == null) {
// Throw NullPointerException for compatibility with the former
@@ -1917,7 +1865,8 @@
byte[] bytes, String mimeType) throws IOException
{
- Iterator readerIterator = ImageIO.getImageReadersByMIMEType(mimeType);
+ Iterator<ImageReader> readerIterator =
+ ImageIO.getImageReadersByMIMEType(mimeType);
if (!readerIterator.hasNext()) {
throw new IOException("No registered service provider can decode " +
@@ -1927,7 +1876,7 @@
IOException ioe = null;
while (readerIterator.hasNext()) {
- ImageReader imageReader = (ImageReader)readerIterator.next();
+ ImageReader imageReader = readerIterator.next();
try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes)) {
try (ImageInputStream imageInputStream = ImageIO.createImageInputStream(bais)) {
ImageReadParam param = imageReader.getDefaultReadParam();
@@ -1970,7 +1919,8 @@
throws IOException {
IOException originalIOE = null;
- Iterator writerIterator = ImageIO.getImageWritersByMIMEType(mimeType);
+ Iterator<ImageWriter> writerIterator =
+ ImageIO.getImageWritersByMIMEType(mimeType);
if (!writerIterator.hasNext()) {
throw new IOException("No registered service provider can encode " +
@@ -2029,7 +1979,8 @@
String mimeType)
throws IOException {
- Iterator writerIterator = ImageIO.getImageWritersByMIMEType(mimeType);
+ Iterator<ImageWriter> writerIterator =
+ ImageIO.getImageWritersByMIMEType(mimeType);
ImageTypeSpecifier typeSpecifier =
new ImageTypeSpecifier(renderedImage);
@@ -2038,7 +1989,7 @@
IOException ioe = null;
while (writerIterator.hasNext()) {
- ImageWriter imageWriter = (ImageWriter)writerIterator.next();
+ ImageWriter imageWriter = writerIterator.next();
ImageWriterSpi writerSpi = imageWriter.getOriginatingProvider();
if (!writerSpi.canEncodeImage(typeSpecifier)) {
@@ -2122,7 +2073,7 @@
public byte[] convertData(final Object source,
final Transferable contents,
final long format,
- final Map formatMap,
+ final Map<Long, DataFlavor> formatMap,
final boolean isToolkitThread)
throws IOException
{
@@ -2145,7 +2096,7 @@
}
byte[] data = null;
try {
- DataFlavor flavor = (DataFlavor)formatMap.get(format);
+ DataFlavor flavor = formatMap.get(format);
if (flavor != null) {
data = translateTransferable(contents, flavor, format);
}
@@ -2186,7 +2137,7 @@
} finally {
getToolkitThreadBlockedHandler().unlock();
} else {
- DataFlavor flavor = (DataFlavor)formatMap.get(format);
+ DataFlavor flavor = formatMap.get(format);
if (flavor != null) {
ret = translateTransferable(contents, flavor, format);
}
@@ -2235,7 +2186,7 @@
* Helper function to convert a Set of DataFlavors to a sorted array.
* The array will be sorted according to <code>DataFlavorComparator</code>.
*/
- public static DataFlavor[] setToSortedDataFlavorArray(Set flavorsSet) {
+ public static DataFlavor[] setToSortedDataFlavorArray(Set<DataFlavor> flavorsSet) {
DataFlavor[] flavors = new DataFlavor[flavorsSet.size()];
flavorsSet.toArray(flavors);
final Comparator<DataFlavor> comparator =
@@ -2267,8 +2218,8 @@
* If there are no platform-specific mappings for this native, the method
* returns an empty <code>List</code>.
*/
- public List<DataFlavor> getPlatformMappingsForNative(String nat) {
- return new ArrayList<>();
+ public LinkedHashSet<DataFlavor> getPlatformMappingsForNative(String nat) {
+ return new LinkedHashSet<>();
}
/**
@@ -2276,8 +2227,8 @@
* If there are no platform-specific mappings for this flavor, the method
* returns an empty <code>List</code>.
*/
- public List<String> getPlatformMappingsForFlavor(DataFlavor df) {
- return new ArrayList<>();
+ public LinkedHashSet<String> getPlatformMappingsForFlavor(DataFlavor df) {
+ return new LinkedHashSet<>();
}
/**
@@ -2333,7 +2284,6 @@
*/
public static class CharsetComparator extends IndexedComparator<String> {
private static final Map<String, Integer> charsets;
- private static final String defaultEncoding;
private static final Integer DEFAULT_CHARSET_INDEX = 2;
private static final Integer OTHER_CHARSET_INDEX = 1;
@@ -2354,8 +2304,7 @@
// US-ASCII is the worst charset supported
charsetsMap.put(canonicalName("US-ASCII"), WORST_CHARSET_INDEX);
- defaultEncoding = DataTransferer.canonicalName(DataTransferer.getDefaultTextCharset());
- charsetsMap.putIfAbsent(defaultEncoding, DEFAULT_CHARSET_INDEX);
+ charsetsMap.putIfAbsent(Charset.defaultCharset().name(), DEFAULT_CHARSET_INDEX);
charsetsMap.put(UNSUPPORTED_CHARSET, UNSUPPORTED_CHARSET_INDEX);
@@ -2598,12 +2547,12 @@
String primaryType1 = flavor1.getPrimaryType();
String subType1 = flavor1.getSubType();
String mimeType1 = primaryType1 + "/" + subType1;
- Class class1 = flavor1.getRepresentationClass();
+ Class<?> class1 = flavor1.getRepresentationClass();
String primaryType2 = flavor2.getPrimaryType();
String subType2 = flavor2.getSubType();
String mimeType2 = primaryType2 + "/" + subType2;
- Class class2 = flavor2.getRepresentationClass();
+ Class<?> class2 = flavor2.getRepresentationClass();
if (flavor1.isFlavorTextType() && flavor2.isFlavorTextType()) {
// First, compare MIME types
--- a/jdk/src/share/classes/sun/awt/datatransfer/SunClipboard.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/datatransfer/SunClipboard.java Fri May 23 23:55:14 2014 +0000
@@ -78,7 +78,7 @@
* this clipboard. It is used for tracking changes
* of <code>DataFlavor</code>s available on this clipboard.
*/
- private volatile Set currentDataFlavors;
+ private volatile Set<DataFlavor> currentDataFlavors;
public SunClipboard(String name) {
@@ -338,7 +338,7 @@
protected abstract byte[] getClipboardData(long format) throws IOException;
- private static Set formatArrayAsDataFlavorSet(long[] formats) {
+ private static Set<DataFlavor> formatArrayAsDataFlavorSet(long[] formats) {
return (formats == null) ? null :
DataTransferer.getInstance().
getFlavorsForFormatsAsSet(formats, getDefaultFlavorTable());
@@ -417,7 +417,7 @@
* this clipboard
*/
public void checkChange(long[] formats) {
- Set prevDataFlavors = currentDataFlavors;
+ Set<DataFlavor> prevDataFlavors = currentDataFlavors;
currentDataFlavors = formatArrayAsDataFlavorSet(formats);
if (Objects.equals(prevDataFlavors, currentDataFlavors)) {
--- a/jdk/src/share/classes/sun/awt/datatransfer/TransferableProxy.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/datatransfer/TransferableProxy.java Fri May 23 23:55:14 2014 +0000
@@ -111,9 +111,9 @@
}
protected void annotateClass(final Class<?> cl) throws IOException {
- ClassLoader classLoader =
- (ClassLoader)AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ ClassLoader classLoader = AccessController.doPrivileged(
+ new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
return cl.getClassLoader();
}
});
@@ -124,14 +124,14 @@
map.put(s, classLoader);
}
protected void annotateProxyClass(final Class<?> cl) throws IOException {
- ClassLoader classLoader =
- (ClassLoader)AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ ClassLoader classLoader = AccessController.doPrivileged(
+ new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
return cl.getClassLoader();
}
});
- Class[] interfaces = cl.getInterfaces();
+ Class<?>[] interfaces = cl.getInterfaces();
Set<String> s = new HashSet<String>(interfaces.length);
for (int i = 0; i < interfaces.length; i++) {
s.add(interfaces[i].getName());
@@ -141,7 +141,7 @@
}
Map<Set<String>, ClassLoader> getClassLoaderMap() {
- return new HashMap(map);
+ return new HashMap<>(map);
}
}
@@ -191,9 +191,9 @@
boolean hasNonPublicInterface = false;
// define proxy in class loader of non-public interface(s), if any
- Class[] classObjs = new Class[interfaces.length];
+ Class<?>[] classObjs = new Class<?>[interfaces.length];
for (int i = 0; i < interfaces.length; i++) {
- Class cl = Class.forName(interfaces[i], false, classLoader);
+ Class<?> cl = Class.forName(interfaces[i], false, classLoader);
if ((cl.getModifiers() & Modifier.PUBLIC) == 0) {
if (hasNonPublicInterface) {
if (nonPublicLoader != cl.getClassLoader()) {
--- a/jdk/src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java Fri May 23 23:55:14 2014 +0000
@@ -146,7 +146,7 @@
}
protected abstract void startDrag(Transferable trans,
- long[] formats, Map formatMap);
+ long[] formats, Map<Long, DataFlavor> formatMap);
/**
* set cursor
--- a/jdk/src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java Fri May 23 23:55:14 2014 +0000
@@ -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
@@ -239,17 +239,24 @@
if (localTransferable != null) {
return localTransferable.getTransferData(df);
+ } else if (df.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType)) {
+ // Workaround to JDK-8024061: Exception thrown when drag and drop
+ // between two components is executed quickly.
+ // It is expected localTransferable is not null if javaJVMLocalObjectMimeType
+ // is used. Executing further results in ClassCastException, so null is
+ // returned here as no transfer data is available in this case.
+ return null;
}
if (dropStatus != STATUS_ACCEPT || dropComplete) {
throw new InvalidDnDOperationException("No drop current");
}
- Map flavorMap = DataTransferer.getInstance().getFlavorsForFormats
- (currentT, DataTransferer.adaptFlavorMap
+ Map<DataFlavor, Long> flavorMap = DataTransferer.getInstance()
+ .getFlavorsForFormats(currentT, DataTransferer.adaptFlavorMap
(currentDT.getFlavorMap()));
- lFormat = (Long)flavorMap.get(df);
+ lFormat = flavorMap.get(df);
if (lFormat == null) {
throw new UnsupportedFlavorException(df);
}
@@ -738,7 +745,7 @@
// dispatcher state fields
private int returnValue = 0;
// set of events to be dispatched by this dispatcher
- private final HashSet eventSet = new HashSet(3);
+ private final HashSet<SunDropTargetEvent> eventSet = new HashSet<>(3);
static final ToolkitThreadBlockedHandler handler =
DataTransferer.getInstance().getToolkitThreadBlockedHandler();
--- a/jdk/src/share/classes/sun/awt/geom/AreaOp.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/geom/AreaOp.java Fri May 23 23:55:14 2014 +0000
@@ -152,36 +152,36 @@
public abstract int getState();
- public Vector calculate(Vector left, Vector right) {
- Vector edges = new Vector();
+ public Vector<Curve> calculate(Vector<Curve> left, Vector<Curve> right) {
+ Vector<Edge> edges = new Vector<>();
addEdges(edges, left, AreaOp.CTAG_LEFT);
addEdges(edges, right, AreaOp.CTAG_RIGHT);
- edges = pruneEdges(edges);
+ Vector<Curve> curves = pruneEdges(edges);
if (false) {
System.out.println("result: ");
- int numcurves = edges.size();
- Curve[] curvelist = (Curve[]) edges.toArray(new Curve[numcurves]);
+ int numcurves = curves.size();
+ Curve[] curvelist = curves.toArray(new Curve[numcurves]);
for (int i = 0; i < numcurves; i++) {
System.out.println("curvelist["+i+"] = "+curvelist[i]);
}
}
- return edges;
+ return curves;
}
- private static void addEdges(Vector edges, Vector curves, int curvetag) {
- Enumeration enum_ = curves.elements();
+ private static void addEdges(Vector<Edge> edges, Vector<Curve> curves, int curvetag) {
+ Enumeration<Curve> enum_ = curves.elements();
while (enum_.hasMoreElements()) {
- Curve c = (Curve) enum_.nextElement();
+ Curve c = enum_.nextElement();
if (c.getOrder() > 0) {
edges.add(new Edge(c, curvetag));
}
}
}
- private static Comparator YXTopComparator = new Comparator() {
- public int compare(Object o1, Object o2) {
- Curve c1 = ((Edge) o1).getCurve();
- Curve c2 = ((Edge) o2).getCurve();
+ private static Comparator<Edge> YXTopComparator = new Comparator<Edge>() {
+ public int compare(Edge o1, Edge o2) {
+ Curve c1 = o1.getCurve();
+ Curve c2 = o2.getCurve();
double v1, v2;
if ((v1 = c1.getYTop()) == (v2 = c2.getYTop())) {
if ((v1 = c1.getXTop()) == (v2 = c2.getXTop())) {
@@ -195,12 +195,13 @@
}
};
- private Vector pruneEdges(Vector edges) {
+ private Vector<Curve> pruneEdges(Vector<Edge> edges) {
int numedges = edges.size();
if (numedges < 2) {
- return edges;
+ // empty vector is expected with less than 2 edges
+ return new Vector<>();
}
- Edge[] edgelist = (Edge[]) edges.toArray(new Edge[numedges]);
+ Edge[] edgelist = edges.toArray(new Edge[numedges]);
Arrays.sort(edgelist, YXTopComparator);
if (false) {
System.out.println("pruning: ");
@@ -214,9 +215,9 @@
int cur = 0;
int next = 0;
double yrange[] = new double[2];
- Vector subcurves = new Vector();
- Vector chains = new Vector();
- Vector links = new Vector();
+ Vector<CurveLink> subcurves = new Vector<>();
+ Vector<ChainEnd> chains = new Vector<>();
+ Vector<CurveLink> links = new Vector<>();
// Active edges are between left (inclusive) and right (exclusive)
while (left < numedges) {
double y = yrange[0];
@@ -385,7 +386,7 @@
if (false) {
System.out.println("new links:");
for (int i = 0; i < links.size(); i++) {
- CurveLink link = (CurveLink) links.elementAt(i);
+ CurveLink link = links.elementAt(i);
System.out.println(" "+link.getSubCurve());
}
}
@@ -396,10 +397,10 @@
yrange[0] = yend;
}
finalizeSubCurves(subcurves, chains);
- Vector ret = new Vector();
- Enumeration enum_ = subcurves.elements();
+ Vector<Curve> ret = new Vector<>();
+ Enumeration<CurveLink> enum_ = subcurves.elements();
while (enum_.hasMoreElements()) {
- CurveLink link = (CurveLink) enum_.nextElement();
+ CurveLink link = enum_.nextElement();
ret.add(link.getMoveto());
CurveLink nextlink = link;
while ((nextlink = nextlink.getNext()) != null) {
@@ -413,7 +414,8 @@
return ret;
}
- public static void finalizeSubCurves(Vector subcurves, Vector chains) {
+ public static void finalizeSubCurves(Vector<CurveLink> subcurves,
+ Vector<ChainEnd> chains) {
int numchains = chains.size();
if (numchains == 0) {
return;
@@ -437,9 +439,9 @@
private static CurveLink[] EmptyLinkList = new CurveLink[2];
private static ChainEnd[] EmptyChainList = new ChainEnd[2];
- public static void resolveLinks(Vector subcurves,
- Vector chains,
- Vector links)
+ public static void resolveLinks(Vector<CurveLink> subcurves,
+ Vector<ChainEnd> chains,
+ Vector<CurveLink> links)
{
int numlinks = links.size();
CurveLink[] linklist;
--- a/jdk/src/share/classes/sun/awt/geom/Crossings.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/geom/Crossings.java Fri May 23 23:55:14 2014 +0000
@@ -77,14 +77,14 @@
public abstract boolean covers(double ystart, double yend);
- public static Crossings findCrossings(Vector curves,
+ public static Crossings findCrossings(Vector<? extends Curve> curves,
double xlo, double ylo,
double xhi, double yhi)
{
Crossings cross = new EvenOdd(xlo, ylo, xhi, yhi);
- Enumeration enum_ = curves.elements();
+ Enumeration<? extends Curve> enum_ = curves.elements();
while (enum_.hasMoreElements()) {
- Curve c = (Curve) enum_.nextElement();
+ Curve c = enum_.nextElement();
if (c.accumulateCrossings(cross)) {
return null;
}
@@ -237,7 +237,7 @@
return false;
}
- private Vector tmp = new Vector();
+ private Vector<Curve> tmp = new Vector<>();
public boolean accumulateQuad(double x0, double y0, double coords[]) {
if (y0 < ylo && coords[1] < ylo && coords[3] < ylo) {
@@ -258,9 +258,9 @@
return false;
}
Curve.insertQuad(tmp, x0, y0, coords);
- Enumeration enum_ = tmp.elements();
+ Enumeration<Curve> enum_ = tmp.elements();
while (enum_.hasMoreElements()) {
- Curve c = (Curve) enum_.nextElement();
+ Curve c = enum_.nextElement();
if (c.accumulateCrossings(this)) {
return true;
}
@@ -296,9 +296,9 @@
return false;
}
Curve.insertCubic(tmp, x0, y0, coords);
- Enumeration enum_ = tmp.elements();
+ Enumeration<Curve> enum_ = tmp.elements();
while (enum_.hasMoreElements()) {
- Curve c = (Curve) enum_.nextElement();
+ Curve c = enum_.nextElement();
if (c.accumulateCrossings(this)) {
return true;
}
--- a/jdk/src/share/classes/sun/awt/geom/Curve.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/geom/Curve.java Fri May 23 23:55:14 2014 +0000
@@ -38,11 +38,11 @@
protected int direction;
- public static void insertMove(Vector curves, double x, double y) {
+ public static void insertMove(Vector<Curve> curves, double x, double y) {
curves.add(new Order0(x, y));
}
- public static void insertLine(Vector curves,
+ public static void insertLine(Vector<Curve> curves,
double x0, double y0,
double x1, double y1)
{
@@ -59,7 +59,7 @@
}
}
- public static void insertQuad(Vector curves,
+ public static void insertQuad(Vector<Curve> curves,
double x0, double y0,
double coords[])
{
@@ -82,7 +82,7 @@
}
}
- public static void insertCubic(Vector curves,
+ public static void insertCubic(Vector<Curve> curves,
double x0, double y0,
double coords[])
{
--- a/jdk/src/share/classes/sun/awt/geom/Order2.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/geom/Order2.java Fri May 23 23:55:14 2014 +0000
@@ -47,7 +47,7 @@
private double ycoeff1;
private double ycoeff2;
- public static void insert(Vector curves, double tmp[],
+ public static void insert(Vector<Curve> curves, double tmp[],
double x0, double y0,
double cx0, double cy0,
double x1, double y1,
@@ -74,7 +74,7 @@
tmp[i1 + 4], tmp[i1 + 5], direction);
}
- public static void addInstance(Vector curves,
+ public static void addInstance(Vector<Curve> curves,
double x0, double y0,
double cx0, double cy0,
double x1, double y1,
--- a/jdk/src/share/classes/sun/awt/geom/Order3.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/geom/Order3.java Fri May 23 23:55:14 2014 +0000
@@ -53,7 +53,7 @@
private double ycoeff2;
private double ycoeff3;
- public static void insert(Vector curves, double tmp[],
+ public static void insert(Vector<Curve> curves, double tmp[],
double x0, double y0,
double cx0, double cy0,
double cx1, double cy1,
@@ -105,7 +105,7 @@
}
}
- public static void addInstance(Vector curves,
+ public static void addInstance(Vector<Curve> curves,
double x0, double y0,
double cx0, double cy0,
double cx1, double cy1,
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/awt/image/AbstractMultiResolutionImage.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,123 @@
+/*
+ * 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+package sun.awt.image;
+
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.image.*;
+
+/**
+ * This class provides default implementations for the
+ * <code>MultiResolutionImage</code> interface. The developer needs only
+ * to subclass this abstract class and define the <code>getResolutionVariant</code>,
+ * <code>getResolutionVariants</code>, and <code>getBaseImage</code> methods.
+ *
+ *
+ * For example,
+ * {@code
+ * public class CustomMultiResolutionImage extends AbstractMultiResolutionImage {
+ *
+ * int baseImageIndex;
+ * Image[] resolutionVariants;
+ *
+ * public CustomMultiResolutionImage(int baseImageIndex,
+ * Image... resolutionVariants) {
+ * this.baseImageIndex = baseImageIndex;
+ * this.resolutionVariants = resolutionVariants;
+ * }
+ *
+ * @Override
+ * public Image getResolutionVariant(float logicalDPIX, float logicalDPIY,
+ * float baseImageWidth, float baseImageHeight,
+ * float destImageWidth, float destImageHeight) {
+ * // return a resolution variant based on the given logical DPI,
+ * // base image size, or destination image size
+ * }
+ *
+ * @Override
+ * public List<Image> getResolutionVariants() {
+ * return Arrays.asList(resolutionVariants);
+ * }
+ *
+ * protected Image getBaseImage() {
+ * return resolutionVariants[baseImageIndex];
+ * }
+ * }
+ * }
+ *
+ * @see java.awt.Image
+ * @see java.awt.image.MultiResolutionImage
+ *
+ * @since 1.9
+ */
+public abstract class AbstractMultiResolutionImage extends java.awt.Image
+ implements MultiResolutionImage {
+
+ /**
+ * @inheritDoc
+ */
+ @Override
+ public int getWidth(ImageObserver observer) {
+ return getBaseImage().getWidth(null);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ @Override
+ public int getHeight(ImageObserver observer) {
+ return getBaseImage().getHeight(null);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ @Override
+ public ImageProducer getSource() {
+ return getBaseImage().getSource();
+ }
+
+ /**
+ * @inheritDoc
+ */
+ @Override
+ public Graphics getGraphics() {
+ return getBaseImage().getGraphics();
+
+ }
+
+ /**
+ * @inheritDoc
+ */
+ @Override
+ public Object getProperty(String name, ImageObserver observer) {
+ return getBaseImage().getProperty(name, observer);
+ }
+
+ /**
+ * @return base image
+ */
+ protected abstract Image getBaseImage();
+}
--- a/jdk/src/share/classes/sun/awt/image/BufImgSurfaceData.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/image/BufImgSurfaceData.java Fri May 23 23:55:14 2014 +0000
@@ -51,7 +51,7 @@
private BufferedImageGraphicsConfig graphicsConfig;
RenderLoops solidloops;
- private static native void initIDs(Class ICM, Class ICMColorData);
+ private static native void initIDs(Class<?> ICM, Class<?> ICMColorData);
private static final int DCM_RGBX_RED_MASK = 0xff000000;
private static final int DCM_RGBX_GREEN_MASK = 0x00ff0000;
--- a/jdk/src/share/classes/sun/awt/image/GifImageDecoder.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/image/GifImageDecoder.java Fri May 23 23:55:14 2014 +0000
@@ -61,7 +61,7 @@
int trans_pixel = -1;
IndexColorModel global_model;
- Hashtable props = new Hashtable();
+ Hashtable<String, Object> props = new Hashtable<>();
byte[] saved_image;
IndexColorModel saved_model;
--- a/jdk/src/share/classes/sun/awt/image/ImageDecoder.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/image/ImageDecoder.java Fri May 23 23:55:14 2014 +0000
@@ -83,7 +83,7 @@
return count;
}
- protected int setProperties(Hashtable props) {
+ protected int setProperties(Hashtable<?,?> props) {
ImageConsumerQueue cq = null;
int count = 0;
while ((cq = nextConsumer(cq)) != null) {
@@ -164,7 +164,7 @@
source.doneDecoding(this);
close();
java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
+ new java.security.PrivilegedAction<Object>() {
public Object run() {
feeder.interrupt();
return null;
--- a/jdk/src/share/classes/sun/awt/image/ImageFetcher.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/image/ImageFetcher.java Fri May 23 23:55:14 2014 +0000
@@ -152,7 +152,7 @@
info.numWaiting--;
}
}
- src = (ImageFetchable) info.waitList.elementAt(0);
+ src = info.waitList.elementAt(0);
info.waitList.removeElement(src);
}
return src;
@@ -303,26 +303,25 @@
final ThreadGroup fetcherGroup = fetcherThreadGroup;
java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Object run() {
- for (int i = 0; i < info.fetchers.length; i++) {
- if (info.fetchers[i] == null) {
- ImageFetcher f = new ImageFetcher(
- fetcherGroup, i);
- try {
- f.start();
- info.fetchers[i] = f;
- info.numFetchers++;
- break;
- } catch (Error e) {
+ new java.security.PrivilegedAction<Object>() {
+ public Object run() {
+ for (int i = 0; i < info.fetchers.length; i++) {
+ if (info.fetchers[i] == null) {
+ ImageFetcher f = new ImageFetcher(fetcherGroup, i);
+ try {
+ f.start();
+ info.fetchers[i] = f;
+ info.numFetchers++;
+ break;
+ } catch (Error e) {
+ }
}
+ }
+ return null;
}
- }
- return null;
- }
- });
- return;
- }
+ });
+ return;
+ }
}
@@ -337,13 +336,13 @@
Thread[] fetchers;
int numFetchers;
int numWaiting;
- Vector waitList;
+ Vector<ImageFetchable> waitList;
private FetcherInfo() {
fetchers = new Thread[MAX_NUM_FETCHERS_PER_APPCONTEXT];
numFetchers = 0;
numWaiting = 0;
- waitList = new Vector();
+ waitList = new Vector<>();
}
/* The key to put()/get() the FetcherInfo into/from the AppContext. */
--- a/jdk/src/share/classes/sun/awt/image/ImageRepresentation.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/image/ImageRepresentation.java Fri May 23 23:55:14 2014 +0000
@@ -185,7 +185,7 @@
protected BufferedImage createImage(ColorModel cm,
WritableRaster raster,
boolean isRasterPremultiplied,
- Hashtable properties)
+ Hashtable<?,?> properties)
{
BufferedImage bi =
new BufferedImage(cm, raster, isRasterPremultiplied, null);
--- a/jdk/src/share/classes/sun/awt/image/ImagingLib.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/image/ImagingLib.java Fri May 23 23:55:14 2014 +0000
@@ -61,7 +61,7 @@
private static final int AFFINE_OP = 1;
private static final int CONVOLVE_OP = 2;
- private static Class[] nativeOpClass = new Class[NUM_NATIVE_OPS];
+ private static Class<?>[] nativeOpClass = new Class<?>[NUM_NATIVE_OPS];
/**
* Returned value indicates whether the library initailization was
@@ -134,7 +134,7 @@
}
- private static int getNativeOpIndex(Class opClass) {
+ private static int getNativeOpIndex(Class<?> opClass) {
//
// Search for this class in cached list of
// classes supplying native acceleration
--- a/jdk/src/share/classes/sun/awt/image/JPEGImageDecoder.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/image/JPEGImageDecoder.java Fri May 23 23:55:14 2014 +0000
@@ -47,8 +47,8 @@
private static ColorModel ARGBcolormodel;
private static ColorModel Graycolormodel;
- private static final Class InputStreamClass = InputStream.class;
- private static native void initIDs(Class InputStreamClass);
+ private static final Class<?> InputStreamClass = InputStream.class;
+ private static native void initIDs(Class<?> InputStreamClass);
private ColorModel colormodel;
@@ -73,7 +73,7 @@
private native void readImage(InputStream is, byte buf[])
throws ImageFormatException, IOException;
- Hashtable props = new Hashtable();
+ Hashtable<String, Object> props = new Hashtable<>();
public JPEGImageDecoder(InputStreamImageSource src, InputStream is) {
super(src, is);
--- a/jdk/src/share/classes/sun/awt/image/MultiResolutionBufferedImage.java Thu May 22 20:24:42 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,185 +0,0 @@
-/*
- * 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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.
- */
-package sun.awt.image;
-
-import java.awt.Dimension;
-import java.awt.Image;
-import java.awt.Graphics;
-import java.awt.geom.Dimension2D;
-import java.awt.image.BufferedImage;
-import java.awt.image.ImageObserver;
-import java.util.Arrays;
-import java.util.List;
-import java.util.function.Function;
-import java.util.function.BiFunction;
-import java.util.stream.Collectors;
-
-public class MultiResolutionBufferedImage extends BufferedImage
- implements MultiResolutionImage {
-
- private final BiFunction<Integer, Integer, Image> mapper;
- private final Dimension2D[] sizes;
- private int availableInfo;
-
- public MultiResolutionBufferedImage(Image baseImage,
- BiFunction<Integer, Integer, Image> mapper) {
- this(baseImage, new Dimension[]{new Dimension(
- baseImage.getWidth(null), baseImage.getHeight(null))
- }, mapper);
- }
-
- public MultiResolutionBufferedImage(Image baseImage,
- Dimension2D[] sizes, BiFunction<Integer, Integer, Image> mapper) {
- super(baseImage.getWidth(null), baseImage.getHeight(null),
- BufferedImage.TYPE_INT_ARGB_PRE);
- this.sizes = sizes;
- this.mapper = mapper;
- this.availableInfo = getInfo(baseImage);
- Graphics g = getGraphics();
- g.drawImage(baseImage, 0, 0, null);
- g.dispose();
- }
-
- @Override
- public Image getResolutionVariant(int width, int height) {
- int baseWidth = getWidth();
- int baseHeight = getHeight();
-
- if (baseWidth == width && baseHeight == height) {
- return this;
- }
-
- ImageCache cache = ImageCache.getInstance();
- ImageCacheKey key = new ImageCacheKey(this, width, height);
- Image resolutionVariant = cache.getImage(key);
- if (resolutionVariant == null) {
- resolutionVariant = mapper.apply(width, height);
- cache.setImage(key, resolutionVariant);
- preload(resolutionVariant, availableInfo);
- }
-
- return resolutionVariant;
- }
-
- @Override
- public List<Image> getResolutionVariants() {
- return Arrays.stream(sizes).map((Function<Dimension2D, Image>) size
- -> getResolutionVariant((int) size.getWidth(),
- (int) size.getHeight())).collect(Collectors.toList());
- }
-
- public MultiResolutionBufferedImage map(Function<Image, Image> mapper) {
- return new MultiResolutionBufferedImage(mapper.apply(this), sizes,
- (width, height) ->
- mapper.apply(getResolutionVariant(width, height)));
- }
-
- @Override
- public int getWidth(ImageObserver observer) {
- availableInfo |= ImageObserver.WIDTH;
- return super.getWidth(observer);
- }
-
- @Override
- public int getHeight(ImageObserver observer) {
- availableInfo |= ImageObserver.HEIGHT;
- return super.getHeight(observer);
- }
-
- @Override
- public Object getProperty(String name, ImageObserver observer) {
- availableInfo |= ImageObserver.PROPERTIES;
- return super.getProperty(name, observer);
- }
-
- private static int getInfo(Image image) {
- if (image instanceof ToolkitImage) {
- return ((ToolkitImage) image).getImageRep().check(
- (img, infoflags, x, y, w, h) -> false);
- }
- return 0;
- }
-
- private static void preload(Image image, int availableInfo) {
- if (availableInfo != 0 && image instanceof ToolkitImage) {
- ((ToolkitImage) image).preload(new ImageObserver() {
- int flags = availableInfo;
-
- @Override
- public boolean imageUpdate(Image img, int infoflags,
- int x, int y, int width, int height) {
- flags &= ~infoflags;
- return (flags != 0) && ((infoflags
- & (ImageObserver.ERROR | ImageObserver.ABORT)) == 0);
- }
- });
- }
- }
-
- private static class ImageCacheKey implements ImageCache.PixelsKey {
-
- private final int pixelCount;
- private final int hash;
-
- private final int w;
- private final int h;
- private final Image baseImage;
-
- ImageCacheKey(final Image baseImage,
- final int w, final int h) {
- this.baseImage = baseImage;
- this.w = w;
- this.h = h;
- this.pixelCount = w * h;
- hash = hash();
- }
-
- @Override
- public int getPixelCount() {
- return pixelCount;
- }
-
- private int hash() {
- int hash = baseImage.hashCode();
- hash = 31 * hash + w;
- hash = 31 * hash + h;
- return hash;
- }
-
- @Override
- public int hashCode() {
- return hash;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof ImageCacheKey) {
- ImageCacheKey key = (ImageCacheKey) obj;
- return baseImage == key.baseImage && w == key.w && h == key.h;
- }
- return false;
- }
- }
-}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/awt/image/MultiResolutionCachedImage.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,181 @@
+/*
+ * 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+package sun.awt.image;
+
+import java.awt.Dimension;
+import java.awt.Image;
+import java.awt.geom.Dimension2D;
+import java.awt.image.ImageObserver;
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Function;
+import java.util.function.BiFunction;
+import java.util.stream.Collectors;
+
+public class MultiResolutionCachedImage extends AbstractMultiResolutionImage {
+
+ private final int baseImageWidth;
+ private final int baseImageHeight;
+ private final Dimension2D[] sizes;
+ private final BiFunction<Integer, Integer, Image> mapper;
+ private int availableInfo;
+
+ public MultiResolutionCachedImage(int baseImageWidth, int baseImageHeight,
+ BiFunction<Integer, Integer, Image> mapper) {
+ this(baseImageWidth, baseImageHeight, new Dimension[]{new Dimension(
+ baseImageWidth, baseImageHeight)
+ }, mapper);
+ }
+
+ public MultiResolutionCachedImage(int baseImageWidth, int baseImageHeight,
+ Dimension2D[] sizes, BiFunction<Integer, Integer, Image> mapper) {
+ this.baseImageWidth = baseImageWidth;
+ this.baseImageHeight = baseImageHeight;
+ this.sizes = sizes;
+ this.mapper = mapper;
+ }
+
+ @Override
+ public Image getResolutionVariant(int width, int height) {
+ ImageCache cache = ImageCache.getInstance();
+ ImageCacheKey key = new ImageCacheKey(this, width, height);
+ Image resolutionVariant = cache.getImage(key);
+ if (resolutionVariant == null) {
+ resolutionVariant = mapper.apply(width, height);
+ cache.setImage(key, resolutionVariant);
+ }
+ preload(resolutionVariant, availableInfo);
+ return resolutionVariant;
+ }
+
+ @Override
+ public List<Image> getResolutionVariants() {
+ return Arrays.stream(sizes).map((Function<Dimension2D, Image>) size
+ -> getResolutionVariant((int) size.getWidth(),
+ (int) size.getHeight())).collect(Collectors.toList());
+ }
+
+ public MultiResolutionCachedImage map(Function<Image, Image> mapper) {
+ return new MultiResolutionCachedImage(baseImageWidth, baseImageHeight,
+ sizes, (width, height) ->
+ mapper.apply(getResolutionVariant(width, height)));
+ }
+
+ @Override
+ public int getWidth(ImageObserver observer) {
+ updateInfo(observer, ImageObserver.WIDTH);
+ return super.getWidth(observer);
+ }
+
+ @Override
+ public int getHeight(ImageObserver observer) {
+ updateInfo(observer, ImageObserver.HEIGHT);
+ return super.getHeight(observer);
+ }
+
+ @Override
+ public Object getProperty(String name, ImageObserver observer) {
+ updateInfo(observer, ImageObserver.PROPERTIES);
+ return super.getProperty(name, observer);
+ }
+
+ @Override
+ protected Image getBaseImage() {
+ return getResolutionVariant(baseImageWidth, baseImageHeight);
+ }
+
+ private void updateInfo(ImageObserver observer, int info) {
+ availableInfo |= (observer == null) ? ImageObserver.ALLBITS : info;
+ }
+
+ private static int getInfo(Image image) {
+ if (image instanceof ToolkitImage) {
+ return ((ToolkitImage) image).getImageRep().check(
+ (img, infoflags, x, y, w, h) -> false);
+ }
+ return 0;
+ }
+
+ private static void preload(Image image, int availableInfo) {
+ if (availableInfo != 0 && image instanceof ToolkitImage) {
+ ((ToolkitImage) image).preload(new ImageObserver() {
+ int flags = availableInfo;
+
+ @Override
+ public boolean imageUpdate(Image img, int infoflags,
+ int x, int y, int width, int height) {
+ flags &= ~infoflags;
+ return (flags != 0) && ((infoflags
+ & (ImageObserver.ERROR | ImageObserver.ABORT)) == 0);
+ }
+ });
+ }
+ }
+
+ private static class ImageCacheKey implements ImageCache.PixelsKey {
+
+ private final int pixelCount;
+ private final int hash;
+
+ private final int w;
+ private final int h;
+ private final Image baseImage;
+
+ ImageCacheKey(final Image baseImage,
+ final int w, final int h) {
+ this.baseImage = baseImage;
+ this.w = w;
+ this.h = h;
+ this.pixelCount = w * h;
+ hash = hash();
+ }
+
+ @Override
+ public int getPixelCount() {
+ return pixelCount;
+ }
+
+ private int hash() {
+ int hash = baseImage.hashCode();
+ hash = 31 * hash + w;
+ hash = 31 * hash + h;
+ return hash;
+ }
+
+ @Override
+ public int hashCode() {
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof ImageCacheKey) {
+ ImageCacheKey key = (ImageCacheKey) obj;
+ return baseImage == key.baseImage && w == key.w && h == key.h;
+ }
+ return false;
+ }
+ }
+}
\ No newline at end of file
--- a/jdk/src/share/classes/sun/awt/image/OffScreenImageSource.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/image/OffScreenImageSource.java Fri May 23 23:55:14 2014 +0000
@@ -40,15 +40,15 @@
BufferedImage image;
int width;
int height;
- Hashtable properties;
+ Hashtable<?, ?> properties;
public OffScreenImageSource(BufferedImage image,
- Hashtable properties) {
+ Hashtable<?, ?> properties) {
this.image = image;
if (properties != null) {
this.properties = properties;
} else {
- this.properties = new Hashtable();
+ this.properties = new Hashtable<String, Object>();
}
width = image.getWidth();
height = image.getHeight();
--- a/jdk/src/share/classes/sun/awt/image/PNGImageDecoder.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/image/PNGImageDecoder.java Fri May 23 23:55:14 2014 +0000
@@ -68,7 +68,7 @@
private int filterMethod;
private int interlaceMethod;
private int gamma = 100000;
- private java.util.Hashtable properties;
+ private java.util.Hashtable<String, Object> properties;
/* this is not needed
ImageConsumer target;
*/
@@ -83,7 +83,7 @@
private void property(String key,Object value) {
if(value==null) return;
- if(properties==null) properties=new java.util.Hashtable();
+ if(properties==null) properties=new java.util.Hashtable<>();
properties.put(key,value);
}
private void property(String key,float value) {
--- a/jdk/src/share/classes/sun/awt/image/ToolkitImage.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/image/ToolkitImage.java Fri May 23 23:55:14 2014 +0000
@@ -79,7 +79,7 @@
private int width = -1;
private int height = -1;
- private Hashtable properties;
+ private Hashtable<?, ?> properties;
private int availinfo;
@@ -254,9 +254,9 @@
addInfo(ImageObserver.WIDTH | ImageObserver.HEIGHT);
}
- void setProperties(Hashtable props) {
+ void setProperties(Hashtable<?, ?> props) {
if (props == null) {
- props = new Hashtable();
+ props = new Hashtable<String, Object>();
}
properties = props;
addInfo(ImageObserver.PROPERTIES);
--- a/jdk/src/share/classes/sun/awt/shell/ShellFolder.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/shell/ShellFolder.java Fri May 23 23:55:14 2014 +0000
@@ -127,14 +127,14 @@
File[] files = super.listFiles();
if (!includeHiddenFiles) {
- Vector v = new Vector();
+ Vector<File> v = new Vector<>();
int nameCount = (files == null) ? 0 : files.length;
for (int i = 0; i < nameCount; i++) {
if (!files[i].isHidden()) {
v.addElement(files[i]);
}
}
- files = (File[])v.toArray(new File[v.size()]);
+ files = v.toArray(new File[v.size()]);
}
return files;
@@ -208,7 +208,7 @@
static {
String managerClassName = (String)Toolkit.getDefaultToolkit().
getDesktopProperty("Shell.shellFolderManager");
- Class managerClass = null;
+ Class<?> managerClass = null;
try {
managerClass = ReflectUtil.forName(managerClassName);
// swallow the exceptions below and use default shell folder
@@ -554,7 +554,7 @@
/**
* Provides a default comparator for the default column set
*/
- private static final Comparator DEFAULT_COMPARATOR = new Comparator() {
+ private static final Comparator<Object> DEFAULT_COMPARATOR = new Comparator<Object>() {
public int compare(Object o1, Object o2) {
int gt;
@@ -565,7 +565,9 @@
} else if (o1 == null && o2 != null) {
gt = -1;
} else if (o1 instanceof Comparable) {
- gt = ((Comparable) o1).compareTo(o2);
+ @SuppressWarnings("unchecked")
+ Comparable<Object> o = (Comparable<Object>) o1;
+ gt = o.compareTo(o2);
} else {
gt = 0;
}
--- a/jdk/src/share/classes/sun/awt/shell/ShellFolderColumnInfo.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/shell/ShellFolderColumnInfo.java Fri May 23 23:55:14 2014 +0000
@@ -38,7 +38,7 @@
*/
private Integer alignment;
private SortOrder sortOrder;
- private Comparator comparator;
+ private Comparator<?> comparator;
/**
* <code>false</code> (default) if the {@link comparator} expects folders as arguments,
* and <code>true</code> if folder's column values. The first option is used default for comparison
@@ -49,7 +49,7 @@
public ShellFolderColumnInfo(String title, Integer width,
Integer alignment, boolean visible,
- SortOrder sortOrder, Comparator comparator,
+ SortOrder sortOrder, Comparator<?> comparator,
boolean compareByColumn) {
this.title = title;
this.width = width;
@@ -62,7 +62,7 @@
public ShellFolderColumnInfo(String title, Integer width,
Integer alignment, boolean visible,
- SortOrder sortOrder, Comparator comparator) {
+ SortOrder sortOrder, Comparator<?> comparator) {
this(title, width, alignment, visible, sortOrder, comparator, false);
}
@@ -115,11 +115,11 @@
this.sortOrder = sortOrder;
}
- public Comparator getComparator() {
+ public Comparator<?> getComparator() {
return comparator;
}
- public void setComparator(Comparator comparator) {
+ public void setComparator(Comparator<?> comparator) {
this.comparator = comparator;
}
--- a/jdk/src/share/classes/sun/awt/util/IdentityArrayList.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/util/IdentityArrayList.java Fri May 23 23:55:14 2014 +0000
@@ -285,6 +285,7 @@
* this list
* @throws NullPointerException if the specified array is null
*/
+ @SuppressWarnings("unchecked")
public <T> T[] toArray(T[] a) {
if (a.length < size)
// Make a new array of a's runtime type, but my contents:
@@ -307,7 +308,9 @@
public E get(int index) {
rangeCheck(index);
- return (E) elementData[index];
+ @SuppressWarnings("unchecked")
+ E rv = (E) elementData[index];
+ return rv;
}
/**
@@ -322,6 +325,7 @@
public E set(int index, E element) {
rangeCheck(index);
+ @SuppressWarnings("unchecked")
E oldValue = (E) elementData[index];
elementData[index] = element;
return oldValue;
@@ -371,6 +375,7 @@
rangeCheck(index);
modCount++;
+ @SuppressWarnings("unchecked")
E oldValue = (E) elementData[index];
int numMoved = size - index - 1;
--- a/jdk/src/share/classes/sun/awt/util/IdentityLinkedList.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/awt/util/IdentityLinkedList.java Fri May 23 23:55:14 2014 +0000
@@ -280,7 +280,9 @@
Entry<E> successor = (index==size ? header : entry(index));
Entry<E> predecessor = successor.previous;
for (int i=0; i<numNew; i++) {
- Entry<E> e = new Entry<E>((E)a[i], successor, predecessor);
+ @SuppressWarnings("unchecked")
+ E tmp = (E) a[i];
+ Entry<E> e = new Entry<E>(tmp, successor, predecessor);
predecessor.next = e;
predecessor = e;
}
@@ -396,7 +398,7 @@
*/
public int indexOf(Object o) {
int index = 0;
- for (Entry e = header.next; e != header; e = e.next) {
+ for (Entry<E> e = header.next; e != header; e = e.next) {
if (o == e.element) {
return index;
}
@@ -418,7 +420,7 @@
*/
public int lastIndexOf(Object o) {
int index = size;
- for (Entry e = header.previous; e != header; e = e.previous) {
+ for (Entry<E> e = header.previous; e != header; e = e.previous) {
index--;
if (o == e.element) {
return index;
@@ -787,7 +789,7 @@
}
/** Adapter to provide descending iterators via ListItr.previous */
- private class DescendingIterator implements Iterator {
+ private class DescendingIterator implements Iterator<E> {
final ListItr itr = new ListItr(size());
public boolean hasNext() {
return itr.hasPrevious();
@@ -860,6 +862,7 @@
* this list
* @throws NullPointerException if the specified array is null
*/
+ @SuppressWarnings("unchecked")
public <T> T[] toArray(T[] a) {
if (a.length < size)
a = (T[])java.lang.reflect.Array.newInstance(
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/awt/util/ThreadGroupUtils.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,55 @@
+/*
+ * 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+
+package sun.awt.util;
+
+/**
+ * A utility class needed to access the root {@code ThreadGroup}
+ *
+ * The class should not depend on any others, because it' called from JNI_OnLoad of the AWT
+ * native library. Triggering class loading could lead to a deadlock.
+ */
+public final class ThreadGroupUtils {
+
+ private ThreadGroupUtils() {
+ // Avoid instantiation
+ }
+
+ /**
+ * Returns a root thread group.
+ * Should be called with {@link sun.security.util.SecurityConstants#MODIFY_THREADGROUP_PERMISSION}
+ *
+ * @return a root {@code ThreadGroup}
+ */
+ public static ThreadGroup getRootThreadGroup() {
+ ThreadGroup currentTG = Thread.currentThread().getThreadGroup();
+ ThreadGroup parentTG = currentTG.getParent();
+ while (parentTG != null) {
+ currentTG = parentTG;
+ parentTG = currentTG.getParent();
+ }
+ return currentTG;
+ }
+}
--- a/jdk/src/share/classes/sun/dc/META-INF/services/sun.java2d.pipe.RenderingEngine Thu May 22 20:24:42 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-# Ductus Rendering Engine module
-sun.dc.DuctusRenderingEngine
--- a/jdk/src/share/classes/sun/font/CreatedFontTracker.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/font/CreatedFontTracker.java Fri May 23 23:55:14 2014 +0000
@@ -35,7 +35,7 @@
import java.util.concurrent.TimeUnit;
import sun.awt.AppContext;
-import sun.misc.ThreadGroupUtils;
+import sun.awt.util.ThreadGroupUtils;
public class CreatedFontTracker {
--- a/jdk/src/share/classes/sun/font/SunFontManager.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/font/SunFontManager.java Fri May 23 23:55:14 2014 +0000
@@ -52,7 +52,7 @@
import sun.awt.AppContext;
import sun.awt.FontConfiguration;
import sun.awt.SunToolkit;
-import sun.misc.ThreadGroupUtils;
+import sun.awt.util.ThreadGroupUtils;
import sun.java2d.FontSupport;
import sun.util.logging.PlatformLogger;
@@ -1161,6 +1161,7 @@
case FONTFORMAT_NATIVE:
NativeFont nf = new NativeFont(fileName, false);
physicalFont = addToFontList(nf, fontRank);
+ break;
default:
}
--- a/jdk/src/share/classes/sun/font/TrueTypeGlyphMapper.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/font/TrueTypeGlyphMapper.java Fri May 23 23:55:14 2014 +0000
@@ -109,6 +109,7 @@
cmap = CMap.theNullCmap;
}
+ @SuppressWarnings("fallthrough")
private final char remapJAChar(char unicode) {
switch (unicode) {
case REVERSE_SOLIDUS:
@@ -123,6 +124,7 @@
default: return unicode;
}
}
+ @SuppressWarnings("fallthrough")
private final int remapJAIntChar(int unicode) {
switch (unicode) {
case REVERSE_SOLIDUS:
--- a/jdk/src/share/classes/sun/java2d/Disposer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/java2d/Disposer.java Fri May 23 23:55:14 2014 +0000
@@ -25,7 +25,7 @@
package sun.java2d;
-import sun.misc.ThreadGroupUtils;
+import sun.awt.util.ThreadGroupUtils;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
--- a/jdk/src/share/classes/sun/java2d/Spans.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/java2d/Spans.java Fri May 23 23:55:14 2014 +0000
@@ -49,7 +49,7 @@
* Holds a list of individual
* Span instances.
*/
- private List mSpans = new Vector(kMaxAddsSinceSort);
+ private List<Span> mSpans = new Vector<>(kMaxAddsSinceSort);
/**
* The number of <code>Span</code>
@@ -144,7 +144,7 @@
Collections.sort(mSpans);
mAddsSinceSort = 0;
- Iterator iter = mSpans.iterator();
+ Iterator<Span> iter = mSpans.iterator();
/* Have 'span' start at the first span in
* the collection. The collection may be empty
@@ -152,7 +152,7 @@
*/
Span span = null;
if (iter.hasNext()) {
- span = (Span) iter.next();
+ span = iter.next();
}
/* Loop over the spans collapsing those that intersect
@@ -160,7 +160,7 @@
*/
while (iter.hasNext()) {
- Span nextSpan = (Span) iter.next();
+ Span nextSpan = iter.next();
/* The spans are in ascending start position
* order and so the next span's starting point
@@ -202,9 +202,9 @@
private void printSpans() {
System.out.println("----------");
if (mSpans != null) {
- Iterator iter = mSpans.iterator();
+ Iterator<Span> iter = mSpans.iterator();
while (iter.hasNext()) {
- Span span = (Span) iter.next();
+ Span span = iter.next();
System.out.println(span);
}
}
@@ -216,7 +216,7 @@
/**
* Holds a single half-open interval.
*/
- static class Span implements Comparable {
+ static class Span implements Comparable<Span> {
/**
* The span includes the starting point.
@@ -315,8 +315,7 @@
* position. The end position is ignored
* in this ranking.
*/
- public int compareTo(Object o) {
- Span otherSpan = (Span) o;
+ public int compareTo(Span otherSpan) {
float otherStart = otherSpan.getStart();
int result;
@@ -345,7 +344,7 @@
* <code>SpanIntersection.instance</code> to
* get the single instance of this class.
*/
- static class SpanIntersection implements Comparator {
+ static class SpanIntersection implements Comparator<Span> {
/**
* This class is a Singleton and the following
@@ -361,10 +360,8 @@
}
- public int compare(Object o1, Object o2) {
+ public int compare(Span span1, Span span2) {
int result;
- Span span1 = (Span) o1;
- Span span2 = (Span) o2;
/* Span 1 is entirely to the left of span2.
* span1: <-----<
--- a/jdk/src/share/classes/sun/java2d/SunGraphics2D.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/java2d/SunGraphics2D.java Fri May 23 23:55:14 2014 +0000
@@ -1430,8 +1430,11 @@
}
}
- RenderingHints makeHints(Map hints) {
- RenderingHints model = new RenderingHints(hints);
+ RenderingHints makeHints(Map<?,?> hints) {
+ RenderingHints model = new RenderingHints(null);
+ if (hints != null) {
+ model.putAll(hints);
+ }
model.put(SunHints.KEY_RENDERING,
SunHints.Value.get(SunHints.INTKEY_RENDERING,
renderHint));
--- a/jdk/src/share/classes/sun/java2d/SunGraphicsEnvironment.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/java2d/SunGraphicsEnvironment.java Fri May 23 23:55:14 2014 +0000
@@ -82,7 +82,7 @@
public SunGraphicsEnvironment() {
java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
+ new java.security.PrivilegedAction<Object>() {
public Object run() {
String version = System.getProperty("os.version", "0.0");
try {
--- a/jdk/src/share/classes/sun/java2d/cmm/CMSManager.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/java2d/cmm/CMSManager.java Fri May 23 23:55:14 2014 +0000
@@ -34,7 +34,6 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
import sun.security.action.GetPropertyAction;
-import java.util.ServiceLoader;
public class CMSManager {
public static ColorSpace GRAYspace; // These two fields allow access
@@ -52,35 +51,28 @@
return cmmImpl;
}
- CMMServiceProvider spi = AccessController.doPrivileged(
- new PrivilegedAction<CMMServiceProvider>() {
- public CMMServiceProvider run() {
- String cmmClass = System.getProperty(
- "sun.java2d.cmm", "sun.java2d.cmm.lcms.LcmsServiceProvider");
-
- ServiceLoader<CMMServiceProvider> cmmLoader
- = ServiceLoader.loadInstalled(CMMServiceProvider.class);
-
- CMMServiceProvider spi = null;
+ GetPropertyAction gpa = new GetPropertyAction("sun.java2d.cmm");
+ String cmmProviderClass = AccessController.doPrivileged(gpa);
+ CMMServiceProvider provider = null;
+ if (cmmProviderClass != null) {
+ try {
+ Class<?> cls = Class.forName(cmmProviderClass);
+ provider = (CMMServiceProvider)cls.newInstance();
+ } catch (ReflectiveOperationException e) {
+ }
+ }
+ if (provider == null) {
+ provider = new sun.java2d.cmm.lcms.LcmsServiceProvider();
+ }
- for (CMMServiceProvider cmm : cmmLoader) {
- spi = cmm;
- if (cmm.getClass().getName().equals(cmmClass)) {
- break;
- }
- }
- return spi;
- }
- });
-
- cmmImpl = spi.getColorManagementModule();
+ cmmImpl = provider.getColorManagementModule();
if (cmmImpl == null) {
throw new CMMException("Cannot initialize Color Management System."+
"No CM module found");
}
- GetPropertyAction gpa = new GetPropertyAction("sun.java2d.cmm.trace");
+ gpa = new GetPropertyAction("sun.java2d.cmm.trace");
String cmmTrace = AccessController.doPrivileged(gpa);
if (cmmTrace != null) {
cmmImpl = new CMMTracer(cmmImpl);
--- a/jdk/src/share/classes/sun/java2d/cmm/lcms/LCMS.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/java2d/cmm/lcms/LCMS.java Fri May 23 23:55:14 2014 +0000
@@ -189,7 +189,7 @@
LCMSImageLayout dest);
public static native void freeTransform(long ID);
- public static native void initLCMS(Class Trans, Class IL, Class Pf);
+ public static native void initLCMS(Class<?> Trans, Class<?> IL, Class<?> Pf);
private LCMS() {};
@@ -201,7 +201,7 @@
}
java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
+ new java.security.PrivilegedAction<Object>() {
public Object run() {
/* We need to load awt here because of usage trace and
* disposer frameworks
--- a/jdk/src/share/classes/sun/java2d/cmm/lcms/META-INF/services/sun.java2d.cmm.CMMServiceProvider Thu May 22 20:24:42 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-# Little CMS color management module
-sun.java2d.cmm.lcms.LcmsServiceProvider
--- a/jdk/src/share/classes/sun/java2d/loops/Blit.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/java2d/loops/Blit.java Fri May 23 23:55:14 2014 +0000
@@ -217,8 +217,8 @@
Blit performop;
Blit convertresult;
- WeakReference srcTmp;
- WeakReference dstTmp;
+ WeakReference<SurfaceData> srcTmp;
+ WeakReference<SurfaceData> dstTmp;
public GeneralXorBlit(SurfaceType srctype,
CompositeType comptype,
@@ -257,14 +257,14 @@
} else {
SurfaceData cachedSrc = null;
if (srcTmp != null) {
- cachedSrc = (SurfaceData) srcTmp.get();
+ cachedSrc = srcTmp.get();
}
src = convertFrom(convertsrc, srcData, srcx, srcy,
width, height, cachedSrc);
sx = 0;
sy = 0;
if (src != cachedSrc) {
- srcTmp = new WeakReference(src);
+ srcTmp = new WeakReference<>(src);
}
}
@@ -277,7 +277,7 @@
// assert: convertresult != null
SurfaceData cachedDst = null;
if (dstTmp != null) {
- cachedDst = (SurfaceData) dstTmp.get();
+ cachedDst = dstTmp.get();
}
dst = convertFrom(convertdst, dstData, dstx, dsty,
width, height, cachedDst);
@@ -285,7 +285,7 @@
dy = 0;
opclip = null;
if (dst != cachedDst) {
- dstTmp = new WeakReference(dst);
+ dstTmp = new WeakReference<>(dst);
}
}
--- a/jdk/src/share/classes/sun/java2d/loops/CustomComponent.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/java2d/loops/CustomComponent.java Fri May 23 23:55:14 2014 +0000
@@ -50,7 +50,7 @@
public static void register() {
// REMIND: This does not work for all destinations yet since
// the screen SurfaceData objects do not implement getRaster
- Class owner = CustomComponent.class;
+ Class<?> owner = CustomComponent.class;
GraphicsPrimitive[] primitives = {
new GraphicsPrimitiveProxy(owner, "OpaqueCopyAnyToArgb",
Blit.methodSignature,
--- a/jdk/src/share/classes/sun/java2d/loops/GeneralRenderer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/java2d/loops/GeneralRenderer.java Fri May 23 23:55:14 2014 +0000
@@ -50,7 +50,7 @@
public final class GeneralRenderer {
public static void register() {
- Class owner = GeneralRenderer.class;
+ Class<?> owner = GeneralRenderer.class;
GraphicsPrimitive[] primitives = {
new GraphicsPrimitiveProxy(owner, "SetFillRectANY",
FillRect.methodSignature,
--- a/jdk/src/share/classes/sun/java2d/loops/GraphicsPrimitive.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/java2d/loops/GraphicsPrimitive.java Fri May 23 23:55:14 2014 +0000
@@ -316,7 +316,7 @@
public abstract GraphicsPrimitive traceWrap();
- static HashMap traceMap;
+ static HashMap<Object, int[]> traceMap;
public static int traceflags;
public static String tracefile;
@@ -427,13 +427,14 @@
public void run() {
PrintStream ps = getTraceOutputFile();
- Iterator iterator = traceMap.entrySet().iterator();
+ Iterator<Map.Entry<Object, int[]>> iterator =
+ traceMap.entrySet().iterator();
long total = 0;
int numprims = 0;
while (iterator.hasNext()) {
- Map.Entry me = (Map.Entry) iterator.next();
+ Map.Entry<Object, int[]> me = iterator.next();
Object prim = me.getKey();
- int[] count = (int[]) me.getValue();
+ int[] count = me.getValue();
if (count[0] == 1) {
ps.print("1 call to ");
} else {
@@ -455,15 +456,15 @@
public synchronized static void tracePrimitive(Object prim) {
if ((traceflags & TRACECOUNTS) != 0) {
if (traceMap == null) {
- traceMap = new HashMap();
+ traceMap = new HashMap<>();
TraceReporter.setShutdownHook();
}
- Object o = traceMap.get(prim);
+ int[] o = traceMap.get(prim);
if (o == null) {
o = new int[1];
traceMap.put(prim, o);
}
- ((int[]) o)[0]++;
+ o[0]++;
}
if ((traceflags & TRACELOG) != 0) {
PrintStream ps = getTraceOutputFile();
--- a/jdk/src/share/classes/sun/java2d/loops/GraphicsPrimitiveMgr.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/java2d/loops/GraphicsPrimitiveMgr.java Fri May 23 23:55:14 2014 +0000
@@ -45,11 +45,11 @@
private static GraphicsPrimitive generalPrimitives[];
private static boolean needssort = true;
- private static native void initIDs(Class GP, Class ST, Class CT,
- Class SG2D, Class Color, Class AT,
- Class XORComp, Class AlphaComp,
- Class Path2D, Class Path2DFloat,
- Class SHints);
+ private static native void initIDs(Class<?> GP, Class<?> ST, Class<?> CT,
+ Class<?> SG2D, Class<?> Color, Class<?> AT,
+ Class<?> XORComp, Class<?> AlphaComp,
+ Class<?> Path2D, Class<?> Path2DFloat,
+ Class<?> SHints);
private static native void registerNativeLoops();
static {
@@ -73,16 +73,17 @@
public int uniqueID;
}
- private static Comparator primSorter = new Comparator() {
- public int compare(Object o1, Object o2) {
- int id1 = ((GraphicsPrimitive) o1).getUniqueID();
- int id2 = ((GraphicsPrimitive) o2).getUniqueID();
+ private static Comparator<GraphicsPrimitive> primSorter =
+ new Comparator<GraphicsPrimitive>() {
+ public int compare(GraphicsPrimitive o1, GraphicsPrimitive o2) {
+ int id1 = o1.getUniqueID();
+ int id2 = o2.getUniqueID();
return (id1 == id2 ? 0 : (id1 < id2 ? -1 : 1));
}
};
- private static Comparator primFinder = new Comparator() {
+ private static Comparator<Object> primFinder = new Comparator<Object>() {
public int compare(Object o1, Object o2) {
int id1 = ((GraphicsPrimitive) o1).getUniqueID();
int id2 = ((PrimitiveSpec) o2).uniqueID;
--- a/jdk/src/share/classes/sun/java2d/loops/GraphicsPrimitiveProxy.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/java2d/loops/GraphicsPrimitiveProxy.java Fri May 23 23:55:14 2014 +0000
@@ -41,7 +41,7 @@
*/
public class GraphicsPrimitiveProxy extends GraphicsPrimitive {
- private Class owner;
+ private Class<?> owner;
private String relativeClassName;
/**
@@ -53,7 +53,7 @@
* @param relativeClassName The name of the class this is a proxy for.
* This should not include the package.
*/
- public GraphicsPrimitiveProxy(Class owner, String relativeClassName,
+ public GraphicsPrimitiveProxy(Class<?> owner, String relativeClassName,
String methodSignature,
int primID,
SurfaceType srctype,
@@ -80,7 +80,7 @@
String name = getPackageName(owner.getName()) + "."
+ relativeClassName;
try {
- Class clazz = Class.forName(name);
+ Class<?> clazz = Class.forName(name);
GraphicsPrimitive p = (GraphicsPrimitive) clazz.newInstance();
if (!satisfiesSameAs(p)) {
throw new RuntimeException("Primitive " + p
--- a/jdk/src/share/classes/sun/java2d/loops/MaskBlit.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/java2d/loops/MaskBlit.java Fri May 23 23:55:14 2014 +0000
@@ -143,8 +143,8 @@
MaskBlit performop;
Blit convertresult;
- WeakReference srcTmp;
- WeakReference dstTmp;
+ WeakReference<SurfaceData> srcTmp;
+ WeakReference<SurfaceData> dstTmp;
public General(SurfaceType srctype,
CompositeType comptype,
@@ -184,14 +184,14 @@
} else {
SurfaceData cachedSrc = null;
if (srcTmp != null) {
- cachedSrc = (SurfaceData) srcTmp.get();
+ cachedSrc = srcTmp.get();
}
src = convertFrom(convertsrc, srcData, srcx, srcy,
width, height, cachedSrc);
sx = 0;
sy = 0;
if (src != cachedSrc) {
- srcTmp = new WeakReference(src);
+ srcTmp = new WeakReference<>(src);
}
}
@@ -204,7 +204,7 @@
// assert: convertresult != null
SurfaceData cachedDst = null;
if (dstTmp != null) {
- cachedDst = (SurfaceData) dstTmp.get();
+ cachedDst = dstTmp.get();
}
dst = convertFrom(convertdst, dstData, dstx, dsty,
width, height, cachedDst);
@@ -212,7 +212,7 @@
dy = 0;
opclip = null;
if (dst != cachedDst) {
- dstTmp = new WeakReference(dst);
+ dstTmp = new WeakReference<>(dst);
}
}
--- a/jdk/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java Fri May 23 23:55:14 2014 +0000
@@ -728,7 +728,7 @@
class OGLGeneralBlit extends Blit {
private Blit performop;
- private WeakReference srcTmp;
+ private WeakReference<SurfaceData> srcTmp;
OGLGeneralBlit(SurfaceType dstType,
CompositeType compType,
@@ -750,7 +750,7 @@
SurfaceData cachedSrc = null;
if (srcTmp != null) {
// use cached intermediate surface, if available
- cachedSrc = (SurfaceData)srcTmp.get();
+ cachedSrc = srcTmp.get();
}
// convert source to IntArgbPre
@@ -763,7 +763,7 @@
if (src != cachedSrc) {
// cache the intermediate surface
- srcTmp = new WeakReference(src);
+ srcTmp = new WeakReference<>(src);
}
}
}
@@ -802,7 +802,7 @@
if (dstBuffer != cachedDst) {
// cache the intermediate surface
- dstTmp = new WeakReference(dstBuffer);
+ dstTmp = new WeakReference<>(dstBuffer);
}
// now blit the buffer back to the destination
--- a/jdk/src/share/classes/sun/java2d/opengl/OGLRenderQueue.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/java2d/opengl/OGLRenderQueue.java Fri May 23 23:55:14 2014 +0000
@@ -25,7 +25,7 @@
package sun.java2d.opengl;
-import sun.misc.ThreadGroupUtils;
+import sun.awt.util.ThreadGroupUtils;
import sun.java2d.pipe.RenderBuffer;
import sun.java2d.pipe.RenderQueue;
import static sun.java2d.pipe.BufferedOpCodes.*;
--- a/jdk/src/share/classes/sun/java2d/pipe/AlphaPaintPipe.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/java2d/pipe/AlphaPaintPipe.java Fri May 23 23:55:14 2014 +0000
@@ -48,16 +48,16 @@
* SunGraphics2D.
*/
public class AlphaPaintPipe implements CompositePipe {
- static WeakReference cachedLastRaster;
- static WeakReference cachedLastColorModel;
- static WeakReference cachedLastData;
+ static WeakReference<Raster> cachedLastRaster;
+ static WeakReference<ColorModel> cachedLastColorModel;
+ static WeakReference<SurfaceData> cachedLastData;
static class TileContext {
SunGraphics2D sunG2D;
PaintContext paintCtxt;
ColorModel paintModel;
- WeakReference lastRaster;
- WeakReference lastData;
+ WeakReference<Raster> lastRaster;
+ WeakReference<SurfaceData> lastData;
MaskBlit lastMask;
Blit lastBlit;
SurfaceData dstData;
@@ -105,8 +105,8 @@
SurfaceData srcData = null;
Raster lastRas = null;
if (context.lastData != null && context.lastRaster != null) {
- srcData = (SurfaceData) context.lastData.get();
- lastRas = (Raster) context.lastRaster.get();
+ srcData = context.lastData.get();
+ lastRas = context.lastRaster.get();
if (srcData == null || lastRas == null) {
srcData = null;
lastRas = null;
@@ -127,7 +127,7 @@
}
if (lastRas != srcRaster) {
lastRas = srcRaster;
- context.lastRaster = new WeakReference(lastRas);
+ context.lastRaster = new WeakReference<>(lastRas);
// REMIND: This will fail for a non-Writable raster!
BufferedImage bImg =
new BufferedImage(paintModel,
@@ -135,7 +135,7 @@
paintModel.isAlphaPremultiplied(),
null);
srcData = BufImgSurfaceData.createData(bImg);
- context.lastData = new WeakReference(srcData);
+ context.lastData = new WeakReference<>(srcData);
context.lastMask = null;
context.lastBlit = null;
}
@@ -197,7 +197,7 @@
{
// Avoid creating new WeakReference if possible
cachedLastColorModel =
- new WeakReference(context.paintModel);
+ new WeakReference<>(context.paintModel);
}
cachedLastData = context.lastData;
}
--- a/jdk/src/share/classes/sun/java2d/pipe/RenderQueue.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/java2d/pipe/RenderQueue.java Fri May 23 23:55:14 2014 +0000
@@ -81,10 +81,10 @@
* A Set containing hard references to Objects that must stay alive until
* the queue has been completely flushed.
*/
- protected Set refSet;
+ protected Set<Object> refSet;
protected RenderQueue() {
- refSet = new HashSet();
+ refSet = new HashSet<>();
buf = RenderBuffer.allocate(BUFFER_SIZE);
}
--- a/jdk/src/share/classes/sun/java2d/pipe/RenderingEngine.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/java2d/pipe/RenderingEngine.java Fri May 23 23:55:14 2014 +0000
@@ -32,7 +32,6 @@
import java.security.PrivilegedAction;
import java.security.AccessController;
-import java.util.ServiceLoader;
import sun.security.action.GetPropertyAction;
import sun.awt.geom.PathConsumer2D;
@@ -97,12 +96,9 @@
* </pre>
*
* If no specific {@code RenderingEngine} is specified on the command
- * or Ductus renderer is specified, it will attempt loading the
- * sun.dc.DuctusRenderingEngine class using Class.forName as a fastpath;
- * if not found, use the ServiceLoader.
- * If no specific {@code RenderingEngine} is specified on the command
- * line then the last one returned by enumerating all subclasses of
- * {@code RenderingEngine} known to the ServiceLoader is used.
+ * or Ductus renderer is specified, it will first attempt loading the
+ * sun.dc.DuctusRenderingEngine class using Class.forName, if that
+ * is not found, then it will look for Pisces.
* <p>
* Runtime tracing of the actions of the {@code RenderingEngine}
* can be enabled by specifying the runtime flag:
@@ -117,42 +113,30 @@
return reImpl;
}
- reImpl =
- AccessController.doPrivileged(new PrivilegedAction<RenderingEngine>() {
- public RenderingEngine run() {
- final String ductusREClass = "sun.dc.DuctusRenderingEngine";
- String reClass =
- System.getProperty("sun.java2d.renderer", ductusREClass);
- if (reClass.equals(ductusREClass)) {
- try {
- Class<?> cls = Class.forName(ductusREClass);
- return (RenderingEngine) cls.newInstance();
- } catch (ReflectiveOperationException ignored) {
- // not found
- }
- }
-
- ServiceLoader<RenderingEngine> reLoader =
- ServiceLoader.loadInstalled(RenderingEngine.class);
-
- RenderingEngine service = null;
-
- for (RenderingEngine re : reLoader) {
- service = re;
- if (re.getClass().getName().equals(reClass)) {
- break;
- }
- }
- return service;
- }
- });
+ /* Look first for ductus or an app-override renderer,
+ * if not specified or present, then look for pisces.
+ */
+ final String ductusREClass = "sun.dc.DuctusRenderingEngine";
+ final String piscesREClass = "sun.java2d.pisces.PiscesRenderingEngine";
+ GetPropertyAction gpa =
+ new GetPropertyAction("sun.java2d.renderer", ductusREClass);
+ String reClass = AccessController.doPrivileged(gpa);
+ try {
+ Class<?> cls = Class.forName(reClass);
+ reImpl = (RenderingEngine) cls.newInstance();
+ } catch (ReflectiveOperationException ignored0) {
+ try {
+ Class<?> cls = Class.forName(piscesREClass);
+ reImpl = (RenderingEngine) cls.newInstance();
+ } catch (ReflectiveOperationException ignored1) {
+ }
+ }
if (reImpl == null) {
throw new InternalError("No RenderingEngine module found");
}
- GetPropertyAction gpa =
- new GetPropertyAction("sun.java2d.renderer.trace");
+ gpa = new GetPropertyAction("sun.java2d.renderer.trace");
String reTrace = AccessController.doPrivileged(gpa);
if (reTrace != null) {
reImpl = new Tracer(reImpl);
--- a/jdk/src/share/classes/sun/java2d/pipe/SpanClipRenderer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/classes/sun/java2d/pipe/SpanClipRenderer.java Fri May 23 23:55:14 2014 +0000
@@ -39,14 +39,14 @@
{
CompositePipe outpipe;
- static Class RegionClass = Region.class;
- static Class RegionIteratorClass = RegionIterator.class;
+ static Class<?> RegionClass = Region.class;
+ static Class<?> RegionIteratorClass = RegionIterator.class;
static {
initIDs(RegionClass, RegionIteratorClass);
}
- static native void initIDs(Class rc, Class ric);
+ static native void initIDs(Class<?> rc, Class<?> ric);
public SpanClipRenderer(CompositePipe pipe) {
outpipe = pipe;
--- a/jdk/src/share/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine Thu May 22 20:24:42 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-# Pisces Rendering Engine module
-sun.java2d.pisces.PiscesRenderingEngine
--- a/jdk/src/share/classes/sun/misc/ThreadGroupUtils.java Thu May 22 20:24:42 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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.
- */
-
-package sun.misc;
-
-/**
- * A utility class needed to access the root {@code ThreadGroup}
- *
- * The class should not depend on any others, because it' called from JNI_OnLoad of the AWT
- * native library. Triggering class loading could could lead to a deadlock.
- */
-public final class ThreadGroupUtils {
-
- private ThreadGroupUtils() {
- // Avoid instantiation
- }
-
- /**
- * Returns a root thread group.
- * Should be called with {@link sun.security.util.SecurityConstants#MODIFY_THREADGROUP_PERMISSION}
- *
- * @return a root {@code ThreadGroup}
- */
- public static ThreadGroup getRootThreadGroup() {
- ThreadGroup currentTG = Thread.currentThread().getThreadGroup();
- ThreadGroup parentTG = currentTG.getParent();
- while (parentTG != null) {
- currentTG = parentTG;
- parentTG = currentTG.getParent();
- }
- return currentTG;
- }
-}
--- a/jdk/src/share/native/sun/awt/splashscreen/splashscreen_jpeg.c Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/native/sun/awt/splashscreen/splashscreen_jpeg.c Fri May 23 23:55:14 2014 +0000
@@ -25,7 +25,6 @@
#include "splashscreen_impl.h"
-#include "jinclude.h"
#include "jpeglib.h"
#include "jerror.h"
@@ -107,11 +106,11 @@
if (cinfo->src == NULL) { /* first time for this JPEG object? */
cinfo->src = (struct jpeg_source_mgr *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo,
- JPOOL_PERMANENT, SIZEOF(stream_source_mgr));
+ JPOOL_PERMANENT, sizeof(stream_source_mgr));
src = (stream_src_ptr) cinfo->src;
src->buffer = (JOCTET *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo,
- JPOOL_PERMANENT, INPUT_BUF_SIZE * SIZEOF(JOCTET));
+ JPOOL_PERMANENT, INPUT_BUF_SIZE * sizeof(JOCTET));
}
src = (stream_src_ptr) cinfo->src;
--- a/jdk/src/share/native/sun/java2d/cmm/lcms/LCMS.c Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/native/sun/java2d/cmm/lcms/LCMS.c Fri May 23 23:55:14 2014 +0000
@@ -30,7 +30,7 @@
#include "jni_util.h"
#include "Trace.h"
#include "Disposer.h"
-#include "lcms2.h"
+#include <lcms2.h>
#include "jlong.h"
--- a/jdk/src/share/native/sun/java2d/loops/ProcessPath.c Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/native/sun/java2d/loops/ProcessPath.c Fri May 23 23:55:14 2014 +0000
@@ -189,34 +189,34 @@
#define PROCESS_POINT(hnd, fX, fY, checkBounds, pixelInfo) \
do { \
- jint _X = (fX)>> MDP_PREC; \
- jint _Y = (fY)>> MDP_PREC; \
+ jint X_ = (fX)>> MDP_PREC; \
+ jint Y_ = (fY)>> MDP_PREC; \
if (checkBounds && \
- (hnd->dhnd->yMin > _Y || \
- hnd->dhnd->yMax <= _Y || \
- hnd->dhnd->xMin > _X || \
- hnd->dhnd->xMax <= _X)) break; \
+ (hnd->dhnd->yMin > Y_ || \
+ hnd->dhnd->yMax <= Y_ || \
+ hnd->dhnd->xMin > X_ || \
+ hnd->dhnd->xMax <= X_)) break; \
/* \
- * (_X,_Y) should be inside boundaries \
+ * (X_,Y_) should be inside boundaries \
* \
- * assert(hnd->dhnd->yMin <= _Y && \
- * hnd->dhnd->yMax > _Y && \
- * hnd->dhnd->xMin <= _X && \
- * hnd->dhnd->xMax > _X); \
+ * assert(hnd->dhnd->yMin <= Y_ && \
+ * hnd->dhnd->yMax > Y_ && \
+ * hnd->dhnd->xMin <= X_ && \
+ * hnd->dhnd->xMax > X_); \
* \
*/ \
if (pixelInfo[0] == 0) { \
pixelInfo[0] = 1; \
- pixelInfo[1] = _X; \
- pixelInfo[2] = _Y; \
- pixelInfo[3] = _X; \
- pixelInfo[4] = _Y; \
- hnd->dhnd->pDrawPixel(hnd->dhnd, _X, _Y); \
- } else if ((_X != pixelInfo[3] || _Y != pixelInfo[4]) && \
- (_X != pixelInfo[1] || _Y != pixelInfo[2])) { \
- hnd->dhnd->pDrawPixel(hnd->dhnd, _X, _Y); \
- pixelInfo[3] = _X; \
- pixelInfo[4] = _Y; \
+ pixelInfo[1] = X_; \
+ pixelInfo[2] = Y_; \
+ pixelInfo[3] = X_; \
+ pixelInfo[4] = Y_; \
+ hnd->dhnd->pDrawPixel(hnd->dhnd, X_, Y_); \
+ } else if ((X_ != pixelInfo[3] || Y_ != pixelInfo[4]) && \
+ (X_ != pixelInfo[1] || Y_ != pixelInfo[2])) { \
+ hnd->dhnd->pDrawPixel(hnd->dhnd, X_, Y_); \
+ pixelInfo[3] = X_; \
+ pixelInfo[4] = Y_; \
} \
} while(0)
--- a/jdk/src/share/native/sun/security/smartcardio/pcsc.c Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/share/native/sun/security/smartcardio/pcsc.c Fri May 23 23:55:14 2014 +0000
@@ -108,7 +108,7 @@
JNIEXPORT jlong JNICALL Java_sun_security_smartcardio_PCSC_SCardEstablishContext
(JNIEnv *env, jclass thisClass, jint dwScope)
{
- SCARDCONTEXT context;
+ SCARDCONTEXT context = 0;
LONG rv;
dprintf("-establishContext\n");
rv = CALL_SCardEstablishContext(dwScope, NULL, NULL, &context);
@@ -180,7 +180,7 @@
SCARDCONTEXT context = (SCARDCONTEXT)jContext;
LONG rv;
LPTSTR mszReaders;
- DWORD size;
+ DWORD size = 0;
jobjectArray result;
dprintf1("-context: %x\n", context);
@@ -215,8 +215,8 @@
SCARDCONTEXT context = (SCARDCONTEXT)jContext;
LONG rv;
LPCTSTR readerName;
- SCARDHANDLE card;
- DWORD proto;
+ SCARDHANDLE card = 0;
+ DWORD proto = 0;
readerName = (*env)->GetStringUTFChars(env, jReaderName, NULL);
if (readerName == NULL) {
@@ -280,8 +280,8 @@
DWORD readerLen = READERNAME_BUFFER_SIZE;
unsigned char atr[ATR_BUFFER_SIZE];
DWORD atrLen = ATR_BUFFER_SIZE;
- DWORD state;
- DWORD protocol;
+ DWORD state = 0;
+ DWORD protocol = 0;
jbyteArray jArray;
jbyte status[2];
--- a/jdk/src/solaris/classes/sun/awt/X11/InfoWindow.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/InfoWindow.java Fri May 23 23:55:14 2014 +0000
@@ -207,8 +207,9 @@
textLabel.setText(tooltipString);
}
- Point pointer = (Point)AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ Point pointer = AccessController.doPrivileged(
+ new PrivilegedAction<Point>() {
+ public Point run() {
if (!isPointerOverTrayIcon(liveArguments.getBounds())) {
return null;
}
--- a/jdk/src/solaris/classes/sun/awt/X11/ListHelper.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/ListHelper.java Fri May 23 23:55:14 2014 +0000
@@ -55,10 +55,10 @@
private final int SCROLLBAR_WIDTH; // Width of a scrollbar
- private java.util.List items; // List of items
+ private java.util.List<String> items; // List of items
// TODO: maybe this would be better as a simple int[]
- private java.util.List selected; // List of selected items
+ private java.util.List<Integer> selected; // List of selected items
private boolean multiSelect; // Can multiple items be selected
// at once?
private int focusedIndex;
@@ -100,8 +100,8 @@
this.peer = peer;
this.colors = colors;
this.multiSelect = multiSelect;
- items = new ArrayList(initialSize);
- selected = new ArrayList(1);
+ items = new ArrayList<>(initialSize);
+ selected = new ArrayList<>(1);
selected.add(Integer.valueOf(-1));
this.maxVisItems = maxVisItems;
@@ -190,7 +190,7 @@
/* if called for multiselect, return -1 */
public int getSelectedIndex() {
if (!multiSelect) {
- Integer val = (Integer)selected.get(0);
+ Integer val = selected.get(0);
return val.intValue();
}
return -1;
@@ -217,7 +217,7 @@
}
public String getItem(int index) {
- return (String) items.get(index);
+ return items.get(index);
}
/**********************************************************************/
@@ -576,9 +576,9 @@
}
boolean isItemSelected(int index) {
- Iterator itr = selected.iterator();
+ Iterator<Integer> itr = selected.iterator();
while (itr.hasNext()) {
- Integer val = (Integer)itr.next();
+ Integer val = itr.next();
if (val.intValue() == index) {
return true;
}
--- a/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java Fri May 23 23:55:14 2014 +0000
@@ -26,6 +26,7 @@
package sun.awt.X11;
import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.DataFlavor;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.InvalidDnDOperationException;
@@ -65,7 +66,7 @@
}
protected void initializeDragImpl(int actions, Transferable contents,
- Map formatMap, long[] formats)
+ Map<Long, DataFlavor> formatMap, long[] formats)
throws InvalidDnDOperationException,
IllegalArgumentException, XException {
--- a/jdk/src/solaris/classes/sun/awt/X11/Native.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/Native.java Fri May 23 23:55:14 2014 +0000
@@ -43,13 +43,12 @@
static int dataModel;
static {
- String dataModelProp = (String)AccessController.
- doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- return System.getProperty("sun.arch.data.model");
- }
- });
+ String dataModelProp = AccessController.doPrivileged(
+ new PrivilegedAction<String>() {
+ public String run() {
+ return System.getProperty("sun.arch.data.model");
+ }
+ });
try {
dataModel = Integer.parseInt(dataModelProp);
} catch (Exception e) {
@@ -333,9 +332,9 @@
* Stores Java Vector of Longs into memory. Memory location is treated as array
* of native <code>long</code>s
*/
- static void putLong(long ptr, Vector arr) {
+ static void putLong(long ptr, Vector<Long> arr) {
for (int i = 0; i < arr.size(); i ++, ptr += getLongSize()) {
- putLong(ptr, ((Long)arr.elementAt(i)).longValue());
+ putLong(ptr, arr.elementAt(i).longValue());
}
}
@@ -343,9 +342,9 @@
* Stores Java Vector of Longs into memory. Memory location is treated as array
* of native <code>long</code>s. Array is stored in reverse order
*/
- static void putLongReverse(long ptr, Vector arr) {
+ static void putLongReverse(long ptr, Vector<Long> arr) {
for (int i = arr.size()-1; i >= 0; i--, ptr += getLongSize()) {
- putLong(ptr, ((Long)arr.elementAt(i)).longValue());
+ putLong(ptr, arr.elementAt(i).longValue());
}
}
/**
--- a/jdk/src/solaris/classes/sun/awt/X11/XAWTXSettings.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XAWTXSettings.java Fri May 23 23:55:14 2014 +0000
@@ -98,7 +98,7 @@
* should be "good enough" for most cases.
*/
- Map updatedSettings = null;
+ Map<String, Object> updatedSettings = null;
XToolkit.awtLock();
try {
long display = XToolkit.getDisplay();
@@ -112,7 +112,7 @@
}
private void updateXSettings(int screen, long owner) {
- final Map updatedSettings = getUpdatedSettings(owner);
+ final Map<String, Object> updatedSettings = getUpdatedSettings(owner);
// this method is called under awt lock and usually on toolkit thread
// but parseXSettings() causes public code execution, so we need to transfer
// this to EDT
@@ -123,7 +123,7 @@
});
}
- private Map getUpdatedSettings(final long owner) {
+ private Map<String, Object> getUpdatedSettings(final long owner) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
log.fine("owner =" + owner);
}
@@ -131,7 +131,7 @@
return null;
}
- Map settings = null;
+ Map<String, Object> settings = null;
try {
WindowPropertyGetter getter =
new WindowPropertyGetter(owner, xSettingsPropertyAtom, 0, MAX_LENGTH,
--- a/jdk/src/solaris/classes/sun/awt/X11/XAtomList.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XAtomList.java Fri May 23 23:55:14 2014 +0000
@@ -157,7 +157,7 @@
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append("[");
- Iterator iter = atoms.iterator();
+ Iterator<XAtom> iter = atoms.iterator();
while (iter.hasNext()) {
buf.append(iter.next().toString());
if (iter.hasNext()) {
--- a/jdk/src/solaris/classes/sun/awt/X11/XAwtState.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XAwtState.java Fri May 23 23:55:14 2014 +0000
@@ -40,7 +40,7 @@
* The mouse is over this component.
* If the component is not disabled, it received MOUSE_ENTERED but no MOUSE_EXITED.
*/
- private static WeakReference componentMouseEnteredRef = null;
+ private static WeakReference<Component> componentMouseEnteredRef = null;
static void setComponentMouseEntered(Component component) {
XToolkit.awtLock();
@@ -50,7 +50,7 @@
return;
}
if (component != getComponentMouseEntered()) {
- componentMouseEnteredRef = new WeakReference(component);
+ componentMouseEnteredRef = new WeakReference<>(component);
}
} finally {
XToolkit.awtUnlock();
@@ -63,7 +63,7 @@
if (componentMouseEnteredRef == null) {
return null;
}
- return (Component)componentMouseEnteredRef.get();
+ return componentMouseEnteredRef.get();
} finally {
XToolkit.awtUnlock();
}
@@ -83,7 +83,7 @@
return inManualGrab;
}
- private static WeakReference grabWindowRef = null;
+ private static WeakReference<XBaseWindow> grabWindowRef = null;
/**
* The X Active Grab overrides any other active grab by the same
@@ -112,7 +112,7 @@
return;
}
if (grabWindow != getGrabWindow()) {
- grabWindowRef = new WeakReference(grabWindow);
+ grabWindowRef = new WeakReference<>(grabWindow);
}
} finally {
XToolkit.awtUnlock();
@@ -125,7 +125,7 @@
if (grabWindowRef == null) {
return null;
}
- XBaseWindow xbw = (XBaseWindow)grabWindowRef.get();
+ XBaseWindow xbw = grabWindowRef.get();
if( xbw != null && xbw.isDisposed() ) {
xbw = null;
grabWindowRef = null;
--- a/jdk/src/solaris/classes/sun/awt/X11/XBaseMenuWindow.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XBaseMenuWindow.java Fri May 23 23:55:14 2014 +0000
@@ -231,7 +231,7 @@
*/
void instantPreInit(XCreateWindowParams params) {
super.instantPreInit(params);
- items = new ArrayList();
+ items = new ArrayList<>();
}
/************************************************
@@ -367,10 +367,10 @@
* Clears items vector and loads specified vector
* @param items vector to be loaded
*/
- public void reloadItems(Vector items) {
+ public void reloadItems(Vector<? extends MenuItem> items) {
synchronized(getMenuTreeLock()) {
this.items.clear();
- MenuItem[] itemArray = (MenuItem[])items.toArray(new MenuItem[] {});
+ MenuItem[] itemArray = items.toArray(new MenuItem[] {});
int itemCnt = itemArray.length;
for(int i = 0; i < itemCnt; i++) {
addItem(itemArray[i]);
--- a/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java Fri May 23 23:55:14 2014 +0000
@@ -236,8 +236,8 @@
return false;
}
- private static Class seClass;
- private static Constructor seCtor;
+ private static Class<?> seClass;
+ private static Constructor<?> seCtor;
final static AWTEvent wrapInSequenced(AWTEvent event) {
try {
@@ -246,9 +246,11 @@
}
if (seCtor == null) {
- seCtor = (Constructor) AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws Exception {
- Constructor ctor = seClass.getConstructor(new Class[] { AWTEvent.class });
+ seCtor = AccessController.doPrivileged(new
+ PrivilegedExceptionAction<Constructor<?>>() {
+ public Constructor<?> run() throws Exception {
+ Constructor<?> ctor = seClass.getConstructor(
+ new Class<?>[] { AWTEvent.class });
ctor.setAccessible(true);
return ctor;
}
@@ -1322,7 +1324,7 @@
}
}
- private void addTree(Collection order, Set set, Container cont) {
+ private void addTree(Collection<Long> order, Set<Long> set, Container cont) {
for (int i = 0; i < cont.getComponentCount(); i++) {
Component comp = cont.getComponent(i);
ComponentPeer peer = comp.getPeer();
--- a/jdk/src/solaris/classes/sun/awt/X11/XCreateWindowParams.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XCreateWindowParams.java Fri May 23 23:55:14 2014 +0000
@@ -30,7 +30,7 @@
import java.util.Map;
@SuppressWarnings("serial") // JDK-implementation class
-public class XCreateWindowParams extends HashMap {
+public class XCreateWindowParams extends HashMap<Object, Object> {
public XCreateWindowParams() {
}
public XCreateWindowParams(Object[] map) {
@@ -82,9 +82,9 @@
}
public String toString() {
StringBuffer buf = new StringBuffer();
- Iterator eIter = entrySet().iterator();
+ Iterator<Map.Entry<Object, Object>> eIter = entrySet().iterator();
while (eIter.hasNext()) {
- Map.Entry entry = (Map.Entry)eIter.next();
+ Map.Entry<Object, Object> entry = eIter.next();
buf.append(entry.getKey() + ": " + entry.getValue() + "\n");
}
return buf.toString();
--- a/jdk/src/solaris/classes/sun/awt/X11/XDataTransferer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDataTransferer.java Fri May 23 23:55:14 2014 +0000
@@ -45,9 +45,11 @@
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.List;
import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
import javax.imageio.ImageTypeSpecifier;
import javax.imageio.ImageWriter;
import javax.imageio.spi.ImageWriterSpi;
@@ -258,28 +260,9 @@
Transferable localeTransferable)
throws IOException {
- String charset = null;
- if (localeTransferable != null &&
- isLocaleDependentTextFormat(format) &&
- localeTransferable.isDataFlavorSupported(javaTextEncodingFlavor)) {
- try {
- charset = new String(
- (byte[])localeTransferable.getTransferData(javaTextEncodingFlavor),
- "UTF-8"
- );
- } catch (UnsupportedFlavorException cannotHappen) {
- }
- } else {
- charset = getCharsetForTextFormat(format);
- }
- if (charset == null) {
- // Only happens when we have a custom text type.
- charset = getDefaultTextCharset();
- }
-
- BufferedReader reader = null;
- try {
- reader = new BufferedReader(new InputStreamReader(stream, charset));
+ String charset = getBestCharsetForTextFormat(format, localeTransferable);
+ try (InputStreamReader isr = new InputStreamReader(stream, charset);
+ BufferedReader reader = new BufferedReader(isr)) {
String line;
ArrayList<URI> uriList = new ArrayList<>();
URI uri;
@@ -292,9 +275,6 @@
uriList.add(uri);
}
return uriList.toArray(new URI[uriList.size()]);
- } finally {
- if (reader != null)
- reader.close();
}
}
@@ -330,8 +310,8 @@
* type can be translated by the Data Transfer subsystem.
*/
@Override
- public List<DataFlavor> getPlatformMappingsForNative(String nat) {
- List<DataFlavor> flavors = new ArrayList<>();
+ public LinkedHashSet<DataFlavor> getPlatformMappingsForNative(String nat) {
+ LinkedHashSet<DataFlavor> flavors = new LinkedHashSet<>();
if (nat == null) {
return flavors;
@@ -354,7 +334,7 @@
// flavors to enable dynamic text native-to-flavor mapping generation.
// See SystemFlavorMap.getFlavorsForNative() for details.
if ("image".equals(primaryType)) {
- Iterator readers = ImageIO.getImageReadersByMIMEType(baseType);
+ Iterator<ImageReader> readers = ImageIO.getImageReadersByMIMEType(baseType);
if (readers.hasNext()) {
flavors.add(DataFlavor.imageFlavor);
}
@@ -392,8 +372,8 @@
* Transfer subsystem.
*/
@Override
- public List<String> getPlatformMappingsForFlavor(DataFlavor df) {
- List<String> natives = new ArrayList<>(1);
+ public LinkedHashSet<String> getPlatformMappingsForFlavor(DataFlavor df) {
+ LinkedHashSet<String> natives = new LinkedHashSet<>(1);
if (df == null) {
return natives;
--- a/jdk/src/solaris/classes/sun/awt/X11/XDnDDragSourceProtocol.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDnDDragSourceProtocol.java Fri May 23 23:55:14 2014 +0000
@@ -26,6 +26,7 @@
package sun.awt.X11;
import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.DataFlavor;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.InvalidDnDOperationException;
@@ -70,7 +71,7 @@
* @returns true if the initialized successfully.
*/
protected void initializeDragImpl(int actions, Transferable contents,
- Map formatMap, long[] formats)
+ Map<Long, DataFlavor> formatMap, long[] formats)
throws InvalidDnDOperationException,
IllegalArgumentException, XException {
assert XToolkit.isAWTLockHeldByCurrentThread();
--- a/jdk/src/solaris/classes/sun/awt/X11/XDragAndDropProtocols.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDragAndDropProtocols.java Fri May 23 23:55:14 2014 +0000
@@ -36,8 +36,8 @@
* @since 1.5
*/
final class XDragAndDropProtocols {
- private final static List dragProtocols;
- private final static List dropProtocols;
+ private final static List<XDragSourceProtocol> dragProtocols;
+ private final static List<XDropTargetProtocol> dropProtocols;
public static final String XDnD = "XDnD";
public static final String MotifDnD = "MotifDnD";
@@ -50,7 +50,7 @@
XDropTargetProtocolListener dropTargetProtocolListener =
XDropTargetContextPeer.getXDropTargetProtocolListener();
- List tDragSourceProtocols = new ArrayList();
+ List<XDragSourceProtocol> tDragSourceProtocols = new ArrayList<>();
XDragSourceProtocol xdndDragSourceProtocol =
XDnDDragSourceProtocol.createInstance(dragSourceProtocolListener);
tDragSourceProtocols.add(xdndDragSourceProtocol);
@@ -58,7 +58,7 @@
MotifDnDDragSourceProtocol.createInstance(dragSourceProtocolListener);
tDragSourceProtocols.add(motifdndDragSourceProtocol);
- List tDropTargetProtocols = new ArrayList();
+ List<XDropTargetProtocol> tDropTargetProtocols = new ArrayList<>();
XDropTargetProtocol xdndDropTargetProtocol =
XDnDDropTargetProtocol.createInstance(dropTargetProtocolListener);
tDropTargetProtocols.add(xdndDropTargetProtocol);
@@ -70,11 +70,11 @@
dropProtocols = Collections.unmodifiableList(tDropTargetProtocols);
}
- static Iterator getDragSourceProtocols() {
+ static Iterator<XDragSourceProtocol> getDragSourceProtocols() {
return dragProtocols.iterator();
}
- static Iterator getDropTargetProtocols() {
+ static Iterator<XDropTargetProtocol> getDropTargetProtocols() {
return dropProtocols.iterator();
}
@@ -88,10 +88,10 @@
return null;
}
- Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols();
+ Iterator<XDragSourceProtocol> dragProtocols =
+ XDragAndDropProtocols.getDragSourceProtocols();
while (dragProtocols.hasNext()) {
- XDragSourceProtocol dragProtocol =
- (XDragSourceProtocol)dragProtocols.next();
+ XDragSourceProtocol dragProtocol = dragProtocols.next();
if (dragProtocol.getProtocolName().equals(name)) {
return dragProtocol;
}
@@ -110,10 +110,10 @@
return null;
}
- Iterator dropProtocols = XDragAndDropProtocols.getDropTargetProtocols();
+ Iterator<XDropTargetProtocol> dropProtocols =
+ XDragAndDropProtocols.getDropTargetProtocols();
while (dropProtocols.hasNext()) {
- XDropTargetProtocol dropProtocol =
- (XDropTargetProtocol)dropProtocols.next();
+ XDropTargetProtocol dropProtocol = dropProtocols.next();
if (dropProtocol.getProtocolName().equals(name)) {
return dropProtocol;
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XDragSourceContextPeer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDragSourceContextPeer.java Fri May 23 23:55:14 2014 +0000
@@ -29,6 +29,7 @@
import java.awt.Cursor;
import java.awt.Window;
+import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants;
@@ -110,7 +111,7 @@
}
protected void startDrag(Transferable transferable,
- long[] formats, Map formatMap) {
+ long[] formats, Map<Long, DataFlavor> formatMap) {
Component component = getTrigger().getComponent();
Component c = null;
XWindowPeer wpeer = null;
@@ -161,9 +162,10 @@
int dropActions = getDragSourceContext().getSourceActions();
- Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols();
+ Iterator<XDragSourceProtocol> dragProtocols =
+ XDragAndDropProtocols.getDragSourceProtocols();
while (dragProtocols.hasNext()) {
- XDragSourceProtocol dragProtocol = (XDragSourceProtocol)dragProtocols.next();
+ XDragSourceProtocol dragProtocol = dragProtocols.next();
try {
dragProtocol.initializeDrag(dropActions, transferable,
formatMap, formats);
@@ -313,9 +315,10 @@
dragDropFinished(false, DnDConstants.ACTION_NONE, xRoot, yRoot);
}
- Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols();
+ Iterator<XDragSourceProtocol> dragProtocols =
+ XDragAndDropProtocols.getDragSourceProtocols();
while (dragProtocols.hasNext()) {
- XDragSourceProtocol dragProtocol = (XDragSourceProtocol)dragProtocols.next();
+ XDragSourceProtocol dragProtocol = dragProtocols.next();
try {
dragProtocol.cleanup();
} catch (XException xe) {
@@ -418,9 +421,10 @@
}
if (clientWindow != 0) {
- Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols();
+ Iterator<XDragSourceProtocol> dragProtocols =
+ XDragAndDropProtocols.getDragSourceProtocols();
while (dragProtocols.hasNext()) {
- XDragSourceProtocol dragProtocol = (XDragSourceProtocol)dragProtocols.next();
+ XDragSourceProtocol dragProtocol = dragProtocols.next();
if (dragProtocol.attachTargetWindow(clientWindow, time)) {
protocol = dragProtocol;
break;
@@ -550,10 +554,10 @@
XClientMessageEvent xclient = ev.get_xclient();
- Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols();
+ Iterator<XDragSourceProtocol> dragProtocols =
+ XDragAndDropProtocols.getDragSourceProtocols();
while (dragProtocols.hasNext()) {
- XDragSourceProtocol dragProtocol =
- (XDragSourceProtocol)dragProtocols.next();
+ XDragSourceProtocol dragProtocol = dragProtocols.next();
if (dragProtocol.processProxyModeEvent(xclient,
getProxyModeSourceWindow())) {
return true;
--- a/jdk/src/solaris/classes/sun/awt/X11/XDragSourceProtocol.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDragSourceProtocol.java Fri May 23 23:55:14 2014 +0000
@@ -26,6 +26,7 @@
package sun.awt.X11;
import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.DataFlavor;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.InvalidDnDOperationException;
@@ -84,7 +85,7 @@
* @throws XException if some X call failed.
*/
public final void initializeDrag(int actions, Transferable contents,
- Map formatMap, long[] formats)
+ Map<Long, DataFlavor> formatMap, long[] formats)
throws InvalidDnDOperationException,
IllegalArgumentException, XException {
XToolkit.awtLock();
@@ -110,7 +111,8 @@
/* The caller must hold AWT_LOCK. */
protected abstract void initializeDragImpl(int actions,
Transferable contents,
- Map formatMap, long[] formats)
+ Map<Long, DataFlavor> formatMap,
+ long[] formats)
throws InvalidDnDOperationException, IllegalArgumentException, XException;
/**
--- a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetContextPeer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetContextPeer.java Fri May 23 23:55:14 2014 +0000
@@ -89,12 +89,12 @@
/* If the event was not consumed, send a response to the source. */
try {
if (ctxt != 0 && !e.isConsumed()) {
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
while (dropTargetProtocols.hasNext()) {
XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ dropTargetProtocols.next();
if (dropTargetProtocol.sendResponse(ctxt, e.getID(),
returnValue)) {
break;
@@ -116,12 +116,12 @@
if (ctxt != 0) {
try {
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
while (dropTargetProtocols.hasNext()) {
XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ dropTargetProtocols.next();
if (dropTargetProtocol.sendDropDone(ctxt, success,
dropAction)) {
break;
@@ -140,12 +140,12 @@
long ctxt = getNativeDragContext();
if (ctxt != 0) {
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
while (dropTargetProtocols.hasNext()) {
XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ dropTargetProtocols.next();
// getData throws IAE if ctxt is not for this protocol.
try {
return dropTargetProtocol.getData(ctxt, format);
@@ -221,12 +221,11 @@
public void forwardEventToEmbedded(long embedded, long ctxt,
int eventID) {
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
while (dropTargetProtocols.hasNext()) {
- XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ XDropTargetProtocol dropTargetProtocol = dropTargetProtocols.next();
if (dropTargetProtocol.forwardEventToEmbedded(embedded, ctxt,
eventID)) {
break;
--- a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetEventProcessor.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetEventProcessor.java Fri May 23 23:55:14 2014 +0000
@@ -79,12 +79,11 @@
}
if (protocol == null) {
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
while (dropTargetProtocols.hasNext()) {
- XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ XDropTargetProtocol dropTargetProtocol = dropTargetProtocols.next();
// Don't try to process it again with the current protocol.
if (dropTargetProtocol == curProtocol) {
continue;
--- a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetProtocol.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetProtocol.java Fri May 23 23:55:14 2014 +0000
@@ -295,7 +295,8 @@
}
/* Access to HashMap is synchronized on this XDropTargetProtocol instance. */
- private final HashMap embedderRegistry = new HashMap();
+ private final HashMap<Long, EmbedderRegistryEntry> embedderRegistry =
+ new HashMap<>();
protected final void putEmbedderRegistryEntry(long embedder,
boolean overriden,
@@ -310,8 +311,7 @@
protected final EmbedderRegistryEntry getEmbedderRegistryEntry(long embedder) {
synchronized (this) {
- return
- (EmbedderRegistryEntry)embedderRegistry.get(Long.valueOf(embedder));
+ return embedderRegistry.get(Long.valueOf(embedder));
}
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java Fri May 23 23:55:14 2014 +0000
@@ -141,10 +141,10 @@
}
public long[] getSites() {
long[] ret = new long[sites.size()];
- Iterator iter = sites.iterator();
+ Iterator<Long> iter = sites.iterator();
int index = 0;
while (iter.hasNext()) {
- Long l = (Long)iter.next();
+ Long l = iter.next();
ret[index++] = l.longValue();
}
return ret;
@@ -199,14 +199,13 @@
private EmbeddedDropSiteEntry registerEmbedderDropSite(long embedder) {
assert XToolkit.isAWTLockHeldByCurrentThread();
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
// The list of protocols supported by the embedder.
- List<XDropTargetProtocol> embedderProtocols = new ArrayList();
+ List<XDropTargetProtocol> embedderProtocols = new ArrayList<>();
while (dropTargetProtocols.hasNext()) {
- XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ XDropTargetProtocol dropTargetProtocol = dropTargetProtocols.next();
if (dropTargetProtocol.isProtocolSupported(embedder)) {
embedderProtocols.add(dropTargetProtocol);
}
@@ -262,7 +261,7 @@
private void registerProtocols(long embedder, boolean protocols,
List<XDropTargetProtocol> supportedProtocols) {
- Iterator dropTargetProtocols = null;
+ Iterator<XDropTargetProtocol> dropTargetProtocols = null;
/*
* By default, we register a drop site that supports all dnd
@@ -289,8 +288,7 @@
XlibWrapper.XGrabServer(XToolkit.getDisplay());
try {
while (dropTargetProtocols.hasNext()) {
- XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ XDropTargetProtocol dropTargetProtocol = dropTargetProtocols.next();
if ((protocols == XEMBED_PROTOCOLS) ==
dropTargetProtocol.isXEmbedSupported()) {
dropTargetProtocol.registerEmbedderDropSite(embedder);
@@ -310,14 +308,13 @@
assert XToolkit.isAWTLockHeldByCurrentThread();
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
// The list of protocols supported by the embedder.
- List<XDropTargetProtocol> embedderProtocols = new ArrayList();
+ List<XDropTargetProtocol> embedderProtocols = new ArrayList<>();
while (dropTargetProtocols.hasNext()) {
- XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ XDropTargetProtocol dropTargetProtocol = dropTargetProtocols.next();
if (dropTargetProtocol.isProtocolSupported(embedder)) {
embedderProtocols.add(dropTargetProtocol);
}
@@ -361,8 +358,7 @@
XlibWrapper.XGrabServer(XToolkit.getDisplay());
try {
while (dropTargetProtocols.hasNext()) {
- XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ XDropTargetProtocol dropTargetProtocol = dropTargetProtocols.next();
if (!isXEmbedServer || !dropTargetProtocol.isXEmbedSupported()) {
dropTargetProtocol.registerEmbedderDropSite(embedder);
}
@@ -376,7 +372,7 @@
EmbeddedDropSiteEntry entry) {
assert XToolkit.isAWTLockHeldByCurrentThread();
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
/* Grab server, since we are working with the window that belongs to
@@ -384,8 +380,7 @@
XlibWrapper.XGrabServer(XToolkit.getDisplay());
try {
while (dropTargetProtocols.hasNext()) {
- XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ XDropTargetProtocol dropTargetProtocol = dropTargetProtocols.next();
dropTargetProtocol.unregisterEmbedderDropSite(embedder);
}
@@ -470,14 +465,14 @@
registerProtocols(toplevel, XEMBED_PROTOCOLS,
entry.getSupportedProtocols());
} else {
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
// Register the embedded window as a plain drop site with
// all DnD protocols that are supported by XEmbed.
while (dropTargetProtocols.hasNext()) {
XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ dropTargetProtocols.next();
if (dropTargetProtocol.isXEmbedSupported()) {
dropTargetProtocol.registerEmbedderDropSite(window);
}
@@ -558,12 +553,12 @@
}
if (toplevel == window) {
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
while (dropTargetProtocols.hasNext()) {
XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ dropTargetProtocols.next();
dropTargetProtocol.registerDropTarget(toplevel);
}
} else {
@@ -584,13 +579,13 @@
long toplevel = getToplevelWindow(window);
if (toplevel == window) {
- Iterator dropProtocols =
+ Iterator<XDropTargetProtocol> dropProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
removeDelayedRegistrationEntry(window);
while (dropProtocols.hasNext()) {
- XDropTargetProtocol dropProtocol = (XDropTargetProtocol)dropProtocols.next();
+ XDropTargetProtocol dropProtocol = dropProtocols.next();
dropProtocol.unregisterDropTarget(window);
}
} else {
@@ -615,12 +610,11 @@
}
registerEmbeddedDropSite(canvasWindow, clientWindow);
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
while (dropTargetProtocols.hasNext()) {
- XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ XDropTargetProtocol dropTargetProtocol = dropTargetProtocols.next();
dropTargetProtocol.registerEmbeddedDropSite(clientWindow);
}
@@ -634,12 +628,11 @@
if (logger.isLoggable(PlatformLogger.Level.FINE)) {
logger.fine(" XEmbed drop site will be unregistered for " + Long.toHexString(clientWindow));
}
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
while (dropTargetProtocols.hasNext()) {
- XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ XDropTargetProtocol dropTargetProtocol = dropTargetProtocols.next();
dropTargetProtocol.unregisterEmbeddedDropSite(clientWindow);
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XEmbeddingContainer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbeddingContainer.java Fri May 23 23:55:14 2014 +0000
@@ -32,7 +32,7 @@
import sun.awt.AWTAccessor;
public class XEmbeddingContainer extends XEmbedHelper implements XEventDispatcher {
- HashMap children = new HashMap();
+ HashMap<Long, java.awt.peer.ComponentPeer> children = new HashMap<>();
XEmbeddingContainer() {
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XFileDialogPeer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XFileDialogPeer.java Fri May 23 23:55:14 2014 +0000
@@ -146,9 +146,9 @@
savedDir = target.getDirectory();
// Shouldn't save 'user.dir' to 'savedDir'
// since getDirectory() will be incorrect after handleCancel
- userDir = (String)AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
+ userDir = AccessController.doPrivileged(
+ new PrivilegedAction<String>() {
+ public String run() {
return System.getProperty("user.dir");
}
});
--- a/jdk/src/solaris/classes/sun/awt/X11/XListPeer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XListPeer.java Fri May 23 23:55:14 2014 +0000
@@ -70,7 +70,7 @@
ListPainter painter;
// TODO: ick - Vector?
- Vector items;
+ Vector<String> items;
boolean multipleSelections;
int active = NONE;
@@ -139,7 +139,7 @@
super.preInit(params);
// Stuff that must be initialized before layout() is called
- items = new Vector();
+ items = new Vector<>();
createVerScrollbar();
createHorScrollbar();
@@ -281,7 +281,7 @@
int m = 0;
int end = items.size();
for(int i = 0 ; i < end ; i++) {
- int l = fm.stringWidth(((String)items.elementAt(i)));
+ int l = fm.stringWidth(items.elementAt(i));
m = Math.max(m, l);
}
return m;
@@ -292,7 +292,7 @@
*/
int getItemWidth(int i) {
FontMetrics fm = getFontMetrics(getFont());
- return fm.stringWidth((String)items.elementAt(i));
+ return fm.stringWidth(items.elementAt(i));
}
/**
@@ -659,7 +659,7 @@
( clickCount % 2 == 0 ) ) {
postEvent(new ActionEvent(target,
ActionEvent.ACTION_PERFORMED,
- (String)items.elementAt(currentIndex),
+ items.elementAt(currentIndex),
mouseEvent.getWhen(),
mouseEvent.getModifiers())); // No ext mods
} else if (active == WINDOW) {
@@ -986,7 +986,7 @@
if (selected.length > 0) {
postEvent(new ActionEvent((List)target,
ActionEvent.ACTION_PERFORMED,
- (String)items.elementAt(getFocusIndex()),
+ items.elementAt(getFocusIndex()),
e.getWhen(),
e.getModifiers())); // ActionEvent doesn't have
// extended modifiers.
@@ -1343,7 +1343,7 @@
*/
public void clear() {
selected = new int[0];
- items = new Vector();
+ items = new Vector<>();
currentIndex = -1;
// Fixed 6291736: ITEM_STATE_CHANGED triggered after List.removeAll(), XToolkit
// We should update 'focusIndex' variable more carefully
@@ -1926,7 +1926,7 @@
} else {
g.setColor(getListForeground());
}
- String str = (String)items.elementAt(index);
+ String str = items.elementAt(index);
g.drawString(str, x - hsb.getValue(), y + fontAscent);
} else {
// Clear the remaining area around the item - focus area and the rest of border
--- a/jdk/src/solaris/classes/sun/awt/X11/XMSelection.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XMSelection.java Fri May 23 23:55:14 2014 +0000
@@ -60,7 +60,7 @@
String selectionName;
/* list of listeners to be called for events */
- Vector listeners;
+ Vector<XMSelectionListener> listeners;
/* X atom array (one per screen) for this selection */
XAtom atoms[];
@@ -75,7 +75,7 @@
static XAtom XA_MANAGER;
- static HashMap selectionMap;
+ static HashMap<Long, XMSelection> selectionMap;
static {
long display = XToolkit.getDisplay();
@@ -90,7 +90,7 @@
initScreen(display,screen);
}
- selectionMap = new HashMap();
+ selectionMap = new HashMap<>();
}
static void initScreen(long display, final int screen) {
@@ -227,7 +227,7 @@
static XMSelection getInstance(long selection) {
- return (XMSelection) selectionMap.get(Long.valueOf(selection));
+ return selectionMap.get(Long.valueOf(selection));
}
@@ -259,7 +259,7 @@
public synchronized void addSelectionListener(XMSelectionListener listener) {
if (listeners == null) {
- listeners = new Vector();
+ listeners = new Vector<>();
}
listeners.add(listener);
}
@@ -270,7 +270,7 @@
}
}
- synchronized Collection getListeners() {
+ synchronized Collection<XMSelectionListener> getListeners() {
return listeners;
}
@@ -310,9 +310,9 @@
log.fine("Selection Changed : Screen = " + screen + "Event =" + ev);
}
if (listeners != null) {
- Iterator iter = listeners.iterator();
+ Iterator<XMSelectionListener> iter = listeners.iterator();
while (iter.hasNext()) {
- XMSelectionListener disp = (XMSelectionListener) iter.next();
+ XMSelectionListener disp = iter.next();
disp.selectionChanged(screen, this, ev.get_window(), ev);
}
}
@@ -323,9 +323,9 @@
log.fine("Owner dead : Screen = " + screen + "Event =" + de);
}
if (listeners != null) {
- Iterator iter = listeners.iterator();
+ Iterator<XMSelectionListener> iter = listeners.iterator();
while (iter.hasNext()) {
- XMSelectionListener disp = (XMSelectionListener) iter.next();
+ XMSelectionListener disp = iter.next();
disp.ownerDeath(screen, this, de.get_window());
}
@@ -349,9 +349,9 @@
synchronized void dispatchOwnerChangedEvent(XEvent ev, int screen, long owner, long data, long timestamp) {
if (listeners != null) {
- Iterator iter = listeners.iterator();
+ Iterator<XMSelectionListener> iter = listeners.iterator();
while (iter.hasNext()) {
- XMSelectionListener disp = (XMSelectionListener) iter.next();
+ XMSelectionListener disp = iter.next();
disp.ownerChanged(screen,this, owner, data, timestamp);
}
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XMenuBarPeer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XMenuBarPeer.java Fri May 23 23:55:14 2014 +0000
@@ -195,10 +195,10 @@
void postInit(XCreateWindowParams params) {
super.postInit(params);
// Get menus from the target.
- Vector targetMenuVector = AWTAccessor.getMenuBarAccessor()
- .getMenus(menuBarTarget);
+ Vector<Menu> targetMenuVector = AWTAccessor.getMenuBarAccessor()
+ .getMenus(menuBarTarget);
Menu targetHelpMenu = AWTAccessor.getMenuBarAccessor()
- .getHelpMenu(menuBarTarget);
+ .getHelpMenu(menuBarTarget);
reloadItems(targetMenuVector);
if (targetHelpMenu != null) {
addHelpMenu(targetHelpMenu);
--- a/jdk/src/solaris/classes/sun/awt/X11/XMenuPeer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XMenuPeer.java Fri May 23 23:55:14 2014 +0000
@@ -143,7 +143,7 @@
* Access to target's fields
*
************************************************/
- Vector getTargetItems() {
+ Vector<MenuItem> getTargetItems() {
return AWTAccessor.getMenuAccessor().getItems((Menu)getTarget());
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XMenuWindow.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XMenuWindow.java Fri May 23 23:55:14 2014 +0000
@@ -164,7 +164,7 @@
this.menuPeer = menuPeer;
this.target = menuPeer.getContainer().target;
// Get menus from the target.
- Vector targetItemVector = null;
+ Vector<MenuItem> targetItemVector = null;
targetItemVector = getMenuTargetItems();
reloadItems(targetItemVector);
}
@@ -356,7 +356,7 @@
* Reads vector of items from target
* This function is overriden in XPopupMenuPeer
*/
- Vector getMenuTargetItems() {
+ Vector<MenuItem> getMenuTargetItems() {
return menuPeer.getTargetItems();
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XPopupMenuPeer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XPopupMenuPeer.java Fri May 23 23:55:14 2014 +0000
@@ -134,7 +134,7 @@
public void show(Event e) {
target = (Component)e.target;
// Get menus from the target.
- Vector targetItemVector = getMenuTargetItems();
+ Vector<MenuItem> targetItemVector = getMenuTargetItems();
if (targetItemVector != null) {
reloadItems(targetItemVector);
//Fix for 6287092: JCK15a: api/java_awt/interactive/event/EventTests.html#EventTest0015 fails, mustang
@@ -188,7 +188,7 @@
return AWTAccessor.getMenuItemAccessor().isEnabled(popupMenuTarget);
}
- Vector getMenuTargetItems() {
+ Vector<MenuItem> getMenuTargetItems() {
if (popupMenuTarget == null) {
return null;
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XSelection.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XSelection.java Fri May 23 23:55:14 2014 +0000
@@ -25,6 +25,7 @@
package sun.awt.X11;
+import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.io.ByteArrayOutputStream;
@@ -87,7 +88,7 @@
/* The contents supplied by the current owner. */
private Transferable contents = null;
/* The format-to-flavor map for the current owner. */
- private Map formatMap = null;
+ private Map<Long, DataFlavor> formatMap = null;
/* The formats supported by the current owner was set. */
private long[] formats = null;
/* The AppContext in which the current owner was set. */
@@ -134,7 +135,8 @@
return selectionAtom;
}
- public synchronized boolean setOwner(Transferable contents, Map formatMap,
+ public synchronized boolean setOwner(Transferable contents,
+ Map<Long, DataFlavor> formatMap,
long[] formats, long time)
{
long owner = XWindow.getXAWTRootWindow().getWindow();
--- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Fri May 23 23:55:14 2014 +0000
@@ -36,6 +36,7 @@
import java.awt.dnd.MouseDragGestureRecognizer;
import java.awt.dnd.InvalidDnDOperationException;
import java.awt.dnd.peer.DragSourceContextPeer;
+import java.awt.font.TextAttribute;
import java.awt.im.InputMethodHighlight;
import java.awt.im.spi.InputMethodDescriptor;
import java.awt.image.ColorModel;
@@ -51,7 +52,7 @@
import sun.font.FontConfigManager;
import sun.java2d.SunGraphicsEnvironment;
import sun.misc.*;
-import sun.misc.ThreadGroupUtils;
+import sun.awt.util.ThreadGroupUtils;
import sun.print.PrintJob2D;
import sun.security.action.GetPropertyAction;
import sun.security.action.GetBooleanAction;
@@ -99,9 +100,9 @@
private FontConfigManager fcManager = new FontConfigManager();
static int arrowCursor;
- static TreeMap winMap = new TreeMap();
- static HashMap specialPeerMap = new HashMap();
- static HashMap winToDispatcher = new HashMap();
+ static TreeMap<Long, XBaseWindow> winMap = new TreeMap<>();
+ static HashMap<Object, Object> specialPeerMap = new HashMap<>();
+ static HashMap<Long, Collection<XEventDispatcher>> winToDispatcher = new HashMap<>();
private static long _display;
static UIDefaults uidefaults;
static X11GraphicsEnvironment localEnv;
@@ -358,16 +359,16 @@
}
static XBaseWindow windowToXWindow(long window) {
synchronized(winMap) {
- return (XBaseWindow) winMap.get(Long.valueOf(window));
+ return winMap.get(Long.valueOf(window));
}
}
static void addEventDispatcher(long window, XEventDispatcher dispatcher) {
synchronized(winToDispatcher) {
Long key = Long.valueOf(window);
- Collection dispatchers = (Collection)winToDispatcher.get(key);
+ Collection<XEventDispatcher> dispatchers = winToDispatcher.get(key);
if (dispatchers == null) {
- dispatchers = new Vector();
+ dispatchers = new Vector<>();
winToDispatcher.put(key, dispatchers);
}
dispatchers.add(dispatcher);
@@ -376,7 +377,7 @@
static void removeEventDispatcher(long window, XEventDispatcher dispatcher) {
synchronized(winToDispatcher) {
Long key = Long.valueOf(window);
- Collection dispatchers = (Collection)winToDispatcher.get(key);
+ Collection<XEventDispatcher> dispatchers = winToDispatcher.get(key);
if (dispatchers != null) {
dispatchers.remove(dispatcher);
}
@@ -493,18 +494,18 @@
}
XBaseWindow.dispatchToWindow(ev);
- Collection dispatchers = null;
+ Collection<XEventDispatcher> dispatchers = null;
synchronized(winToDispatcher) {
Long key = Long.valueOf(xany.get_window());
- dispatchers = (Collection)winToDispatcher.get(key);
+ dispatchers = winToDispatcher.get(key);
if (dispatchers != null) { // Clone it to avoid synchronization during dispatching
- dispatchers = new Vector(dispatchers);
+ dispatchers = new Vector<>(dispatchers);
}
}
if (dispatchers != null) {
- Iterator iter = dispatchers.iterator();
+ Iterator<XEventDispatcher> iter = dispatchers.iterator();
while (iter.hasNext()) {
- XEventDispatcher disp = (XEventDispatcher)iter.next();
+ XEventDispatcher disp = iter.next();
disp.dispatchEvent(ev);
}
}
@@ -764,7 +765,7 @@
Insets insets = new Insets(0, 0, 0, 0);
- java.util.List search = new LinkedList();
+ java.util.List<Object> search = new LinkedList<>();
search.add(root);
search.add(0);
while (!search.isEmpty())
@@ -929,6 +930,7 @@
return XDragSourceContextPeer.createDragSourceContextPeer(dge);
}
+ @SuppressWarnings("unchecked")
public <T extends DragGestureRecognizer> T
createDragGestureRecognizer(Class<T> recognizerClass,
DragSource ds,
@@ -1147,7 +1149,7 @@
return 2; // Black and white.
}
- public Map mapInputMethodHighlight(InputMethodHighlight highlight) {
+ public Map<TextAttribute, ?> mapInputMethodHighlight( InputMethodHighlight highlight) {
return XInputMethod.mapInputMethodHighlight(highlight);
}
@Override
@@ -1338,31 +1340,25 @@
static void dumpPeers() {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
log.fine("Mapped windows:");
- Iterator iter = winMap.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry)iter.next();
- log.fine(entry.getKey() + "->" + entry.getValue());
- if (entry.getValue() instanceof XComponentPeer) {
- Component target = (Component)((XComponentPeer)entry.getValue()).getTarget();
+ winMap.forEach((k, v) -> {
+ log.fine(k + "->" + v);
+ if (v instanceof XComponentPeer) {
+ Component target = (Component)((XComponentPeer)v).getTarget();
log.fine("\ttarget: " + target);
}
- }
+ });
SunToolkit.dumpPeers(log);
log.fine("Mapped special peers:");
- iter = specialPeerMap.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry)iter.next();
- log.fine(entry.getKey() + "->" + entry.getValue());
- }
+ specialPeerMap.forEach((k, v) -> {
+ log.fine(k + "->" + v);
+ });
log.fine("Mapped dispatchers:");
- iter = winToDispatcher.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry)iter.next();
- log.fine(entry.getKey() + "->" + entry.getValue());
- }
+ winToDispatcher.forEach((k, v) -> {
+ log.fine(k + "->" + v);
+ });
}
}
@@ -1586,16 +1582,16 @@
* <code>loadXSettings</code>. It is called from the System EDT
* if triggered by an XSETTINGS change.
*/
- void parseXSettings(int screen_XXX_ignored,Map updatedSettings) {
+ void parseXSettings(int screen_XXX_ignored,Map<String, Object> updatedSettings) {
if (updatedSettings == null || updatedSettings.isEmpty()) {
return;
}
- Iterator i = updatedSettings.entrySet().iterator();
+ Iterator<Map.Entry<String, Object>> i = updatedSettings.entrySet().iterator();
while (i.hasNext()) {
- Map.Entry e = (Map.Entry)i.next();
- String name = (String)e.getKey();
+ Map.Entry<String, Object> e = i.next();
+ String name = e.getKey();
name = "gnome." + name;
setDesktopProperty(name, e.getValue());
@@ -1692,7 +1688,7 @@
long window = 0;
try{
// get any application window
- window = ((Long)(winMap.firstKey())).longValue();
+ window = winMap.firstKey().longValue();
}catch(NoSuchElementException nex) {
// get root window
window = getDefaultRootWindow();
@@ -1798,7 +1794,7 @@
}
- private static SortedMap timeoutTasks;
+ private static SortedMap<Long, java.util.List<Runnable>> timeoutTasks;
/**
* Removed the task from the list of waiting-to-be called tasks.
@@ -1819,10 +1815,10 @@
}
return;
}
- Collection values = timeoutTasks.values();
- Iterator iter = values.iterator();
+ Collection<java.util.List<Runnable>> values = timeoutTasks.values();
+ Iterator<java.util.List<Runnable>> iter = values.iterator();
while (iter.hasNext()) {
- java.util.List list = (java.util.List)iter.next();
+ java.util.List<Runnable> list = iter.next();
boolean removed = false;
if (list.contains(task)) {
list.remove(task);
@@ -1869,13 +1865,13 @@
}
if (timeoutTasks == null) {
- timeoutTasks = new TreeMap();
+ timeoutTasks = new TreeMap<>();
}
Long time = Long.valueOf(System.currentTimeMillis() + interval);
- java.util.List tasks = (java.util.List)timeoutTasks.get(time);
+ java.util.List<Runnable> tasks = timeoutTasks.get(time);
if (tasks == null) {
- tasks = new ArrayList(1);
+ tasks = new ArrayList<>(1);
timeoutTasks.put(time, tasks);
}
tasks.add(task);
@@ -1897,7 +1893,7 @@
if (timeoutTasks == null || timeoutTasks.isEmpty()) {
return -1L;
}
- return (Long)timeoutTasks.firstKey();
+ return timeoutTasks.firstKey();
} finally {
awtUnlock();
}
@@ -1918,13 +1914,13 @@
}
Long currentTime = Long.valueOf(System.currentTimeMillis());
- Long time = (Long)timeoutTasks.firstKey();
+ Long time = timeoutTasks.firstKey();
while (time.compareTo(currentTime) <= 0) {
- java.util.List tasks = (java.util.List)timeoutTasks.remove(time);
+ java.util.List<Runnable> tasks = timeoutTasks.remove(time);
- for (Iterator iter = tasks.iterator(); iter.hasNext();) {
- Runnable task = (Runnable)iter.next();
+ for (Iterator<Runnable> iter = tasks.iterator(); iter.hasNext();) {
+ Runnable task = iter.next();
if (timeoutTaskLog.isLoggable(PlatformLogger.Level.FINER)) {
timeoutTaskLog.finer("XToolkit.callTimeoutTasks(): current time={0}" +
@@ -1943,7 +1939,7 @@
if (timeoutTasks.isEmpty()) {
break;
}
- time = (Long)timeoutTasks.firstKey();
+ time = timeoutTasks.firstKey();
}
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java Fri May 23 23:55:14 2014 +0000
@@ -85,7 +85,7 @@
// Fix for 6317038: as EmbeddedFrame is instance of Frame, it is blocked
// by modal dialogs, but in the case of TrayIcon it shouldn't. So we
// set ModalExclusion property on it.
- AccessController.doPrivileged(new PrivilegedAction() {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
eframe.setModalExclusionType(Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
return null;
--- a/jdk/src/solaris/classes/sun/awt/X11/XWM.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XWM.java Fri May 23 23:55:14 2014 +0000
@@ -1072,6 +1072,7 @@
* Returns all protocols supporting given protocol interface
*/
<T> Collection<T> getProtocols(Class<T> protocolInterface) {
+ @SuppressWarnings("unchecked")
Collection<T> res = (Collection<T>) protocolsMap.get(protocolInterface);
if (res != null) {
return res;
@@ -1322,9 +1323,9 @@
}
}
- HashMap storedInsets = new HashMap();
+ HashMap<Class<?>, Insets> storedInsets = new HashMap<>();
Insets guessInsets(XDecoratedPeer window) {
- Insets res = (Insets)storedInsets.get(window.getClass());
+ Insets res = storedInsets.get(window.getClass());
if (res == null) {
switch (WMID) {
case ENLIGHTEN_WM:
--- a/jdk/src/solaris/classes/sun/awt/X11/XWindow.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XWindow.java Fri May 23 23:55:14 2014 +0000
@@ -59,7 +59,7 @@
static int lastX = 0, lastY = 0;
static long lastTime = 0;
static long lastButton = 0;
- static WeakReference lastWindowRef = null;
+ static WeakReference<XWindow> lastWindowRef = null;
static int clickCount = 0;
// used to check if we need to re-create surfaceData.
@@ -692,7 +692,7 @@
if (type == XConstants.ButtonPress) {
//Allow this mouse button to generate CLICK event on next ButtonRelease
mouseButtonClickAllowed |= XlibUtil.getButtonMask(lbutton);
- XWindow lastWindow = (lastWindowRef != null) ? ((XWindow)lastWindowRef.get()):(null);
+ XWindow lastWindow = (lastWindowRef != null) ? (lastWindowRef.get()):(null);
/*
multiclick checking
*/
@@ -705,7 +705,7 @@
clickCount++;
} else {
clickCount = 1;
- lastWindowRef = new WeakReference(this);
+ lastWindowRef = new WeakReference<>(this);
lastButton = lbutton;
lastX = x;
lastY = y;
@@ -820,7 +820,7 @@
*/
int x = xme.get_x();
int y = xme.get_y();
- XWindow lastWindow = (lastWindowRef != null) ? ((XWindow)lastWindowRef.get()):(null);
+ XWindow lastWindow = (lastWindowRef != null) ? (lastWindowRef.get()):(null);
if (!(lastWindow == this &&
(xme.get_time() - lastTime) < XToolkit.getMultiClickTime() &&
--- a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java Fri May 23 23:55:14 2014 +0000
@@ -950,7 +950,7 @@
// make new hash of toplevels of all windows from 'windows' hash.
// FIXME: do not call them "toplevel" as it is misleading.
//
- HashSet toplevels = new HashSet();
+ HashSet<Long> toplevels = new HashSet<>();
long topl = 0, mytopl = 0;
for (XWindowPeer xp : windows) {
--- a/jdk/src/solaris/classes/sun/awt/X11CustomCursor.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11CustomCursor.java Fri May 23 23:55:14 2014 +0000
@@ -47,7 +47,7 @@
protected void createNativeCursor(Image im, int[] pixels, int width, int height,
int xHotSpot, int yHotSpot) {
- class CCount implements Comparable {
+ class CCount implements Comparable<CCount> {
int color;
int count;
@@ -56,8 +56,8 @@
count = ct;
}
- public int compareTo(Object cc) {
- return ((CCount)cc).count - count;
+ public int compareTo(CCount cc) {
+ return cc.count - count;
}
}
--- a/jdk/src/solaris/classes/sun/awt/X11FontManager.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11FontManager.java Fri May 23 23:55:14 2014 +0000
@@ -59,7 +59,7 @@
* E.g., the -0-0-0-0-p-0- reported by X is -*-%d-*-*-p-*- in the font
* configuration files. We need to remove that part for comparisons.
*/
- private static Map fontNameMap = new HashMap();
+ private static Map<String, String> fontNameMap = new HashMap<>();
/*
* xlfdMap is a map from a platform path like
@@ -72,7 +72,7 @@
* the full XLFD string like :-
* "-ricoh-hg gothic b-medium-r-normal--0-0-0-0-m-0-jisx0201.1976-0"
*/
- private static Map xlfdMap = new HashMap();
+ private static Map<String, Vector<String>> xlfdMap = new HashMap<>();
/* xFontDirsMap is also a map from a font ID to a font filepath.
* The difference from fontNameMap is just that it does not have
@@ -88,7 +88,7 @@
* X11 font directory, then precautions must be taken to include both
* directories.
*/
- private static Map xFontDirsMap;
+ private static Map<String, String> xFontDirsMap;
/*
* This is the set of font directories needed to be on the X font path
@@ -121,7 +121,7 @@
* of the singleton GE instance is already synchronised and that is
* the only code path that accesses this map.
*/
- private static HashMap registeredDirs = new HashMap();
+ private static HashMap<String, Object> registeredDirs = new HashMap<>();
/* Array of directories to be added to the X11 font path.
* Used by static method called from Toolkits which use X11 fonts.
@@ -183,7 +183,7 @@
* Add this XLFD (platform name) to the list of known
* ones for this file.
*/
- Vector xVal = (Vector) xlfdMap.get(fileName);
+ Vector<String> xVal = xlfdMap.get(fileName);
if (xVal == null) {
/* Try to be robust on Linux distros which move fonts
* around by verifying that the fileName represents a
@@ -194,7 +194,7 @@
fileName = null;
}
if (fileName != null) {
- xVal = new Vector();
+ xVal = new Vector<>();
xVal.add(platName);
xlfdMap.put(fileName, xVal);
}
@@ -211,7 +211,7 @@
}
if (fontID != null) {
- fileName = (String)fontNameMap.get(fontID);
+ fileName = fontNameMap.get(fontID);
/* On Linux check for the Lucida Oblique fonts */
if (fileName == null && FontUtilities.isLinux && !isOpenJDK()) {
if (oblmap == null) {
@@ -235,7 +235,7 @@
FontUtilities.getLogger()
.warning("** Finished registering all font paths");
}
- fileName = (String)fontNameMap.get(fontID);
+ fileName = fontNameMap.get(fontID);
}
if (fileName == null && !isHeadless()) {
/* Query X11 directly to see if this font is available
@@ -245,7 +245,7 @@
}
if (fileName == null) {
fontID = switchFontIDForName(platName);
- fileName = (String)fontNameMap.get(fontID);
+ fileName = fontNameMap.get(fontID);
}
if (fileName != null) {
fontNameMap.put(fontID, fileName);
@@ -257,8 +257,8 @@
@Override
protected String[] getNativeNames(String fontFileName,
String platformName) {
- Vector nativeNames;
- if ((nativeNames=(Vector)xlfdMap.get(fontFileName))==null) {
+ Vector<String> nativeNames;
+ if ((nativeNames=xlfdMap.get(fontFileName))==null) {
if (platformName == null) {
return null;
} else {
@@ -271,7 +271,7 @@
}
} else {
int len = nativeNames.size();
- return (String[])nativeNames.toArray(new String[len]);
+ return nativeNames.toArray(new String[len]);
}
}
@@ -366,7 +366,7 @@
}
String fontPart = st.sval.substring(breakPos+1);
String fontID = specificFontIDForName(fontPart);
- String sVal = (String) fontNameMap.get(fontID);
+ String sVal = fontNameMap.get(fontID);
if (FontUtilities.debugFonts()) {
PlatformLogger logger = FontUtilities.getLogger();
@@ -386,14 +386,14 @@
* wants to use the native rasteriser.
*/
if (xFontDirsMap == null) {
- xFontDirsMap = new HashMap();
+ xFontDirsMap = new HashMap<>();
}
xFontDirsMap.put(fontID, path);
fullPath = file.getCanonicalPath();
} catch (IOException e) {
fullPath = path + File.separator + fileName;
}
- Vector xVal = (Vector) xlfdMap.get(fullPath);
+ Vector<String> xVal = xlfdMap.get(fullPath);
if (FontUtilities.debugFonts()) {
FontUtilities.getLogger()
.info("fullPath=" + fullPath +
@@ -408,7 +408,7 @@
}
fontNameMap.put(fontID, fullPath);
if (xVal == null) {
- xVal = new Vector();
+ xVal = new Vector<>();
xlfdMap.put (fullPath, xVal);
}
xVal.add(fontPart);
@@ -447,8 +447,8 @@
* will typically not ever need to initialise it so it can be null.
*/
xFontDirsMap = null;
- xlfdMap = new HashMap(1);
- fontNameMap = new HashMap(1);
+ xlfdMap = new HashMap<>(1);
+ fontNameMap = new HashMap<>(1);
}
private String getObliqueLucidaFontID(String fontID) {
@@ -579,10 +579,10 @@
String fileName = null;
String fontID = specificFontIDForName(name);
if (fontID != null) {
- fileName = (String)fontNameMap.get(fontID);
+ fileName = fontNameMap.get(fontID);
if (fileName == null) {
fontID = switchFontIDForName(name);
- fileName = (String)fontNameMap.get(fontID);
+ fileName = fontNameMap.get(fontID);
}
if (fileName == null) {
fileName = getDefaultFontFile();
@@ -685,7 +685,7 @@
getPlatformFontPathFromFontConfig();
if (xFontDirsMap != null) {
String fontID = specificFontIDForName(platformName);
- String dirName = (String)xFontDirsMap.get(fontID);
+ String dirName = xFontDirsMap.get(fontID);
if (dirName != null) {
fontConfigDirs.add(dirName);
}
--- a/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java Fri May 23 23:55:14 2014 +0000
@@ -42,7 +42,7 @@
import sun.java2d.xr.XRGraphicsConfig;
import sun.java2d.loops.SurfaceType;
-import sun.misc.ThreadGroupUtils;
+import sun.awt.util.ThreadGroupUtils;
/**
* This is an implementation of a GraphicsDevice object for a single
@@ -56,7 +56,7 @@
implements DisplayChangedListener
{
int screen;
- HashMap x11ProxyKeyMap = new HashMap();
+ HashMap<SurfaceType, Object> x11ProxyKeyMap = new HashMap<>();
private static AWTPermission fullScreenExclusivePermission;
private static Boolean xrandrExtSupported;
@@ -127,7 +127,7 @@
GraphicsConfiguration[] configs;
GraphicsConfiguration defaultConfig;
- HashSet doubleBufferVisuals;
+ HashSet<Integer> doubleBufferVisuals;
/**
* Returns all of the graphics
@@ -159,7 +159,7 @@
boolean dbeSupported = isDBESupported();
if (dbeSupported && doubleBufferVisuals == null) {
- doubleBufferVisuals = new HashSet();
+ doubleBufferVisuals = new HashSet<>();
getDoubleBufferVisuals(screen);
}
for ( ; i < num; i++) {
@@ -249,7 +249,7 @@
int depth = getConfigDepth(0, screen);
boolean doubleBuffer = false;
if (isDBESupported() && doubleBufferVisuals == null) {
- doubleBufferVisuals = new HashSet();
+ doubleBufferVisuals = new HashSet<>();
getDoubleBufferVisuals(screen);
doubleBuffer =
doubleBufferVisuals.contains(Integer.valueOf(visNum));
--- a/jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java Fri May 23 23:55:14 2014 +0000
@@ -72,7 +72,7 @@
static {
java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
+ new java.security.PrivilegedAction<Object>() {
public Object run() {
System.loadLibrary("awt");
@@ -254,12 +254,12 @@
return true;
}
- Boolean result = (Boolean)java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Object run() {
+ Boolean result = java.security.AccessController.doPrivileged(
+ new java.security.PrivilegedAction<Boolean>() {
+ public Boolean run() {
InetAddress remAddr[] = null;
- Enumeration locals = null;
- Enumeration interfaces = null;
+ Enumeration<InetAddress> locals = null;
+ Enumeration<NetworkInterface> interfaces = null;
try {
interfaces = NetworkInterface.getNetworkInterfaces();
remAddr = InetAddress.getAllByName(hostName);
@@ -275,10 +275,11 @@
}
for (; interfaces.hasMoreElements();) {
- locals = ((NetworkInterface)interfaces.nextElement()).getInetAddresses();
+ locals = interfaces.nextElement().getInetAddresses();
for (; locals.hasMoreElements();) {
+ final InetAddress localAddr = locals.nextElement();
for (int i = 0; i < remAddr.length; i++) {
- if (locals.nextElement().equals(remAddr[i])) {
+ if (localAddr.equals(remAddr[i])) {
return Boolean.TRUE;
}
}
--- a/jdk/src/solaris/classes/sun/awt/X11InputMethod.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11InputMethod.java Fri May 23 23:55:14 2014 +0000
@@ -100,7 +100,7 @@
private boolean isLastTemporary = false;
private boolean isActive = false;
private boolean isActiveClient = false;
- private static Map[] highlightStyles;
+ private static Map<TextAttribute, ?>[] highlightStyles;
private boolean disposed = false;
//reset the XIC if necessary
@@ -136,31 +136,29 @@
// Initialize highlight mapping table
static {
- Map styles[] = new Map[4];
- HashMap map;
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ Map<TextAttribute, ?> styles[] = new Map[4];
+ HashMap<TextAttribute, Object> map;
// UNSELECTED_RAW_TEXT_HIGHLIGHT
- map = new HashMap(1);
- map.put(TextAttribute.WEIGHT,
- TextAttribute.WEIGHT_BOLD);
+ map = new HashMap<>(1);
+ map.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
styles[0] = Collections.unmodifiableMap(map);
// SELECTED_RAW_TEXT_HIGHLIGHT
- map = new HashMap(1);
- map.put(TextAttribute.SWAP_COLORS,
- TextAttribute.SWAP_COLORS_ON);
+ map = new HashMap<>(1);
+ map.put(TextAttribute.SWAP_COLORS, TextAttribute.SWAP_COLORS_ON);
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_ONE_PIXEL);
+ TextAttribute.UNDERLINE_LOW_ONE_PIXEL);
styles[2] = Collections.unmodifiableMap(map);
// SELECTED_CONVERTED_TEXT_HIGHLIGHT
- map = new HashMap(1);
- map.put(TextAttribute.SWAP_COLORS,
- TextAttribute.SWAP_COLORS_ON);
+ map = new HashMap<>(1);
+ map.put(TextAttribute.SWAP_COLORS, TextAttribute.SWAP_COLORS_ON);
styles[3] = Collections.unmodifiableMap(map);
highlightStyles = styles;
@@ -433,7 +431,7 @@
/**
* @see java.awt.Toolkit#mapInputMethodHighlight
*/
- public static Map mapInputMethodHighlight(InputMethodHighlight highlight) {
+ public static Map<TextAttribute, ?> mapInputMethodHighlight(InputMethodHighlight highlight) {
int index;
int state = highlight.getState();
if (state == InputMethodHighlight.RAW_TEXT) {
--- a/jdk/src/solaris/classes/sun/awt/XSettings.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/XSettings.java Fri May 23 23:55:14 2014 +0000
@@ -52,7 +52,7 @@
* settings manager.
* @return a <code>Map</code> of changed settings.
*/
- public Map update(byte[] data) {
+ public Map<String, Object> update(byte[] data) {
return (new Update(data)).update();
}
@@ -79,7 +79,7 @@
private int nsettings = 0;
private boolean isValid;
- private HashMap updatedSettings;
+ private HashMap<String, Object> updatedSettings;
/**
@@ -113,7 +113,7 @@
idx = 8;
nsettings = getINT32();
- updatedSettings = new HashMap();
+ updatedSettings = new HashMap<>();
isValid = true;
}
@@ -213,7 +213,7 @@
/**
* Update settings.
*/
- public Map update() {
+ public Map<String, Object> update() {
if (!isValid) {
return null;
}
--- a/jdk/src/solaris/classes/sun/awt/motif/MFontConfiguration.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/awt/motif/MFontConfiguration.java Fri May 23 23:55:14 2014 +0000
@@ -67,7 +67,7 @@
* the fontconfig files.
*/
protected void initReorderMap() {
- reorderMap = new HashMap();
+ reorderMap = new HashMap<>();
if (osName == null) { /* null means SunOS */
initReorderMapForSolaris();
} else {
@@ -240,7 +240,7 @@
return "sun.awt.Symbol";
}
}
- String encoding = (String) encodingMap.get(xlfdEncoding);
+ String encoding = encodingMap.get(xlfdEncoding);
if (encoding == null) {
encoding = "default";
}
@@ -288,7 +288,7 @@
/* methods for table setup ***********************************************/
- private static HashMap encodingMap = new HashMap();
+ private static HashMap<String, String> encodingMap = new HashMap<>();
private void initTables() {
// encodingMap maps XLFD encoding component to
--- a/jdk/src/solaris/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine Thu May 22 20:24:42 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-# Jules Rendering Engine module
-sun.java2d.jules.JulesRenderingEngine
-
-# Pisces Rendering Engine module
-sun.java2d.pisces.PiscesRenderingEngine
--- a/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java Fri May 23 23:55:14 2014 +0000
@@ -72,7 +72,7 @@
protected int depth;
- private static native void initIDs(Class xorComp, boolean tryDGA);
+ private static native void initIDs(Class<?> xorComp, boolean tryDGA);
protected native void initSurface(int depth, int width, int height,
long drawable);
@@ -515,6 +515,7 @@
return getSurfaceType(gc, transparency, false);
}
+ @SuppressWarnings("fallthrough")
public static SurfaceType getSurfaceType(X11GraphicsConfig gc,
int transparency,
boolean pixmapSurface)
--- a/jdk/src/solaris/native/sun/awt/awt.h Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/native/sun/awt/awt.h Fri May 23 23:55:14 2014 +0000
@@ -34,9 +34,9 @@
#include "jni_util.h"
#include "debug_util.h"
-#ifndef HEADLESS
+#if !defined(HEADLESS) && !defined(MACOSX)
#include <X11/Intrinsic.h>
-#endif /* !HEADLESS */
+#endif /* !HEADLESS && !MACOSX */
/* The JVM instance: defined in awt_MToolkit.c */
@@ -110,9 +110,9 @@
#define AWT_NOTIFY() AWT_NOTIFY_IMPL()
#define AWT_NOTIFY_ALL() AWT_NOTIFY_ALL_IMPL()
-#ifndef HEADLESS
+#if !defined(HEADLESS) && !defined(MACOSX)
extern Display *awt_display; /* awt_GraphicsEnv.c */
extern Boolean awt_ModLockIsShiftLock; /* XToolkit.c */
-#endif /* !HEADLESS */
+#endif /* !HEADLESS && !MACOSX */
#endif /* ! _AWT_ */
--- a/jdk/src/solaris/native/sun/awt/awt_LoadLibrary.c Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/native/sun/awt/awt_LoadLibrary.c Fri May 23 23:55:14 2014 +0000
@@ -35,8 +35,6 @@
#include <sys/param.h>
#include <sys/utsname.h>
-#include "awt_Plugin.h"
-
#ifdef AIX
#include "porting_aix.h" /* For the 'dladdr' function. */
#endif
@@ -236,55 +234,3 @@
(*XsessionWMcommand)(env, jargv);
}
-
-
-#define REFLECT_VOID_FUNCTION(name, arglist, paramlist) \
-typedef void name##_type arglist; \
-void name arglist \
-{ \
- static name##_type *name##_ptr = NULL; \
- if (name##_ptr == NULL && awtHandle == NULL) { \
- return; \
- } \
- name##_ptr = (name##_type *) \
- dlsym(awtHandle, #name); \
- if (name##_ptr == NULL) { \
- return; \
- } \
- (*name##_ptr)paramlist; \
-}
-
-#define REFLECT_FUNCTION(return_type, name, arglist, paramlist) \
-typedef return_type name##_type arglist; \
-return_type name arglist \
-{ \
- static name##_type *name##_ptr = NULL; \
- if (name##_ptr == NULL && awtHandle == NULL) { \
- return NULL; \
- } \
- name##_ptr = (name##_type *) \
- dlsym(awtHandle, #name); \
- if (name##_ptr == NULL) { \
- return NULL; \
- } \
- return (*name##_ptr)paramlist; \
-}
-
-
-/*
- * These entry point must remain in libawt.so ***for Java Plugin ONLY***
- * Reflect this call over to the correct libawt_<toolkit>.so.
- */
-
-REFLECT_VOID_FUNCTION(getAwtLockFunctions,
- (void (**AwtLock)(JNIEnv *), void (**AwtUnlock)(JNIEnv *),
- void (**AwtNoFlushUnlock)(JNIEnv *), void *reserved),
- (AwtLock, AwtUnlock, AwtNoFlushUnlock, reserved))
-
-REFLECT_VOID_FUNCTION(getAwtData,
- (int32_t *awt_depth, Colormap *awt_cmap, Visual **awt_visual,
- int32_t *awt_num_colors, void *pReserved),
- (awt_depth, awt_cmap, awt_visual,
- awt_num_colors, pReserved))
-
-REFLECT_FUNCTION(Display *, getAwtDisplay, (void), ())
--- a/jdk/src/solaris/native/sun/awt/awt_Plugin.c Thu May 22 20:24:42 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,149 +0,0 @@
-/*
- * Copyright (c) 1999, 2001, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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.
- */
-
-#ifdef HEADLESS
- #error This file should not be included in headless library
-#endif
-
-#include <jni.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <awt.h>
-#include <awt_p.h>
-
-/*
- * Fix 4221246: Provide utility function for Netscape to use to
- * get AWT display, depth, colormap, and number of colors.
- *
- */
-
-Display *getAwtDisplay(void)
-{
- return awt_display;
-}
-
-void getExtAwtData(Display *display,
- int32_t screen,
- int32_t *awt_depth,
- Colormap *awt_cmap,
- Visual **awt_visual,
- int32_t *awt_num_colors,
- void *pReserved)
-{
- AwtGraphicsConfigDataPtr defaultConfig = NULL;
-
-#ifdef DEBUG
- if (pReserved != NULL) {
- jio_fprintf(stderr,
- "getExtAwtData: warning: reserved pointer is not null\n");
- }
-#endif
-
- if (screen >= 0) {
- defaultConfig = getDefaultConfig(screen);
- }
-
- if (defaultConfig) {
- if (awt_depth != NULL) {
- *awt_depth = defaultConfig->awt_depth;
- }
-
- if (awt_cmap != NULL) {
- *awt_cmap = defaultConfig->awt_cmap;
- }
-
- if (awt_visual != NULL) {
- *awt_visual = defaultConfig->awt_visInfo.visual;
- }
-
- if (awt_num_colors != NULL) {
- *awt_num_colors = defaultConfig->awt_num_colors;
- }
- }
-}
-
-/*
- * getAwtData provided for compatibility with Solaris 1.2 Java Plug-in
- *
- */
-void getAwtData(int32_t *awt_depth,
- Colormap *awt_cmap,
- Visual **awt_visual,
- int32_t *awt_num_colors,
- void *pReserved)
-{
- Display *display = getAwtDisplay();
-
- getExtAwtData(display,
- DefaultScreen(display),
- awt_depth,
- awt_cmap,
- awt_visual,
- awt_num_colors,
- pReserved);
-}
-
-/*
- * Fix 4221246: Provide utility funtion for Netscape to get
- * function pointers to AWT lock functions.
- *
- */
-
-static void awt_lock_wrapper(JNIEnv *env) {
- AWT_LOCK();
-}
-
-static void awt_unlock_wrapper(JNIEnv *env) {
- AWT_UNLOCK();
-}
-
-static void awt_noflush_unlock_wrapper(JNIEnv *env) {
- AWT_NOFLUSH_UNLOCK();
-}
-
-void getAwtLockFunctions(void (**AwtLock)(JNIEnv *),
- void (**AwtUnlock)(JNIEnv *),
- void (**AwtNoFlushUnlock)(JNIEnv *),
- void *pReserved)
-{
-#ifdef DEBUG
- if (pReserved != NULL) {
- jio_fprintf(stderr,
- "getAwtLockFunctions: warning: reserved pointer is not null\n");
- }
-#endif
-
- if (AwtLock != NULL) {
- *AwtLock = awt_lock_wrapper;
- }
-
- if (AwtUnlock != NULL) {
- *AwtUnlock = awt_unlock_wrapper;
- }
-
- if (AwtNoFlushUnlock != NULL) {
- *AwtNoFlushUnlock = awt_noflush_unlock_wrapper;
- }
-}
--- a/jdk/src/solaris/native/sun/awt/awt_Plugin.h Thu May 22 20:24:42 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 1999, 2001, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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.
- */
-
-/*
- * Fix 4221246: Export functions for Netscape to use to get AWT info
- */
-
-#ifndef _AWT_PLUGIN_H_
-#define _AWT_PLUGIN_H_
-
-#include <jni.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-
-void getAwtLockFunctions(void (**AwtLock)(JNIEnv *),
- void (**AwtUnlock)(JNIEnv *),
- void (**AwtNoFlushUnlock)(JNIEnv *),
- void *);
-
-void getExtAwtData(Display *,
- int32_t,
- int32_t *, /* awt_depth */
- Colormap *, /* awt_cmap */
- Visual **, /* awt_visInfo.visual */
- int32_t *, /* awt_num_colors */
- void *);
-
-void getAwtData(int32_t *, Colormap *, Visual **, int32_t *, void *);
-
-Display *getAwtDisplay(void);
-
-#endif /* _AWT_PLUGIN_H_ */
--- a/jdk/src/solaris/native/sun/awt/color.h Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/native/sun/awt/color.h Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -28,13 +28,13 @@
#include "awt.h"
#include "colordata.h"
-#ifndef HEADLESS
+#if !defined(HEADLESS) && !defined(MACOSX)
typedef struct {
unsigned int Depth;
XPixmapFormatValues wsImageFormat;
ImgColorData clrdata;
ImgConvertFcn *convert[NUM_IMGCV];
} awtImageData;
-#endif /* !HEADLESS */
+#endif /* !HEADLESS && !MACOSX */
#endif /* _COLOR_H_ */
--- a/jdk/src/solaris/native/sun/awt/img_util_md.h Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/native/sun/awt/img_util_md.h Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -25,7 +25,7 @@
#include "color.h"
-#ifndef HEADLESS
+#if !defined(HEADLESS) && !defined(MACOSX)
typedef struct {
ImgConvertData cvdata; /* The data needed by ImgConvertFcn's */
struct Hsun_awt_image_ImageRepresentation *hJavaObject; /* backptr */
@@ -68,7 +68,7 @@
#define MaskScan(cvdata) \
((((IRData *)cvdata)->maskim->bytes_per_line) >> 2)
-#endif /* !HEADLESS */
+#endif /* !HEADLESS && !MACOSX */
#define MaskOffset(x) ((x) >> 5)
--- a/jdk/src/solaris/native/sun/awt/utility/rect.h Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/solaris/native/sun/awt/utility/rect.h Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -28,8 +28,18 @@
#ifndef _AWT_RECT_H
#define _AWT_RECT_H
+#ifndef MACOSX
#include <X11/Xlib.h>
typedef XRectangle RECT_T;
+#else
+// OSX still needs this for BitmapToYXBandedRectangles
+typedef struct {
+ int x;
+ int y;
+ int width;
+ int height;
+} RECT_T;
+#endif /* !MACOSX */
#define RECT_EQ_X(r1,r2) ((r1).x==(r2).x && (r1).width==(r2).width)
--- a/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java Fri May 23 23:55:14 2014 +0000
@@ -39,7 +39,7 @@
import static sun.awt.shell.Win32ShellFolder2.*;
import sun.awt.OSInfo;
-import sun.misc.ThreadGroupUtils;
+import sun.awt.util.ThreadGroupUtils;
// NOTE: This class supersedes Win32ShellFolderManager, which was removed
// from distribution after version 1.4.2.
--- a/jdk/src/windows/classes/sun/awt/windows/WDataTransferer.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/windows/classes/sun/awt/windows/WDataTransferer.java Fri May 23 23:55:14 2014 +0000
@@ -59,6 +59,7 @@
import java.net.URL;
+import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
@@ -268,9 +269,9 @@
if (format == CFSTR_INETURL &&
URL.class.equals(flavor.getRepresentationClass()))
{
- String charset = getDefaultTextCharset();
- if (localeTransferable != null && localeTransferable.
- isDataFlavorSupported(javaTextEncodingFlavor))
+ String charset = Charset.defaultCharset().name();
+ if (localeTransferable != null
+ && localeTransferable.isDataFlavorSupported(javaTextEncodingFlavor))
{
try {
charset = new String((byte[])localeTransferable.
--- a/jdk/src/windows/classes/sun/awt/windows/WToolkit.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/windows/classes/sun/awt/windows/WToolkit.java Fri May 23 23:55:14 2014 +0000
@@ -40,7 +40,7 @@
import sun.awt.AWTPermissions;
import sun.awt.LightweightFrame;
import sun.awt.SunToolkit;
-import sun.misc.ThreadGroupUtils;
+import sun.awt.util.ThreadGroupUtils;
import sun.awt.Win32GraphicsDevice;
import sun.awt.Win32GraphicsEnvironment;
import sun.awt.datatransfer.DataTransferer;
--- a/jdk/src/windows/classes/sun/java2d/d3d/D3DScreenUpdateManager.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DScreenUpdateManager.java Fri May 23 23:55:14 2014 +0000
@@ -38,7 +38,7 @@
import java.util.HashMap;
import sun.awt.AWTAccessor;
-import sun.misc.ThreadGroupUtils;
+import sun.awt.util.ThreadGroupUtils;
import sun.awt.Win32GraphicsConfig;
import sun.awt.windows.WComponentPeer;
import sun.java2d.InvalidPipeException;
--- a/jdk/test/com/sun/jndi/ldap/LdapTimeoutTest.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/test/com/sun/jndi/ldap/LdapTimeoutTest.java Fri May 23 23:55:14 2014 +0000
@@ -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
@@ -64,11 +64,12 @@
env.put(Context.SECURITY_PRINCIPAL, "user");
env.put(Context.SECURITY_CREDENTIALS, "password");
- env.put("com.sun.jndi.ldap.connect.timeout", "10");
- env.put("com.sun.jndi.ldap.read.timeout", "3000");
-
InitialContext ctx = null;
try {
+ new LdapTimeoutTest().deadServerNoTimeout(env);
+
+ env.put("com.sun.jndi.ldap.connect.timeout", "10");
+ env.put("com.sun.jndi.ldap.read.timeout", "3000");
new LdapTimeoutTest().ldapReadTimeoutTest(env, false);
new LdapTimeoutTest().ldapReadTimeoutTest(env, true);
new LdapTimeoutTest().simpleAuthConnectTest(env);
@@ -84,7 +85,7 @@
void ldapReadTimeoutTest(Hashtable env, boolean ssl) {
InitialContext ctx = null;
if (ssl) env.put(Context.SECURITY_PROTOCOL, "ssl");
- ScheduledFuture killer = killSwitch();
+ ScheduledFuture killer = killSwitch(5000);
long start = System.nanoTime();
try {
ctx = new InitialDirContext(env);
@@ -112,7 +113,7 @@
void simpleAuthConnectTest(Hashtable env) {
InitialContext ctx = null;
- ScheduledFuture killer = killSwitch();
+ ScheduledFuture killer = killSwitch(5000);
long start = System.nanoTime();
try {
ctx = new InitialDirContext(env);
@@ -139,6 +140,32 @@
}
}
+ void deadServerNoTimeout(Hashtable env) {
+ InitialContext ctx = null;
+ ScheduledFuture killer = killSwitch(30000);
+ long start = System.nanoTime();
+ try {
+ ctx = new InitialDirContext(env);
+ SearchControls scl = new SearchControls();
+ scl.setSearchScope(SearchControls.SUBTREE_SCOPE);
+ NamingEnumeration<SearchResult> answer = ((InitialDirContext)ctx)
+ .search("ou=People,o=JNDITutorial", "(objectClass=*)", scl);
+ // shouldn't reach here
+ fail();
+ } catch (NamingException e) {
+ long end = System.nanoTime();
+ if (TimeUnit.NANOSECONDS.toMillis(end - start) < 14000) {
+ System.err.println("fail: timeout should be at least 15 seconds, actual time: "
+ + TimeUnit.NANOSECONDS.toMillis(end - start));
+ fail();
+ } else {
+ pass();
+ }
+ } finally {
+ if (!shutItDown(killer, ctx)) fail();
+ }
+ }
+
boolean shutItDown(ScheduledFuture killer, InitialContext ctx) {
killer.cancel(true);
try {
@@ -149,15 +176,15 @@
}
}
- ScheduledFuture killSwitch() {
+ ScheduledFuture killSwitch(int ms) {
final Thread current = Thread.currentThread();
return LdapTimeoutTest.pool.schedule(new Callable<Void>() {
public Void call() throws Exception {
System.err.println("Fail: killSwitch()");
- current.interrupt();
+ System.exit(0);
return null;
}
- }, 5000, TimeUnit.MILLISECONDS);
+ }, ms, TimeUnit.MILLISECONDS);
}
static class Server extends Thread {
--- a/jdk/test/demo/jvmti/mtrace/JFrameCreateTime.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/test/demo/jvmti/mtrace/JFrameCreateTime.java Fri May 23 23:55:14 2014 +0000
@@ -32,24 +32,28 @@
* was very slow (VisualMust debugger people reported this).
*/
+import java.awt.GraphicsEnvironment;
import javax.swing.*;
public class JFrameCreateTime {
public static void main(String[] args) {
JFrame f;
long start, end;
-
- start = System.currentTimeMillis();
- f = new JFrame("JFrame");
- end = System.currentTimeMillis();
-
- System.out.println("JFrame first creation took " + (end - start) + " ms");
+ if (GraphicsEnvironment.isHeadless()) {
+ System.out.println("JFrameCreateTime test was skipped due to headless mode");
+ } else {
+ start = System.currentTimeMillis();
+ f = new JFrame("JFrame");
+ end = System.currentTimeMillis();
- start = System.currentTimeMillis();
- f = new JFrame("JFrame");
- end = System.currentTimeMillis();
+ System.out.println("JFrame first creation took " + (end - start) + " ms");
- System.out.println("JFrame second creation took " + (end - start) + " ms");
- System.exit(0);
+ start = System.currentTimeMillis();
+ f = new JFrame("JFrame");
+ end = System.currentTimeMillis();
+
+ System.out.println("JFrame second creation took " + (end - start) + " ms");
+ System.exit(0);
+ }
}
}
--- a/jdk/test/demo/jvmti/mtrace/TraceJFrame.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/test/demo/jvmti/mtrace/TraceJFrame.java Fri May 23 23:55:14 2014 +0000
@@ -37,7 +37,7 @@
public class TraceJFrame {
public static void main(String args[]) throws Exception {
if (GraphicsEnvironment.isHeadless()) {
- System.out.println("JFrame test was skipped due to headless mode");
+ System.out.println("TraceJFrame test was skipped due to headless mode");
} else {
DemoRun demo;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Choice/RemoveAllShrinkTest/RemoveAllShrinkTest.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+
+/*
+ @test
+ @bug 4851798 8041896
+ @summary Tests Choice List shrinks after removeAll
+ @run main RemoveAllShrinkTest
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+
+
+public class RemoveAllShrinkTest {
+
+ public static void main(String[] args) {
+ Frame f = new Frame();
+ Choice choice = new Choice();
+
+ for (int i = 0; i < 10; ++i) {
+ choice.addItem("Item " + i);
+ }
+
+ f.add(choice, BorderLayout.NORTH);
+ Panel panel = new Panel();
+ panel.setBackground(Color.RED);
+ f.add(panel);
+
+ f.setSize(200, 200);
+ f.setVisible(true);
+ f.toFront();
+
+ choice.removeAll();
+
+ try {
+ Robot robot = new Robot();
+ robot.setAutoWaitForIdle(true);
+ robot.setAutoDelay(50);
+
+ robot.waitForIdle();
+ Thread.sleep(200);
+
+ Point pt = choice.getLocationOnScreen();
+ robot.mouseMove(pt.x + choice.getWidth() - choice.getHeight() / 2,
+ pt.y + choice.getHeight() / 2);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ Thread.sleep(400);
+
+ Point pt1 = panel.getLocationOnScreen();
+
+ Color color = robot.getPixelColor(pt1.x + panel.getWidth() / 2,
+ pt1.y + panel.getHeight() / 2);
+
+ if (!color.equals(Color.RED)) {
+ throw new RuntimeException("RemoveAllShrinkTest failed. " + color);
+ }
+ } catch (Exception e) {
+ throw new RuntimeException("The test was not completed.\n\n" + e);
+ }
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Frame/SetMaximizedBounds/SetMaximizedBounds.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2007, 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.*;
+
+/*
+ * @test
+ * @summary When Frame.setExtendedState(Frame.MAXIMIZED_BOTH)
+ * is called for a Frame after been called setMaximizedBounds() with
+ * certain value, Frame bounds must equal to this value.
+ *
+ * @library ../../../../lib/testlibrary
+ * @build ExtendedRobot
+ * @run main SetMaximizedBounds
+ */
+
+public class SetMaximizedBounds {
+
+ Frame frame;
+ Rectangle bound;
+ boolean supported;
+ ExtendedRobot robot;
+ static Rectangle max = new Rectangle(100,100,400,400);
+
+ public void doTest() throws Exception {
+ robot = new ExtendedRobot();
+
+ EventQueue.invokeAndWait( () -> {
+ frame = new Frame( "TestFrame ");
+ frame.setLayout(new FlowLayout());
+
+ if (Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)) {
+ supported = true;
+ frame.setMaximizedBounds(max);
+ } else {
+ supported = false;
+ }
+
+ frame.setSize(200, 200);
+ frame.setVisible(true);
+ });
+
+ robot.waitForIdle(2000);
+ if (supported) {
+ EventQueue.invokeAndWait( () -> {
+ frame.setExtendedState(Frame.MAXIMIZED_BOTH);
+ });
+ robot.waitForIdle(2000);
+ bound = frame.getBounds();
+ if(!bound.equals(max))
+ throw new RuntimeException("The bounds of the Frame do not equal to what"
+ + " is specified when the frame is in Frame.MAXIMIZED_BOTH state");
+ } else {
+ System.out.println("Frame.MAXIMIZED_BOTH not supported");
+ }
+
+ frame.dispose();
+ }
+
+ public static void main(String[] args) throws Exception {
+ String os = System.getProperty("os.name").toLowerCase();
+ System.out.println(os);
+ if (os.contains("windows") || os.contains("os x"))
+ new SetMaximizedBounds().doTest();
+ else
+ System.out.println("Platform "+os+" is not supported. Supported platforms are Windows and OS X.");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/FullScreen/DisplayChangeVITest/DisplayChangeVITest.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,245 @@
+/*
+ * 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
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 6366359
+ * @summary Test that we don't crash when changing from 8 to 16/32 bit modes
+ * @author Dmitri.Trembovetski@Sun.COM area=FullScreen
+ * @run main/othervm/timeout=200 DisplayChangeVITest
+ * @run main/othervm/timeout=200 -Dsun.java2d.d3d=false DisplayChangeVITest
+ * @run main/othervm/timeout=200 -Dsun.java2d.opengl=true DisplayChangeVITest
+ */
+
+import java.awt.Color;
+import java.awt.DisplayMode;
+import java.awt.Graphics;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.image.BufferedImage;
+import java.awt.image.VolatileImage;
+import java.lang.Exception;
+import java.lang.Thread;
+import java.util.ArrayList;
+import java.util.Random;
+import javax.swing.JFrame;
+
+/**
+ * The test enters fullscreen mode (if it's supported) and then tries
+ * to switch between display moes with different depths and dimensions
+ * while doing both rendering to the screen (via a VolatileImage)
+ * and Swing repainting just to make things more chaotic.
+ *
+ * The procedure is repeated TEST_REPS times (3 by default).
+ *
+ * Don't pay attention to what happens on the screen, it won't be pretty.
+ * If the test doesn't crash or throw exceptions, it passes, otherwise
+ * it fails.
+ */
+public class DisplayChangeVITest extends JFrame implements Runnable {
+
+ private final Random rnd = new Random();
+ private VolatileImage bb;
+ private BufferedImage sprite;
+ private VolatileImage volSprite;
+
+ private static boolean done = false;
+ private static final Object lock = new Object();
+ private static final int TEST_REPS = 3;
+
+ private ArrayList<DisplayMode> dms;
+
+ DisplayChangeVITest() {
+ selectDisplayModes();
+ addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
+ synchronized (lock) {
+ done = true;
+ }
+ }
+ }
+ });
+ sprite = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);
+ sprite.getRaster().getDataBuffer();
+ Graphics g = sprite.getGraphics();
+ g.setColor(Color.yellow);
+ g.fillRect(0, 0, sprite.getWidth(), sprite.getHeight());
+ }
+
+ void render(Graphics g) {
+ do {
+ // volatile images validated here
+ initBackbuffer();
+
+ g.setColor(Color.black);
+ g.fillRect(0, 0, getWidth(), getHeight());
+
+ Graphics gg = bb.getGraphics();
+ gg.setColor(new Color(rnd.nextInt(0x00ffffff)));
+ gg.fillRect(0, 0, bb.getWidth(), bb.getHeight());
+ for (int x = 0; x < 10; x++) {
+ gg.drawImage(sprite, x*200, 0, null);
+ gg.drawImage(volSprite, x*200, 500, null);
+ }
+
+ g.drawImage(bb, 0, 0, null);
+ } while (bb.contentsLost());
+ }
+
+ private static void sleep(long msec) {
+ try { Thread.sleep(msec); } catch (InterruptedException e) {}
+ }
+
+ private int reps = 0;
+ public void run() {
+ GraphicsDevice gd = getGraphicsConfiguration().getDevice();
+ if (gd.isDisplayChangeSupported() && dms.size() > 0) {
+ while (!done && reps++ < TEST_REPS) {
+ for (DisplayMode dm : dms) {
+ System.err.printf("Entering DisplayMode[%dx%dx%d]\n",
+ dm.getWidth(), dm.getHeight(), dm.getBitDepth());
+ gd.setDisplayMode(dm);
+
+ initBackbuffer();
+ for (int i = 0; i < 10; i++) {
+ // render to the screen
+ render(getGraphics());
+ // ask Swing to repaint
+ repaint();
+ sleep(100);
+ }
+ sleep(1500);
+ }
+ }
+ } else {
+ System.err.println("Display mode change " +
+ "not supported. Test passed.");
+ }
+ dispose();
+ synchronized (lock) {
+ done = true;
+ lock.notify();
+ }
+ }
+
+ private void createBackbuffer() {
+ if (bb == null ||
+ bb.getWidth() != getWidth() || bb.getHeight() != getHeight())
+ {
+ bb = createVolatileImage(getWidth(), getHeight());
+ }
+ }
+
+ private void initBackbuffer() {
+ createBackbuffer();
+
+ int res = bb.validate(getGraphicsConfiguration());
+ if (res == VolatileImage.IMAGE_INCOMPATIBLE) {
+ bb = null;
+ createBackbuffer();
+ bb.validate(getGraphicsConfiguration());
+ res = VolatileImage.IMAGE_RESTORED;
+ }
+ if (res == VolatileImage.IMAGE_RESTORED) {
+ Graphics g = bb.getGraphics();
+ g.setColor(new Color(rnd.nextInt(0x00ffffff)));
+ g.fillRect(0, 0, bb.getWidth(), bb.getHeight());
+
+ volSprite = createVolatileImage(100, 100);
+ }
+ volSprite.validate(getGraphicsConfiguration());
+ }
+
+ private void selectDisplayModes() {
+ GraphicsDevice gd =
+ GraphicsEnvironment.getLocalGraphicsEnvironment().
+ getDefaultScreenDevice();
+ dms = new ArrayList<DisplayMode>();
+ DisplayMode dmArray[] = gd.getDisplayModes();
+ boolean found8 = false, found16 = false,
+ found24 = false, found32 = false;
+ for (DisplayMode dm : dmArray) {
+ if (!found8 &&
+ (dm.getBitDepth() == 8 ||
+ dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI) &&
+ (dm.getWidth() >= 800 && dm.getWidth() < 1024))
+ {
+ dms.add(dm);
+ found8 = true;
+ continue;
+ }
+ if (!found32 &&
+ (dm.getBitDepth() == 32 ||
+ dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI) &&
+ dm.getWidth() >= 1280)
+ {
+ dms.add(dm);
+ found32 = true;
+ continue;
+ }
+ if (!found16 &&
+ dm.getBitDepth() == 16 &&
+ (dm.getWidth() >= 1024 && dm.getWidth() < 1280))
+ {
+ dms.add(dm);
+ found16 = true;
+ continue;
+ }
+ if (found8 && found16 && found32) {
+ break;
+ }
+ }
+ System.err.println("Found display modes:");
+ for (DisplayMode dm : dms) {
+ System.err.printf("DisplayMode[%dx%dx%d]\n",
+ dm.getWidth(), dm.getHeight(), dm.getBitDepth());
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ DisplayChangeVITest test = new DisplayChangeVITest();
+ GraphicsDevice gd =
+ GraphicsEnvironment.getLocalGraphicsEnvironment().
+ getDefaultScreenDevice();
+ if (gd.isFullScreenSupported()) {
+ gd.setFullScreenWindow(test);
+ Thread t = new Thread(test);
+ t.run();
+ synchronized (lock) {
+ while (!done) {
+ try {
+ lock.wait(50);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+ System.err.println("Test Passed.");
+ } else {
+ System.err.println("Full screen not supported. Test passed.");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/GridLayout/ChangeGridSize/ChangeGridSize.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,189 @@
+/*
+ * 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
+ * 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.*;
+import java.awt.event.*;
+
+/*
+ * @test
+ * @summary Have different components having different preferred sizes
+ * added to a grid layout. Change the rows and columns of the
+ * grid layout and check the components are re-laid out.
+ * The strategy followed is to calculate the component location
+ * depending on the preferred sizes and gaps and click the cornors
+ * of the components to check if events are triggered
+ * @library ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @run main ChangeGridSize
+ * @run main ChangeGridSize -hg 20 -vg 20
+ */
+
+public class ChangeGridSize {
+
+ private int width = 200;
+ private int height = 200;
+ private final int hGap, vGap;
+ private final int rows = 3;
+ private final int columns = 2;
+ private final int componentCount = 6;
+
+ private Button[] buttons;
+ private Frame frame;
+
+ private ExtendedRobot robot;
+ private GridLayout layout;
+
+ private volatile boolean actionPerformed = false;
+
+ public ChangeGridSize(int hGap, int vGap) throws Exception {
+ this.hGap = hGap;
+ this.vGap = vGap;
+ robot = new ExtendedRobot();
+ EventQueue.invokeAndWait( () -> {
+ frame = new Frame("Test frame");
+ frame.setSize(width, height);
+ layout = new GridLayout(rows + 3, columns - 1, hGap, vGap);
+ frame.setLayout(layout);
+
+ buttons = new Button[componentCount];
+ for (int i = 0; i < componentCount; i++) {
+ buttons[i] = new Button("Button" + i);
+ frame.add(buttons[i]);
+ buttons[i].addActionListener( (event) -> { actionPerformed = true; });
+ }
+ frame.setVisible(true);
+ });
+ }
+
+ public static void main(String[] args) throws Exception {
+ int hGap = 0;
+ int vGap = 0;
+ for (int i = 0; i < args.length; i++) {
+ switch (args[i]) {
+ case "-hg":
+ hGap = Integer.parseInt(args[++i]);
+ break;
+ case "-vg":
+ vGap = Integer.parseInt(args[++i]);
+ break;
+ }
+ }
+ new ChangeGridSize(hGap, vGap).doTest();
+ }
+
+ private void resizeFrame() throws Exception {
+ EventQueue.invokeAndWait(() -> {
+ Insets insets = frame.getInsets();
+ double dH = (height-insets.top-insets.bottom - vGap*(rows-1)) % rows;
+ double dW = (width-insets.left-insets.right - hGap*(columns-1)) % columns;
+ height -= dH;
+ width -= dW;
+ frame.setSize(width, height);
+ frame.revalidate();
+ });
+ robot.waitForIdle();
+ }
+
+ private void changeGridSize() throws Exception {
+ EventQueue.invokeAndWait(() -> {
+ layout.setRows(rows);
+ layout.setColumns(columns);
+
+ frame.revalidate();
+ });
+ robot.waitForIdle();
+ }
+
+ public void testBoundaries(int topLeftX, int topLeftY, int bottomRightX, int bottomRightY) throws Exception {
+
+ actionPerformed = false;
+ robot.mouseMove(topLeftX, topLeftY);
+ robot.delay(500);
+ robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+ robot.delay(500);
+ robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+ robot.waitForIdle(3000);
+
+ if(!actionPerformed)
+ throw new RuntimeException("Clicking on the left top of button did not trigger action event");
+
+ actionPerformed = false;
+ robot.mouseMove(bottomRightX, bottomRightY);
+ robot.delay(500);
+ robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+ robot.delay(500);
+ robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+ robot.waitForIdle(3000);
+
+ if(!actionPerformed)
+ throw new RuntimeException("Clicking on the bottom right of button did not trigger action event");
+ }
+
+ private void doTest() throws Exception {
+ robot.waitForIdle();
+ changeGridSize();
+ resizeFrame();
+
+ int availableWidth = width - frame.getInsets().left -
+ frame.getInsets().right;
+ int componentWidth = (availableWidth + hGap) / columns - hGap;
+ int availableHeight = height - frame.getInsets().top -
+ frame.getInsets().bottom;
+ int componentHeight = (availableHeight + vGap) / rows - vGap;
+
+ for (int i = 0; i < buttons.length; i++) {
+ if (buttons[i].getSize().width != componentWidth ||
+ buttons[i].getSize().height != componentHeight) {
+ throw new RuntimeException(
+ "FAIL: Button " + i + " not of proper size" +
+ "Expected: " + componentWidth + "*" + componentHeight +
+ "Actual: " + buttons[i].getSize().width + "*" + buttons[i].getSize().height);
+ }
+ }
+
+ // Components are visible. They should trigger events.
+ // Now you can check for the actual size shown.
+ int currentRow = 1;
+ int currentColumn = 0;
+ for (int i = 0; i < buttons.length; i++) {
+ currentColumn++;
+ if (currentColumn > columns) {
+ currentColumn = 1;
+ currentRow++;
+ }
+
+ int topPosX = frame.getLocationOnScreen().x +
+ frame.getInsets().left +
+ (currentColumn - 1) * (componentWidth + hGap);
+ int topPosY = frame.getLocationOnScreen().y +
+ frame.getInsets().top +
+ (currentRow - 1) * (componentHeight + vGap);
+
+ int bottomPosX = topPosX + componentWidth - 1;
+ int bottomPosY = topPosY + componentHeight - 1;
+ testBoundaries(topPosX, topPosY, bottomPosX, bottomPosY);
+ }
+
+ frame.dispose();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/GridLayout/ComponentPreferredSize/ComponentPreferredSize.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,181 @@
+/*
+ * 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
+ * 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.*;
+import java.awt.event.InputEvent;
+
+/*
+ * @test
+ * @summary Have different components having different preferred sizes
+ * added to a grid layout having various values of row/columns.
+ * Check if the compnents are correctly laid out.
+ * The strategy followed is to calculate the component location
+ * depending on the preferred sizes and gaps and click the cornors
+ * of the components to check if events are triggered
+ * @library ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @run main ComponentPreferredSize
+ * @run main ComponentPreferredSize -hg 20 -vg 20
+ */
+
+public class ComponentPreferredSize {
+
+ private int width = 200;
+ private int height = 200;
+ private final int hGap, vGap;
+ private final int rows = 3;
+ private final int columns = 2;
+ private final int componentCount = 6;
+
+ private Button[] buttons;
+ private Frame frame;
+
+ private ExtendedRobot robot;
+ private GridLayout layout;
+
+ private volatile boolean actionPerformed = false;
+
+ public ComponentPreferredSize(int hGap, int vGap) throws Exception {
+ this.hGap = hGap;
+ this.vGap = vGap;
+ robot = new ExtendedRobot();
+ EventQueue.invokeAndWait( () -> {
+ frame = new Frame("Test frame");
+ frame.setSize(width, height);
+ layout = new GridLayout(rows, columns, hGap, vGap);
+ frame.setLayout(layout);
+
+ buttons = new Button[componentCount];
+ for (int i = 0; i < componentCount; i++) {
+ buttons[i] = new Button("Button" + i);
+ buttons[i].setPreferredSize(new Dimension((int) Math.random() * 100,
+ (int) Math.random() * 100));
+ frame.add(buttons[i]);
+ buttons[i].addActionListener((event) -> {actionPerformed = true;});
+ }
+
+ frame.setVisible(true);
+ });
+ }
+
+ public static void main(String[] args) throws Exception {
+ int hGap = 0;
+ int vGap = 0;
+ for (int i = 0; i < args.length; i++) {
+ switch (args[i]) {
+ case "-hg":
+ hGap = Integer.parseInt(args[++i]);
+ break;
+ case "-vg":
+ vGap = Integer.parseInt(args[++i]);
+ break;
+ }
+ }
+ new ComponentPreferredSize(hGap, vGap).doTest();
+ }
+
+ private void resizeFrame() throws Exception {
+ EventQueue.invokeAndWait(() -> {
+ Insets insets = frame.getInsets();
+ double dH = (height-insets.top-insets.bottom - vGap*(rows-1)) % rows;
+ double dW = (width-insets.left-insets.right - hGap*(columns-1)) % columns;
+ height -= dH;
+ width -= dW;
+ frame.setSize(width, height);
+ frame.revalidate();
+ });
+ robot.waitForIdle();
+ }
+
+ public void testBoundaries(int topLeftX, int topLeftY, int bottomRightX, int bottomRightY) throws Exception {
+
+ actionPerformed = false;
+ robot.mouseMove(topLeftX, topLeftY);
+ robot.delay(500);
+ robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+ robot.delay(500);
+ robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+ robot.waitForIdle(3000);
+
+ if(!actionPerformed)
+ throw new RuntimeException("Clicking on the left top of button did not trigger action event");
+
+ actionPerformed = false;
+ robot.mouseMove(bottomRightX, bottomRightY);
+ robot.delay(500);
+ robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+ robot.delay(500);
+ robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+ robot.waitForIdle(3000);
+
+ if(!actionPerformed)
+ throw new RuntimeException("Clicking on the bottom right of button did not trigger action event");
+ }
+
+ private void doTest() throws Exception {
+ robot.waitForIdle();
+ resizeFrame();
+
+ int availableWidth = width - frame.getInsets().left -
+ frame.getInsets().right;
+ int componentWidth = (availableWidth + hGap) / columns - hGap;
+ int availableHeight = height - frame.getInsets().top -
+ frame.getInsets().bottom;
+ int componentHeight = (availableHeight + vGap) / rows - vGap;
+
+ for (int i = 0; i < buttons.length; i++) {
+ if (buttons[i].getSize().width != componentWidth ||
+ buttons[i].getSize().height != componentHeight) {
+ throw new RuntimeException(
+ "FAIL: Button " + i + " not of proper size" +
+ "Expected: " + componentWidth + "*" + componentHeight +
+ "Actual: " + buttons[i].getSize().width + "*" + buttons[i].getSize().height);
+ }
+ }
+
+ // Components are visible. They should trigger events.
+ // Now you can check for the actual size shown.
+ int currentRow = 1;
+ int currentColumn = 0;
+ for (int i = 0; i < buttons.length; i++) {
+ currentColumn++;
+ if (currentColumn > columns) {
+ currentColumn = 1;
+ currentRow++;
+ }
+
+ int topPosX = frame.getLocationOnScreen().x +
+ frame.getInsets().left +
+ (currentColumn - 1) * (componentWidth + hGap);
+ int topPosY = frame.getLocationOnScreen().y +
+ frame.getInsets().top +
+ (currentRow - 1) * (componentHeight + vGap);
+
+ int bottomPosX = topPosX + componentWidth - 1;
+ int bottomPosY = topPosY + componentHeight - 1;
+ testBoundaries(topPosX, topPosY, bottomPosX, bottomPosY);
+ }
+
+ frame.dispose();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/FrameBorderCounter.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,95 @@
+/*
+ * 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.Dimension;
+import java.awt.EventQueue;
+import java.awt.Frame;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowAdapter;
+
+public class FrameBorderCounter {
+
+ private static Frame frame;
+ private static Frame background;
+ private static Dimension size;
+ private static Point location;
+ private static Point entered;
+
+ public static void main(String[] args) throws Exception {
+ final Robot robot = new Robot();
+ EventQueue.invokeAndWait(new Runnable() {
+ public void run() {
+ robot.mouseMove(0, 0);
+ }
+ });
+ EventQueue.invokeAndWait(new Runnable() {
+ public void run() {
+ background = new Frame();
+ background.setBounds(100, 100, 300, 300);
+ background.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ entered = e.getLocationOnScreen();
+ System.err.println("[ENTERED] : " + entered);
+ }
+ });
+ background.setVisible(true);
+ }
+ });
+ EventQueue.invokeAndWait(new Runnable() {
+ public void run() {
+ frame = new Frame("Frame");
+ frame.setBounds(200, 200, 100, 100);
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ System.exit(0);
+ }
+ });
+ frame.setVisible(true);
+ }
+ });
+ Thread.sleep(1000);
+ EventQueue.invokeAndWait(new Runnable() {
+ public void run() {
+ location = frame.getLocationOnScreen();
+ size = frame.getSize();
+ }
+ });
+ int out = 20;
+ for (int x = location.x + size.width - out; x <= location.x + size.width + out; ++x) {
+ robot.mouseMove(x, location.y + size.height / 2);
+ Thread.sleep(50);
+ }
+ System.err.println("[LOCATION] : " + location);
+ System.err.println("[SIZE] : " + size);
+ Thread.sleep(250);
+ int shift = entered.x - location.x - size.width - 1;
+ System.err.println("Done");
+ System.out.println(shift);
+ frame.dispose();
+ background.dispose();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/GlassPaneOverlappingTestBase.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,144 @@
+/*
+ * 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.Container;
+import java.awt.Point;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.InputEvent;
+import java.lang.reflect.InvocationTargetException;
+import javax.swing.JFrame;
+import javax.swing.SpringLayout;
+import javax.swing.SwingUtilities;
+
+/**
+ * Base class for testing overlapping of Swing and AWT component put into GlassPane.
+ * Validates drawing and event delivery at the components intersection.
+ * <p> See {@link OverlappingTestBase} for usage
+ *
+ * @author Sergey Grinev
+ */
+public abstract class GlassPaneOverlappingTestBase extends SimpleOverlappingTestBase {
+
+ /**
+ * If true components is additionally tested to be correctly drawn after resize.
+ */
+ protected boolean testResize = true;
+ private JFrame f = null;
+ private volatile Point ancestorLoc;
+
+ /**
+ * Setups GlassPane with lightweight component returned by {@link SimpleOverlappingTestBase#getSwingComponent() }
+ * Called by base class.
+ */
+ @Override
+ protected void prepareControls() {
+ wasLWClicked = false;
+
+ if(f != null) {
+ f.setVisible(false);
+ }
+ f = new JFrame("Mixing : GlassPane Overlapping test");
+ f.setLayout(new SpringLayout());
+ f.setSize(200, 200);
+
+ propagateAWTControls(f);
+
+ f.getGlassPane().setVisible(true);
+ Container glassPane = (Container) f.getGlassPane();
+ glassPane.setLayout(null);
+
+ testedComponent = getSwingComponent();
+ if (useDefaultClickValidation) {
+ testedComponent.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ //System.err.println("lw mouse clicked");
+ wasLWClicked = true;
+ }
+ });
+ }
+ testedComponent.setBounds(0, 0, testedComponent.getPreferredSize().width, testedComponent.getPreferredSize().height);
+ glassPane.add(testedComponent);
+
+ f.setVisible(true);
+ }
+
+ public GlassPaneOverlappingTestBase() {
+ super();
+ }
+
+ public GlassPaneOverlappingTestBase(boolean defaultClickValidation) {
+ super(defaultClickValidation);
+ }
+
+ /**
+ * Run test by {@link OverlappingTestBase#clickAndBlink(java.awt.Robot, java.awt.Point) } validation for current lightweight component.
+ * <p>Also resize component and repeat validation in the resized area.
+ * <p>Called by base class.
+ * @return true if test passed
+ * @see GlassPaneOverlappingTestBase#testResize
+ */
+ @Override
+ protected boolean performTest() {
+ if (!super.performTest()) {
+ return false;
+ }
+ if (testResize) {
+ wasLWClicked = false;
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ public void run() {
+ testedComponent.setBounds(0, 0, testedComponent.getPreferredSize().width, testedComponent.getPreferredSize().height + 20);
+ ancestorLoc = f.getLocationOnScreen();
+ }
+ });
+ } catch (InterruptedException ex) {
+ fail(ex.getMessage());
+ } catch (InvocationTargetException ex) {
+ fail(ex.getMessage());
+ }
+ Point lLoc = testedComponent.getLocationOnScreen();
+ lLoc.translate(1, testedComponent.getPreferredSize().height + 1);
+
+ /* this is a workaround for certain jtreg(?) focus issue:
+ tests fail starting after failing mixing tests but always pass alone.
+ */
+ Util.waitForIdle(robot);
+ ancestorLoc.translate(f.getWidth()/2-15, 2);
+ robot.mouseMove(ancestorLoc.x, ancestorLoc.y);
+ Util.waitForIdle(robot);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(50);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ Util.waitForIdle(robot);
+
+ clickAndBlink(robot, lLoc);
+ return wasLWClicked;
+ } else {
+ return true;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/HierarchyBoundsListenerMixingTest.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,692 @@
+/*
+ * 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.*;
+import java.awt.event.*;
+import java.lang.reflect.InvocationTargetException;
+import javax.swing.SwingUtilities;
+import java.io.*;
+
+/**
+ * AWT Mixing test for HierarchyBoundsListener ancestors.
+ * <p>See <a href="https://bugs.openjdk.java.net/browse/JDK-6768230">CR6768230</a> for details.
+ */
+/*
+@test
+@bug 6768230
+@summary Mixing test for HierarchyBoundsListener ancestors
+@build FrameBorderCounter
+@run main HierarchyBoundsListenerMixingTest
+ */
+public class HierarchyBoundsListenerMixingTest {
+
+ protected void prepareControls() {
+ dummy = new Frame();
+ dummy.setSize(100, 100);
+ dummy.setLocation(0, 350);
+ dummy.setVisible(true);
+
+ frame = new Frame("Test Frame");
+ frame.setLayout(new FlowLayout());
+
+ panel = new Panel();
+ button = new Button("Button");
+ label = new Label("Label");
+ list = new List();
+ list.add("One");
+ list.add("Two");
+ list.add("Three");
+ choice = new Choice();
+ choice.add("Red");
+ choice.add("Orange");
+ choice.add("Yellow");
+ checkbox = new Checkbox("Checkbox");
+ scrollbar = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, 255);
+ textfield = new TextField(15);
+ textarea = new TextArea(5, 15);
+
+ components = new Component[] {
+ panel, button, label, list, choice, checkbox, scrollbar, textfield, textarea
+ };
+ ancestorResized = new boolean[components.length];
+ ancestorMoved = new boolean[components.length];
+
+ frame.addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent event) {
+ System.err.println("User closed the window");
+ System.exit(1);
+ }
+ });
+
+ HierarchyBoundsListener listener = new HierarchyBoundsListenerImpl();
+ for (int i = 0; i < components.length; i++) {
+ components[i].addHierarchyBoundsListener(listener);
+ frame.add(components[i]);
+ }
+ frame.setSize(300, 300);
+ frame.setVisible(true);
+ }
+
+ private int frameBorderCounter() {
+ String JAVA_HOME = System.getProperty("java.home");
+
+ try {
+ Process p = Runtime.getRuntime().exec(JAVA_HOME + "/bin/java FrameBorderCounter");
+ try {
+ p.waitFor();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ if (p.exitValue() != 0) {
+ throw new RuntimeException("FrameBorderCounter exited with not null code!\n" + readInputStream(p.getErrorStream()));
+ }
+ return Integer.parseInt(readInputStream(p.getInputStream()).trim());
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ private String readInputStream(InputStream is) throws IOException {
+ byte[] buffer = new byte[4096];
+ int len = 0;
+ StringBuilder sb = new StringBuilder();
+ try (InputStreamReader isr = new InputStreamReader(is)) {
+ while ((len = is.read(buffer)) > 0) {
+ sb.append(new String(buffer, 0, len));
+ }
+ }
+ return sb.toString();
+ }
+
+ protected boolean performTest() {
+ int BORDER_SHIFT = frameBorderCounter();
+ BORDER_SHIFT = Math.abs(BORDER_SHIFT) == 1 ? BORDER_SHIFT : BORDER_SHIFT / 2;
+ Robot robot = null;
+ try {
+ robot = new Robot();
+ Thread.sleep(delay * 10);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ robot.mouseMove((int) components[0].getLocationOnScreen().x + components[0].getSize().width / 2,
+ (int) components[0].getLocationOnScreen().y + components[0].getSize().height / 2);
+ robot.delay(delay);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(delay);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.delay(delay);
+
+ resetValues();
+ try {
+ EventQueue.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setSize(new Dimension(frame.getSize().width + 10, frame.getSize().height + 10));
+ frame.invalidate();
+ frame.validate();
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ passed = false;
+ }
+ if (! resizeTriggered) {
+ synchronized (resizeLock) {
+ try {
+ resizeLock.wait(delay * 10);
+ } catch (Exception e) {
+ }
+ }
+ }
+ for (int i = 0; i < components.length; i++) {
+ if (! ancestorResized[i]) {
+ System.err.println("FAIL: Frame resized using API call. " +
+ "Ancestor resized event did not occur for " + components[i].getClass());
+ passed = false;
+ }
+ }
+ if (moveCount > 0) {
+ System.err.println("FAIL: Ancestor moved event occured when Frame resized using API");
+ passed = false;
+ }
+ robot.delay(delay * 5);
+
+ resetValues();
+ int x = (int) frame.getLocationOnScreen().x;
+ int y = (int) frame.getLocationOnScreen().y;
+ int w = frame.getSize().width;
+ int h = frame.getSize().height;
+
+ robot.mouseMove(x + w + BORDER_SHIFT, y + h / 2);
+ robot.delay(delay);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(delay);
+ for (int i = 0; i < 20; i++) {
+ robot.mouseMove(x + w + i + BORDER_SHIFT, y + h / 2);
+ robot.delay(50);
+ }
+ robot.delay(delay);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ if (! resizeTriggered) {
+ synchronized (resizeLock) {
+ try {
+ resizeLock.wait(delay * 10);
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ for (int i = 0; i < components.length; i++) {
+ if (! ancestorResized[i]) {
+ System.err.println("FAIL: Frame resized using mouse action. " +
+ "Ancestor resized event did not occur for " +
+ components[i].getClass());
+ passed = false;
+ }
+ }
+ if (moveCount > 0) {
+ System.err.println("FAIL: Ancestor moved event occured when Frame resized using mouse");
+ passed = false;
+ }
+
+ resetValues();
+ try {
+ EventQueue.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setLocation(frame.getLocation().x + 20, frame.getLocation().y + 20);
+ frame.invalidate();
+ frame.validate();
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ passed = false;
+ }
+ if (! moveTriggered) {
+ synchronized (moveLock) {
+ try {
+ moveLock.wait(delay * 10);
+ } catch (Exception e) {
+ }
+ }
+ }
+ for (int i = 0; i < components.length; i++) {
+ if (! ancestorMoved[i]) {
+ System.err.println("FAIL: Frame moved using API call. " +
+ "Ancestor moved event did not occur for " + components[i].getClass());
+ passed = false;
+ }
+ }
+ if (resizeCount > 0) {
+ System.err.println("FAIL: Ancestor resized event occured when Frame moved using API");
+ passed = false;
+ }
+ robot.delay(delay * 10);
+
+ resetValues();
+ x = (int) frame.getLocationOnScreen().x;
+ y = (int) frame.getLocationOnScreen().y;
+ w = frame.getSize().width;
+ h = frame.getSize().height;
+
+ //Click on the dummy frame so that the test frame loses focus. This is to workaround
+ //a bug in Linux AS.
+ robot.mouseMove((int) dummy.getLocationOnScreen().x + dummy.getSize().width / 2,
+ (int) dummy.getLocationOnScreen().y + dummy.getSize().height / 2);
+ robot.delay(delay);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(delay);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.delay(delay);
+
+ robot.mouseMove(x + w / 2, y + 10);
+ robot.delay(delay);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(delay);
+ for (int i = 1; i <= 20; i++) {
+ robot.mouseMove(x + w / 2 + i, y + 10);
+ robot.delay(50);
+ }
+ robot.delay(delay);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ if (! moveTriggered) {
+ synchronized (moveLock) {
+ try {
+ moveLock.wait(delay * 10);
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ for (int i = 0; i < components.length; i++) {
+ if (! ancestorMoved[i]) {
+ System.err.println("FAIL: Frame moved using mouse action. " +
+ "Ancestor moved event did not occur for " + components[i].getClass());
+ passed = false;
+ }
+ }
+ if (resizeCount > 0) {
+ System.err.println("FAIL: Ancestor resized event occured when Frame moved using mouse");
+ passed = false;
+ }
+
+ return passed;
+ }
+
+ private void resetValues() {
+ moveTriggered = false;
+ resizeTriggered = false;
+ moveCount = 0;
+ resizeCount = 0;
+ for (int i = 0; i < ancestorResized.length; i++) {
+ ancestorResized[i] = false;
+ ancestorMoved[i] = false;
+ }
+ }
+
+ private void keyType(int key, Robot robot) throws Exception {
+ robot.keyPress(key);
+ robot.delay(keyDelay);
+ robot.keyRelease(key);
+ robot.delay(keyDelay);
+ }
+
+ class HierarchyBoundsListenerImpl implements HierarchyBoundsListener {
+ // checks for Ancestor_Moved events
+ public void ancestorMoved(HierarchyEvent ce) {
+ if (check) {
+ System.out.println("Moved " + ce.getComponent());
+ }
+ for (int i = 0; i < components.length; i++) {
+ if (components[i].equals(ce.getComponent())) {
+ //setting this array for purpose of checking ancestor_moved.
+ ancestorMoved[i] = true;
+ moveCount++;
+ if (moveCount == components.length) {
+ moveTriggered = true;
+ synchronized (moveLock) {
+ try {
+ moveLock.notifyAll();
+ } catch (Exception e) {
+ }
+ }
+ }
+ }
+ }
+ }
+ // checks for Ancestor_Moved events
+ public void ancestorResized(HierarchyEvent ce) {
+ if (check) {
+ System.out.println("Resized " + ce.getComponent());
+ }
+ for (int i = 0; i < components.length; i++) {
+ if (components[i].equals(ce.getComponent())) {
+ if (! frame.equals(ce.getChanged()) || ce.getChangedParent() != null) {
+ System.err.println("FAIL: Invalid value of HierarchyEvent.getXXX");
+ System.err.println("ce.getChanged() : " + ce.getChanged());
+ System.err.println("ce.getChangedParent() : " + ce.getChangedParent());
+ passed = false;
+ }
+ //setting this array for purpose of checking ancestor_resized
+ ancestorResized[i] = true;
+ resizeCount++;
+ if (resizeCount == components.length) {
+ resizeTriggered = true;
+ synchronized (resizeLock) {
+ try {
+ resizeLock.notifyAll();
+ } catch (Exception e) {
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private Frame frame, dummy;
+ private Panel panel;
+ private Button button;
+ private Label label;
+ private List list;
+ private Choice choice;
+ private Checkbox checkbox;
+ private Scrollbar scrollbar;
+ private TextField textfield;
+ private TextArea textarea;
+ private Component[] components;
+ private boolean[] ancestorResized;
+ private boolean[] ancestorMoved;
+
+ private int delay = 500;
+ private int keyDelay = 50;
+ private int moveCount = 0;
+ private int resizeCount = 0;
+
+ private boolean passed = true;
+ private boolean moveTriggered = false;
+ private boolean resizeTriggered = false;
+ private final Object moveLock = new Object();
+ private final Object resizeLock = new Object();
+
+ private boolean check = false;
+
+ private void invoke() throws InterruptedException {
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ public void run() {
+ prepareControls();
+ }
+ });
+ try {
+ Thread.sleep(1000); // wait for graphic effects on systems like Win7
+ } catch (InterruptedException ex) {
+ }
+ if (!performTest()) {
+ fail("Test failed");
+ }
+ } catch (InvocationTargetException ex) {
+ fail(ex.getMessage());
+ }
+ }
+
+ /*****************************************************
+ * Standard Test Machinery Section
+ * DO NOT modify anything in this section -- it's a
+ * standard chunk of code which has all of the
+ * synchronisation necessary for the test harness.
+ * By keeping it the same in all tests, it is easier
+ * to read and understand someone else's test, as
+ * well as insuring that all tests behave correctly
+ * with the test harness.
+ * There is a section following this for test-
+ * classes
+ ******************************************************/
+ private static void init() throws InterruptedException {
+ //*** Create instructions for the user here ***
+ //System.setProperty("sun.awt.disableMixing", "true");
+
+ String[] instructions = {
+ "This is an AUTOMATIC test, simply wait until it is done.",
+ "The result (passed or failed) will be shown in the",
+ "message window below."
+ };
+ Sysout.createDialog();
+ Sysout.printInstructions(instructions);
+
+ HierarchyBoundsListenerMixingTest instance = new HierarchyBoundsListenerMixingTest();
+
+ instance.invoke();
+
+ pass();
+ }//End init()
+ private static boolean theTestPassed = false;
+ private static boolean testGeneratedInterrupt = false;
+ private static String failureMessage = "";
+ private static Thread mainThread = null;
+ private static int sleepTime = 300000;
+
+ // Not sure about what happens if multiple of this test are
+ // instantiated in the same VM. Being static (and using
+ // static vars), it aint gonna work. Not worrying about
+ // it for now.
+ public static void main(String args[]) throws InterruptedException {
+ mainThread = Thread.currentThread();
+ try {
+ init();
+ } catch (TestPassedException e) {
+ //The test passed, so just return from main and harness will
+ // interepret this return as a pass
+ return;
+ }
+ //At this point, neither test pass nor test fail has been
+ // called -- either would have thrown an exception and ended the
+ // test, so we know we have multiple threads.
+
+ //Test involves other threads, so sleep and wait for them to
+ // called pass() or fail()
+ try {
+ Thread.sleep(sleepTime);
+ //Timed out, so fail the test
+ throw new RuntimeException("Timed out after " + sleepTime / 1000 + " seconds");
+ } catch (InterruptedException e) {
+ //The test harness may have interrupted the test. If so, rethrow the exception
+ // so that the harness gets it and deals with it.
+ if (!testGeneratedInterrupt) {
+ throw e;
+ }
+
+ //reset flag in case hit this code more than once for some reason (just safety)
+ testGeneratedInterrupt = false;
+
+ if (theTestPassed == false) {
+ throw new RuntimeException(failureMessage);
+ }
+ }
+
+ }//main
+
+ public static synchronized void setTimeoutTo(int seconds) {
+ sleepTime = seconds * 1000;
+ }
+
+ public static synchronized void pass() {
+ Sysout.println("The test passed.");
+ Sysout.println("The test is over, hit Ctl-C to stop Java VM");
+ //first check if this is executing in main thread
+ if (mainThread == Thread.currentThread()) {
+ //Still in the main thread, so set the flag just for kicks,
+ // and throw a test passed exception which will be caught
+ // and end the test.
+ theTestPassed = true;
+ throw new TestPassedException();
+ }
+ theTestPassed = true;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
+ }//pass()
+
+ public static synchronized void fail() {
+ //test writer didn't specify why test failed, so give generic
+ fail("it just plain failed! :-)");
+ }
+
+ public static synchronized void fail(String whyFailed) {
+ Sysout.println("The test failed: " + whyFailed);
+ Sysout.println("The test is over, hit Ctl-C to stop Java VM");
+ //check if this called from main thread
+ if (mainThread == Thread.currentThread()) {
+ //If main thread, fail now 'cause not sleeping
+ throw new RuntimeException(whyFailed);
+ }
+ theTestPassed = false;
+ testGeneratedInterrupt = true;
+ failureMessage = whyFailed;
+ mainThread.interrupt();
+ }//fail()
+}// class LWComboBox
+class TestPassedException extends RuntimeException {
+}
+
+//*********** End Standard Test Machinery Section **********
+//************ Begin classes defined for the test ****************
+// if want to make listeners, here is the recommended place for them, then instantiate
+// them in init()
+
+/* Example of a class which may be written as part of a test
+class NewClass implements anInterface
+{
+static int newVar = 0;
+
+public void eventDispatched(AWTEvent e)
+{
+//Counting events to see if we get enough
+eventCount++;
+
+if( eventCount == 20 )
+{
+//got enough events, so pass
+
+LWComboBox.pass();
+}
+else if( tries == 20 )
+{
+//tried too many times without getting enough events so fail
+
+LWComboBox.fail();
+}
+
+}// eventDispatched()
+
+}// NewClass class
+
+ */
+//************** End classes defined for the test *******************
+/****************************************************
+Standard Test Machinery
+DO NOT modify anything below -- it's a standard
+chunk of code whose purpose is to make user
+interaction uniform, and thereby make it simpler
+to read and understand someone else's test.
+ ****************************************************/
+/**
+This is part of the standard test machinery.
+It creates a dialog (with the instructions), and is the interface
+for sending text messages to the user.
+To print the instructions, send an array of strings to Sysout.createDialog
+WithInstructions method. Put one line of instructions per array entry.
+To display a message for the tester to see, simply call Sysout.println
+with the string to be displayed.
+This mimics System.out.println but works within the test harness as well
+as standalone.
+ */
+class Sysout {
+
+ private static TestDialog dialog;
+
+ public static void createDialogWithInstructions(String[] instructions) {
+ dialog = new TestDialog(new Frame(), "Instructions");
+ dialog.printInstructions(instructions);
+ dialog.setVisible(true);
+ println("Any messages for the tester will display here.");
+ }
+
+ public static void createDialog() {
+ dialog = new TestDialog(new Frame(), "Instructions");
+ String[] defInstr = {"Instructions will appear here. ", ""};
+ dialog.printInstructions(defInstr);
+ dialog.setVisible(true);
+ println("Any messages for the tester will display here.");
+ }
+
+ public static void printInstructions(String[] instructions) {
+ dialog.printInstructions(instructions);
+ }
+
+ public static void println(String messageIn) {
+ dialog.displayMessage(messageIn);
+ System.out.println(messageIn);
+ }
+}// Sysout class
+
+/**
+This is part of the standard test machinery. It provides a place for the
+test instructions to be displayed, and a place for interactive messages
+to the user to be displayed.
+To have the test instructions displayed, see Sysout.
+To have a message to the user be displayed, see Sysout.
+Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog {
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog(Frame frame, String name) {
+ super(frame, name);
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea("", 15, maxStringLength, scrollBoth);
+ add("North", instructionsText);
+
+ messageText = new TextArea("", 5, maxStringLength, scrollBoth);
+ add("Center", messageText);
+
+ pack();
+
+ setVisible(true);
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions(String[] instructions) {
+ //Clear out any current instructions
+ instructionsText.setText("");
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for (int i = 0; i < instructions.length; i++) {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[i];
+ while (remainingStr.length() > 0) {
+ //if longer than max then chop off first max chars to print
+ if (remainingStr.length() >= maxStringLength) {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.lastIndexOf(' ', maxStringLength - 1);
+
+ if (posOfSpace <= 0) {
+ posOfSpace = maxStringLength - 1;
+ }
+
+ printStr = remainingStr.substring(0, posOfSpace + 1);
+ remainingStr = remainingStr.substring(posOfSpace + 1);
+ } //else just print
+ else {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append(printStr + "\n");
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage(String messageIn) {
+ messageText.append(messageIn + "\n");
+ System.out.println(messageIn);
+ }
+}// TestDialog class
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JButtonInGlassPaneOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,51 @@
+/*
+ * 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 javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JButton } component in GlassPane.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JButton
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JButtonInGlassPaneOverlapping
+ */
+public class JButtonInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JButton ch = new JButton();
+ ch.setText("Swing component");
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JButtonInGlassPaneOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JButtonOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,51 @@
+/*
+ * 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 javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JButton } component.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JButton
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JButtonOverlapping
+ */
+public class JButtonOverlapping extends SimpleOverlappingTestBase {
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JButton ch = new JButton();
+ ch.setText("Swing component");
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JButtonOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JColorChooserOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,54 @@
+/*
+ * 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 javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JColorChooser } component.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JColorChooser
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JColorChooserOverlapping
+ */
+public class JColorChooserOverlapping extends SimpleOverlappingTestBase {
+
+ public JColorChooserOverlapping() {
+ super(false);
+ }
+
+ @Override
+ protected JComponent getSwingComponent() {
+ wasLWClicked = true;
+ JColorChooser ch = new JColorChooser();
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JColorChooserOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JComboBoxOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,99 @@
+/*
+ * 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.Color;
+import java.awt.Dimension;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import javax.swing.BoxLayout;
+import javax.swing.JComboBox;
+import javax.swing.JFrame;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JCombobox } component.
+ * <p>This test creates combobox and test if heavyweight component is drawn correctly then dropdown is shown.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Overlapping test for javax.swing.JScrollPane
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JComboBoxOverlapping
+ */
+public class JComboBoxOverlapping extends OverlappingTestBase {
+
+ private boolean lwClicked = false;
+ private Point loc;
+ private Point loc2;
+
+ {testEmbeddedFrame = true;}
+
+ protected void prepareControls() {
+ final JFrame frame = new JFrame("Mixing : Dropdown Overlapping test");
+ frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));
+ frame.setSize(200, 200);
+ frame.setVisible(true);
+
+ final JComboBox cb = new JComboBox(petStrings);
+ cb.setPreferredSize(new Dimension(frame.getContentPane().getWidth(), 20));
+ cb.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ if (e.getSource() == cb) {
+ lwClicked = true;
+ }
+ }
+ });
+
+ frame.add(cb);
+ propagateAWTControls(frame);
+ frame.setVisible(true);
+ loc = cb.getLocationOnScreen();
+ loc2 = frame.getContentPane().getLocationOnScreen();
+ }
+
+ @Override
+ protected boolean performTest() {
+ // run robot
+ Robot robot = Util.createRobot();
+ robot.setAutoDelay(ROBOT_DELAY);
+
+ loc2.translate(75, 75);
+ pixelPreCheck(robot, loc2, currentAwtControl);
+
+ loc.translate(3, 3);
+ clickAndBlink(robot, loc, false);
+
+ clickAndBlink(robot, loc2, false);
+
+ return lwClicked;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JComboBoxOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JEditorPaneInGlassPaneOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,53 @@
+/*
+ * 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.Point;
+import javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JBEditorPane } component in GlassPane.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JLabel
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JEditorPaneInGlassPaneOverlapping
+ */
+public class JEditorPaneInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JEditorPane ch = new JEditorPane();
+ ch.setText("<b>Swing component</b>");
+ OverlappingTestBase.shift = new Point(12, 12);
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JEditorPaneInGlassPaneOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JEditorPaneOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,50 @@
+/*
+ * 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 javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JEditorPane } component.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JLabel
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JEditorPaneOverlapping
+ */
+public class JEditorPaneOverlapping extends SimpleOverlappingTestBase {
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JEditorPane ch = new JEditorPane();
+ ch.setText("<b>Swing component</b>");
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JEditorPaneOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JGlassPaneInternalFrameOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,127 @@
+/*
+ * 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.BorderLayout;
+import java.awt.Color;
+import java.awt.Container;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import javax.swing.JFrame;
+import javax.swing.JInternalFrame;
+import javax.swing.SwingUtilities;
+
+/**
+ * AWT/Swing overlapping test with JInternalFrame being put in GlassPane.
+ * See <a href="https://bugs.openjdk.java.net/browse/JDK-6637655">JDK-6637655</a> and
+ * <a href="https://bugs.openjdk.java.net/browse/JDK-6985776">JDK-6985776</a>.
+ * <p>See base class for details.
+ */
+/*
+@test
+@bug 6637655 6985776
+@summary Overlapping test for javax.swing.JScrollPane
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JGlassPaneInternalFrameOverlapping
+ */
+public class JGlassPaneInternalFrameOverlapping extends OverlappingTestBase {
+
+ private boolean lwClicked = true;
+ private Point lLoc;
+ private Point lLoc2;
+ private JInternalFrame internalFrame;
+
+ protected boolean performTest() {
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ lLoc = internalFrame.getContentPane().getLocationOnScreen();
+ lLoc2 = lLoc.getLocation();
+ lLoc2.translate(0, internalFrame.getContentPane().getHeight() + 10);
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ // run robot
+ Robot robot = Util.createRobot();
+ robot.setAutoDelay(ROBOT_DELAY);
+
+ clickAndBlink(robot, lLoc);
+
+ Color c = robot.getPixelColor(lLoc2.x, lLoc2.y);
+ robot.mouseMove(lLoc2.x, lLoc2.y);
+ if (!c.equals(AWT_BACKGROUND_COLOR) &&
+ currentAwtControl.getClass() != java.awt.Scrollbar.class &&
+ currentAwtControl.getClass() != java.awt.Choice.class) {
+ fail("The HW component did not pass pixel color check and is not drawn correctly");
+ }
+
+ return lwClicked;
+ }
+
+ // {debugClassName = "Choice";}
+
+ @Override
+ protected void prepareControls() {
+ JFrame frame = new JFrame("Glass Pane children test");
+ frame.setLayout(null);
+
+ Container contentPane = frame.getContentPane();
+ contentPane.setLayout(new BorderLayout());
+ super.propagateAWTControls(contentPane);
+
+ Container glassPane = (Container) frame.getRootPane().getGlassPane();
+ glassPane.setVisible(true);
+ glassPane.setLayout(null);
+
+ internalFrame = new JInternalFrame("Internal Frame", true);
+ internalFrame.setBounds(50, 0, 200, 100);
+ internalFrame.setVisible(true);
+ glassPane.add(internalFrame);
+
+ internalFrame.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ lwClicked = true;
+ }
+ });
+
+ frame.setSize(300, 180);
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ if (System.getProperty("os.name").toLowerCase().contains("os x")) {
+ System.out.println("Aqua L&F ignores setting color to component. Test passes on Mac OS X.");
+ return;
+ }
+ instance = new JGlassPaneInternalFrameOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JGlassPaneMoveOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,167 @@
+/*
+ * 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.BorderLayout;
+import java.awt.Color;
+import java.awt.Container;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import javax.swing.JFrame;
+import javax.swing.JInternalFrame;
+import javax.swing.SwingUtilities;
+
+/**
+ * AWT/Swing overlapping test with JInternalFrame being moved in GlassPane.
+ * See <a href="https://bugs.openjdk.java.net/browse/JDK-6637655">JDK-6637655</a> and
+ * <a href="https://bugs.openjdk.java.net/browse/JDK-6981919">JDK-6981919</a>.
+ * <p>See base class for details.
+ */
+/*
+@test
+@bug 6637655 6981919
+@summary Overlapping test for javax.swing.JScrollPane
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JGlassPaneMoveOverlapping
+ */
+public class JGlassPaneMoveOverlapping extends OverlappingTestBase {
+
+ private boolean lwClicked = true;
+ private volatile Point lLoc;
+ private volatile Point lLoc2;
+
+ private JInternalFrame internalFrame;
+ private JFrame frame = null;
+ private volatile Point frameLoc;
+
+ protected boolean performTest() {
+
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ lLoc = internalFrame.getContentPane().getLocationOnScreen();
+ lLoc2 = lLoc.getLocation();
+ lLoc2.translate(0, internalFrame.getHeight());
+ frameLoc = frame.getLocationOnScreen();
+ frameLoc.translate(frame.getWidth()/2, 3);
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ // run robot
+ Robot robot = Util.createRobot();
+ robot.setAutoDelay(ROBOT_DELAY);
+
+ // force focus on JFrame (jtreg workaround)
+ robot.mouseMove(frameLoc.x, frameLoc.y);
+ Util.waitForIdle(robot);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(50);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ Util.waitForIdle(robot);
+
+
+ //slow move
+ robot.mouseMove(lLoc.x + 25, lLoc.y - 5);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(100);
+ robot.mouseMove(lLoc.x + 45, lLoc.y - 5);
+ robot.delay(100);
+ robot.mouseMove(lLoc.x + internalWidth - 75, lLoc.y - 5);
+ robot.delay(100);
+ robot.mouseMove(lLoc.x + internalWidth - 55, lLoc.y - 5);
+ robot.delay(100);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ Color c2 = robot.getPixelColor(lLoc.x + internalWidth + 15, lLoc.y - 5);
+ if (c2.equals(AWT_BACKGROUND_COLOR)) {
+ error("Foreground frame is not drawn properly");
+ }
+ Color c = robot.getPixelColor(lLoc.x + internalWidth - 95, lLoc.y + 5);
+ robot.mouseMove(lLoc.x + internalWidth - 95, lLoc.y + 5);
+ System.out.println("color: " + c + " " + AWT_BACKGROUND_COLOR);
+ if (!c.equals(AWT_BACKGROUND_COLOR) && currentAwtControl.getClass() != java.awt.Scrollbar.class) {
+ error("Background AWT component is not drawn properly");
+ }
+
+ return true;
+ }
+
+ // {debugClassName = "Choice";}
+
+ private static void error(String st) {
+ //System.out.println(st);
+ fail(st);
+ }
+
+ private static final int internalWidth = 200;
+
+ @Override
+ protected void prepareControls() {
+ if(frame != null) {
+ frame.setVisible(false);
+ }
+ frame = new JFrame("Glass Pane children test");
+ frame.setLayout(null);
+
+ Container contentPane = frame.getContentPane();
+ contentPane.setLayout(new BorderLayout());
+ super.propagateAWTControls(contentPane);
+
+ Container glassPane = (Container) frame.getRootPane().getGlassPane();
+ glassPane.setVisible(true);
+ glassPane.setLayout(null);
+
+ internalFrame = new JInternalFrame("Internal Frame", true);
+ internalFrame.setBounds(50, 0, internalWidth, 100);
+ internalFrame.setVisible(true);
+ glassPane.add(internalFrame);
+
+ internalFrame.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ lwClicked = true;
+ }
+ });
+
+ frame.setSize(400, 180);
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ if (System.getProperty("os.name").toLowerCase().contains("os x")) {
+ System.out.println("Aqua L&F ignores setting color to component. Test passes on Mac OS X.");
+ return;
+ }
+ instance = new JGlassPaneMoveOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JInternalFrameMoveOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,124 @@
+/*
+ * 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.Point;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import javax.swing.JButton;
+import javax.swing.JDesktopPane;
+import javax.swing.JFrame;
+import javax.swing.JInternalFrame;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JInternalFrame } component during move.
+ * <p>See <a href="http://monaco.sfbay.sun.com/detail.jsf?cr=6985399">CR6768230</a> for details and base class for test info.
+ */
+/*
+@test
+@bug 6985399
+@summary Overlapping test for javax.swing.JScrollPane
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JInternalFrameMoveOverlapping
+ */
+public class JInternalFrameMoveOverlapping extends OverlappingTestBase {
+
+ private boolean lwClicked = true;
+ private Point locTopFrame;
+ private Point locTarget;
+
+ protected boolean performTest() {
+ // run robot
+ Robot robot = Util.createRobot();
+ robot.setAutoDelay(ROBOT_DELAY);
+
+ robot.mouseMove(locTopFrame.x + 25, locTopFrame.y + 25);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException ex) {
+ }
+ robot.mouseMove(locTopFrame.x + (locTarget.x - locTopFrame.x)/2, locTopFrame.y + (locTarget.y - locTopFrame.y)/2);
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException ex) {
+ }
+ robot.mouseMove(locTarget.x, locTarget.y);
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException ex) {
+ }
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ clickAndBlink(robot, locTarget);
+
+ return lwClicked;
+ }
+
+ //static {debugClassName = "Choice";}
+
+ @Override
+ protected void prepareControls() {
+
+
+ JDesktopPane desktopPane = new JDesktopPane();
+
+ JInternalFrame bottomFrame = new JInternalFrame("bottom frame", false, false, false, false);
+ bottomFrame.setSize(220, 220);
+ super.propagateAWTControls(bottomFrame);
+ desktopPane.add(bottomFrame);
+ bottomFrame.setVisible(true);
+
+ JInternalFrame topFrame = new JInternalFrame("top frame", false, false, false, false);
+ topFrame.setSize(200, 200);
+ topFrame.add(new JButton("LW Button") {
+
+ {
+ addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ lwClicked = true;
+ }
+ });
+ }
+ });
+ desktopPane.add(topFrame);
+ topFrame.setVisible(true);
+
+ JFrame frame = new JFrame("Test Window");
+ frame.setSize(300, 300);
+ frame.setContentPane(desktopPane);
+ frame.setVisible(true);
+
+ locTopFrame = topFrame.getLocationOnScreen();
+ locTarget = new Point(locTopFrame.x + bottomFrame.getWidth() / 2, locTopFrame.y + bottomFrame.getHeight()/2);
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JInternalFrameMoveOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JInternalFrameOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,102 @@
+/*
+ * 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.Point;
+import java.awt.Robot;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import javax.swing.JButton;
+import javax.swing.JDesktopPane;
+import javax.swing.JFrame;
+import javax.swing.JInternalFrame;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JInternalFrame } component.
+ * <p>See base class for test info.
+ */
+/*
+@test
+@summary Overlapping test for javax.swing.JScrollPane
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JInternalFrameOverlapping
+ */
+public class JInternalFrameOverlapping extends OverlappingTestBase {
+
+ private boolean lwClicked = true;
+ private Point lLoc;
+
+ protected boolean performTest() {
+
+
+ // run robot
+ Robot robot = Util.createRobot();
+ robot.setAutoDelay(ROBOT_DELAY);
+
+ clickAndBlink(robot, lLoc);
+
+ return lwClicked;
+ }
+
+ /**
+ * Creating two JInternalFrames in JDesktopPanes. Put lightweight component into one frame and heavyweight into another.
+ */
+ @Override
+ protected void prepareControls() {
+ JDesktopPane desktopPane = new JDesktopPane();
+
+ JFrame frame = new JFrame("Test Window");
+ frame.setSize(300, 300);
+ frame.setContentPane(desktopPane);
+ frame.setVisible(true);
+ JInternalFrame bottomFrame = new JInternalFrame("bottom frame", false, false, false, false);
+ bottomFrame.setSize(220, 220);
+ desktopPane.add(bottomFrame);
+ bottomFrame.setVisible(true);
+
+ super.propagateAWTControls(bottomFrame);
+ JInternalFrame topFrame = new JInternalFrame("top frame", false, false, false, false);
+ topFrame.setSize(200, 200);
+ JButton jbutton = new JButton("LW Button") {{
+ addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ lwClicked = true;
+ }
+ });
+ }};
+ topFrame.add(jbutton);
+ desktopPane.add(topFrame);
+ topFrame.setVisible(true);
+ lLoc = jbutton.getLocationOnScreen();
+ lLoc.translate(jbutton.getWidth()/2, jbutton.getWidth()/2); //click at middle of the button
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JInternalFrameOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JLabelInGlassPaneOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,53 @@
+/*
+ * 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.Dimension;
+import javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JLabel } component in GlassPane.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JLabel
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JLabelInGlassPaneOverlapping
+ */
+public class JLabelInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JLabel ch = new JLabel();
+ ch.setPreferredSize(new Dimension(50, 50));
+ ch.setText("Swing component");
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JLabelInGlassPaneOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JLabelOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,52 @@
+/*
+ * 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.Dimension;
+import javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JLabel } component.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JLabel
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JLabelOverlapping
+ */
+public class JLabelOverlapping extends SimpleOverlappingTestBase {
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JLabel ch = new JLabel();
+ ch.setPreferredSize(new Dimension(50, 50));
+ ch.setText("Swing component");
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JLabelOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JListInGlassPaneOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,50 @@
+/*
+ * 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 javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JList } component in GlassPane.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JList
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JListInGlassPaneOverlapping
+ */
+public class JListInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JList ch = new JList(new String[] {"one", "two", "three"});
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JListInGlassPaneOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JListOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,49 @@
+/*
+ * 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 javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JList } component.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JList
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JListOverlapping
+ */
+public class JListOverlapping extends SimpleOverlappingTestBase {
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JList ch = new JList(new String[] {"one", "two", "three", "four"});
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JListOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JMenuBarOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,149 @@
+/*
+ * 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.Color;
+import java.awt.GridLayout;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JSeparator;
+import javax.swing.SwingUtilities;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JMenuBar } and {@link javax.swing.JSeparator} components.
+ * <p>This test creates menu bar and test if heavyweight component is drawn correctly then menu dropdown is shown.
+ * <p>See base class for test info.
+ */
+/*
+@test
+@summary Overlapping test for javax.swing.JScrollPane
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JMenuBarOverlapping
+ */
+public class JMenuBarOverlapping extends OverlappingTestBase {
+
+ {testEmbeddedFrame = true;}
+
+ private boolean lwClicked = false;
+ private boolean spClicked = false;
+ private Point loc;
+ private Point loc2;
+ private Point sepLoc;
+ private JFrame frame;
+ private JMenuBar menuBar;
+ JSeparator separator;
+
+ protected void prepareControls() {
+ frame = new JFrame("Mixing : Dropdown Overlapping test");
+ frame.setLayout(new GridLayout(0,1));
+ frame.setSize(200, 200);
+ frame.setVisible(true);
+
+ menuBar = new JMenuBar();
+ JMenu menu = new JMenu("Test Menu");
+ ActionListener menuListener = new ActionListener() {
+
+ public void actionPerformed(ActionEvent event) {
+ lwClicked = true;
+ }
+ };
+
+ JMenuItem item;
+ menu.add(item = new JMenuItem("first"));
+ item.addActionListener(menuListener);
+ separator = new JSeparator();
+ separator.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ spClicked = true;
+ }
+ });
+ menu.add(separator);
+
+ for (int i = 0; i < petStrings.length; i++) {
+ menu.add(item = new JMenuItem(petStrings[i]));
+ item.addActionListener(menuListener);
+ }
+ menuBar.add(menu);
+ frame.setJMenuBar(menuBar);
+
+ propagateAWTControls(frame);
+ frame.setVisible(true);
+ }
+
+ @Override
+ protected boolean performTest() {
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ loc = menuBar.getLocationOnScreen();
+ loc2 = frame.getContentPane().getLocationOnScreen();
+ }
+ });
+ } catch (Exception e) {
+ }
+ // run robot
+ Robot robot = Util.createRobot();
+ robot.setAutoDelay(ROBOT_DELAY);
+
+ loc2.translate(75, 75);
+ pixelPreCheck(robot, loc2, currentAwtControl);
+
+ loc.translate(3, 3);
+ clickAndBlink(robot, loc, false);
+
+ clickAndBlink(robot, loc2, false);
+
+ clickAndBlink(robot, loc, false);
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ sepLoc = separator.getLocationOnScreen();
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ sepLoc.translate(20, 1);
+ clickAndBlink(robot, sepLoc, false);
+
+ clickAndBlink(robot, loc, false); // close menu before running next step
+ return lwClicked && spClicked;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JMenuBarOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JPanelInGlassPaneOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,53 @@
+/*
+ * 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.Dimension;
+import javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JPanel } component in GlassPane.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JPanel
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JPanelInGlassPaneOverlapping
+ */
+public class JPanelInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JPanel ch = new JPanel();
+ ch.setPreferredSize(new Dimension(50, 50));
+ ch.setBorder(BorderFactory.createTitledBorder("Swing Component"));
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JPanelInGlassPaneOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JPanelOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,52 @@
+/*
+ * 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.Dimension;
+import javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JPanel } component.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JPanel
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JPanelOverlapping
+ */
+public class JPanelOverlapping extends SimpleOverlappingTestBase {
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JPanel ch = new JPanel();
+ ch.setPreferredSize(new Dimension(50, 50));
+ ch.setBorder(BorderFactory.createTitledBorder("Swing Component"));
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JPanelOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JPopupMenuOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,124 @@
+/*
+ * 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.Color;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.lang.reflect.InvocationTargetException;
+import javax.swing.JFrame;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+import javax.swing.SpringLayout;
+import javax.swing.SwingUtilities;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JPopupMenu } component.
+ * <p>This test creates menu and test if heavyweight component is drawn correctly then menu dropdown is shown.
+ * <p>See base class for test info.
+ */
+/*
+@test
+@summary Overlapping test for javax.swing.JScrollPane
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JPopupMenuOverlapping
+ */
+public class JPopupMenuOverlapping extends OverlappingTestBase {
+
+ {testEmbeddedFrame = true;}
+
+ private boolean lwClicked = false;
+ private Point loc;
+ private JPopupMenu popup;
+ private JFrame frame=null;
+
+ protected void prepareControls() {
+ if(frame != null) {
+ frame.setVisible(false);
+ }
+ frame = new JFrame("Mixing : Dropdown Overlapping test");
+ frame.setLayout(new SpringLayout());
+ frame.setSize(200, 200);
+
+ popup = new JPopupMenu();
+ ActionListener menuListener = new ActionListener() {
+
+ public void actionPerformed(ActionEvent event) {
+ lwClicked = true;
+ }
+ };
+ JMenuItem item;
+ for (int i = 0; i < petStrings.length; i++) {
+ popup.add(item = new JMenuItem(petStrings[i]));
+ item.addActionListener(menuListener);
+ }
+ propagateAWTControls(frame);
+ frame.setVisible(true);
+ loc = frame.getContentPane().getLocationOnScreen();
+ }
+
+ @Override
+ protected boolean performTest() {
+ // run robot
+ Robot robot = Util.createRobot();
+ robot.setAutoDelay(ROBOT_DELAY);
+
+ loc.translate(75, 75);
+
+ pixelPreCheck(robot, loc, currentAwtControl);
+
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ public void run() {
+ popup.show(frame.getContentPane(), 15, 15);
+ }
+ });
+
+ robot.waitForIdle();
+
+ clickAndBlink(robot, loc, false);
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ public void run() {
+ popup.setVisible(false);
+ }
+ });
+ } catch (InterruptedException ex) {
+ fail(ex.getMessage());
+ } catch (InvocationTargetException ex) {
+ fail(ex.getMessage());
+ }
+
+ return lwClicked;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JPopupMenuOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JProgressBarInGlassPaneOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,53 @@
+/*
+ * 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.Dimension;
+import javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JProgressBar } component in GlassPane.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JProgressBar
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JProgressBarInGlassPaneOverlapping
+ */
+public class JProgressBarInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JProgressBar ch = new JProgressBar();
+ ch.setValue(50);
+ ch.setPreferredSize(new Dimension(50, 50));
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JProgressBarInGlassPaneOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JProgressBarOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,52 @@
+/*
+ * 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.Dimension;
+import javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JProgressBar } component.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JProgressBar
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JProgressBarOverlapping
+ */
+public class JProgressBarOverlapping extends SimpleOverlappingTestBase {
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JProgressBar ch = new JProgressBar();
+ ch.setValue(50);
+ ch.setPreferredSize(new Dimension(50, 50));
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JProgressBarOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JScrollBarInGlassPaneOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,67 @@
+/*
+ * 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.Point;
+import java.awt.Dimension;
+import java.awt.event.AdjustmentEvent;
+import java.awt.event.AdjustmentListener;
+import javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JScrollBar } component in GlassPane.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JScrollBar
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JScrollBarInGlassPaneOverlapping
+ */
+public class JScrollBarInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
+
+ public JScrollBarInGlassPaneOverlapping() {
+ super(false);
+ }
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JScrollBar ch = new JScrollBar(JScrollBar.VERTICAL);
+ ch.setPreferredSize(new Dimension(50, 50));
+ ch.setValue(50);
+ ch.addAdjustmentListener(new AdjustmentListener() {
+
+ public void adjustmentValueChanged(AdjustmentEvent e) {
+ wasLWClicked = true;
+ }
+ });
+ OverlappingTestBase.shift = new Point(20, 16);
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JScrollBarInGlassPaneOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JScrollBarOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,66 @@
+/*
+ * 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.Point;
+import java.awt.Dimension;
+import java.awt.event.AdjustmentEvent;
+import java.awt.event.AdjustmentListener;
+import javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JScrollBar } component.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JScrollBar
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JScrollBarOverlapping
+ */
+public class JScrollBarOverlapping extends SimpleOverlappingTestBase {
+
+ public JScrollBarOverlapping() {
+ super(false);
+ }
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JScrollBar ch = new JScrollBar(JScrollBar.VERTICAL);
+ ch.setPreferredSize(new Dimension(50, 50));
+ ch.setValue(50);
+ ch.addAdjustmentListener(new AdjustmentListener() {
+
+ public void adjustmentValueChanged(AdjustmentEvent e) {
+ wasLWClicked = true;
+ }
+ });
+ OverlappingTestBase.shift = new Point(20, 16);
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JScrollBarOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JScrollPaneOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,129 @@
+/*
+ * 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.Dimension;
+import java.awt.GridLayout;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.AdjustmentEvent;
+import java.awt.event.AdjustmentListener;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.SwingUtilities;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JScrollPane } component.
+ * <p>See base class for test info.
+ */
+/*
+@test
+@summary Overlapping test for javax.swing.JScrollPane
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JScrollPaneOverlapping
+ */
+public class JScrollPaneOverlapping extends OverlappingTestBase {
+
+// {testEmbeddedFrame = true;}
+
+ private boolean horizontalClicked = false;
+ private boolean verticalClicked = false;
+ private Point hLoc;
+ private Point vLoc;
+
+ private JFrame f;
+ private JPanel p;
+ private JScrollPane scrollPane;
+
+ protected void prepareControls() {
+
+ f = new JFrame("JScrollPane");
+ f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ f.setSize(120, 120);
+
+ p = new JPanel(new GridLayout(0, 1));
+
+ scrollPane = new JScrollPane(p);
+ scrollPane.setPreferredSize(new Dimension(300,300));
+ scrollPane.setHorizontalScrollBarPolicy(
+ JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
+ scrollPane.setVerticalScrollBarPolicy(
+ JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+
+ scrollPane.getHorizontalScrollBar().setValue(1);
+ scrollPane.getHorizontalScrollBar().addAdjustmentListener(new AdjustmentListener() {
+
+ public void adjustmentValueChanged(AdjustmentEvent e) {
+ horizontalClicked = true;
+ }
+ });
+
+ scrollPane.getVerticalScrollBar().setValue(1);
+ scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
+
+ public void adjustmentValueChanged(AdjustmentEvent e) {
+ verticalClicked = true;
+ }
+ });
+
+ f.getContentPane().add(scrollPane);
+ f.setVisible(true);
+ propagateAWTControls(p);
+// JButton b = new JButton("Space extender");
+// b.setPreferredSize(new Dimension(150,150));
+// p.add( b );
+
+ //b.requestFocus(); // to change the look of AWT component, especially Choice
+ }
+
+ @Override
+ protected boolean performTest() {
+ // run robot
+ Robot robot = Util.createRobot();
+ robot.setAutoDelay(ROBOT_DELAY);
+
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ hLoc = scrollPane.getHorizontalScrollBar().getLocationOnScreen();
+ vLoc = scrollPane.getVerticalScrollBar().getLocationOnScreen();
+ }
+ });
+ } catch (Exception e) {
+ }
+ hLoc.translate(2, 2);
+ vLoc.translate(2, 2);
+
+ clickAndBlink(robot, hLoc, false);
+ clickAndBlink(robot, vLoc, false);
+
+ return horizontalClicked && verticalClicked;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JScrollPaneOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JSliderInGlassPaneOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,52 @@
+/*
+ * 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.Dimension;
+import javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JSlider } component in GlassPane.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JSlider
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JSliderInGlassPaneOverlapping
+ */
+public class JSliderInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JSlider ch = new JSlider();
+ ch.setPreferredSize(new Dimension(50, 50));
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JSliderInGlassPaneOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JSliderOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,51 @@
+/*
+ * 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.Dimension;
+import javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JSlider } component.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JSlider
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JSliderOverlapping
+ */
+public class JSliderOverlapping extends SimpleOverlappingTestBase {
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JSlider ch = new JSlider();
+ ch.setPreferredSize(new Dimension(50, 50));
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JSliderOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JSpinnerInGlassPaneOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,67 @@
+/*
+ * 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.Dimension;
+import javax.swing.event.ChangeEvent;
+import javax.swing.*;
+import javax.swing.event.ChangeListener;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JSpinner } component in GlassPane.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JSpinner
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JSpinnerInGlassPaneOverlapping
+ */
+public class JSpinnerInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
+
+ {testResize = false;}
+
+ public JSpinnerInGlassPaneOverlapping() {
+ super(false);
+ }
+
+// static {debugClassName = "Choice";}
+ @Override
+ protected JComponent getSwingComponent() {
+ JSpinner ch = new JSpinner();
+ ch.setPreferredSize(new Dimension(30, 50));
+ ch.addChangeListener(new ChangeListener() {
+
+ public void stateChanged(ChangeEvent e) {
+ wasLWClicked = true;
+ }
+ });
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JSpinnerInGlassPaneOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JSpinnerOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,64 @@
+/*
+ * 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.Dimension;
+import javax.swing.event.ChangeEvent;
+import javax.swing.*;
+import javax.swing.event.ChangeListener;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JSpinner } component.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JSpinner
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JSpinnerOverlapping
+ */
+public class JSpinnerOverlapping extends SimpleOverlappingTestBase {
+
+ public JSpinnerOverlapping() {
+ super(false);
+ }
+
+// static {debugClassName = "Choice";}
+ @Override
+ protected JComponent getSwingComponent() {
+ JSpinner ch = new JSpinner();
+ ch.setPreferredSize(new Dimension(30, 50));
+ ch.addChangeListener(new ChangeListener() {
+
+ public void stateChanged(ChangeEvent e) {
+ wasLWClicked = true;
+ }
+ });
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JSpinnerOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JSplitPaneOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,130 @@
+/*
+ * 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.Color;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.InputEvent;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.SwingUtilities;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JSplitPane } component.
+ * <p>This test creates puts heavyweight and lightweight components into different panels and test if splitter image and components itself are drawn correctly.
+ * <p>See base class for test info.
+ */
+/*
+@test
+@bug 6986109
+@summary Overlapping test for javax.swing.JSplitPane
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JSplitPaneOverlapping
+ */
+public class JSplitPaneOverlapping extends OverlappingTestBase {
+
+ private boolean clicked = false;
+ private Point splitterLoc;
+ private JScrollPane sp1;
+ private JScrollPane sp2;
+
+ protected void prepareControls() {
+ JFrame frame = new JFrame("SplitPane Mixing");
+ JPanel p = new JPanel(new GridLayout());
+ p.setPreferredSize(new Dimension(500, 500));
+ propagateAWTControls(p);
+ sp1 = new JScrollPane(p);
+
+ JButton button = new JButton("JButton");
+ button.setBackground(Color.RED);
+ button.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ clicked = true;
+ }
+ });
+ sp2 = new JScrollPane(button);
+
+ JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sp1, sp2);
+ splitPane.setOneTouchExpandable(false);
+ splitPane.setDividerLocation(150);
+
+ splitPane.setPreferredSize(new Dimension(400, 200));
+
+ frame.getContentPane().add(splitPane);
+ frame.pack();
+ frame.setVisible(true);
+ }
+
+ private static final boolean ignoreFail = false;
+
+ @Override
+ protected boolean performTest() {
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ splitterLoc = sp2.getLocationOnScreen();
+ Point leftLoc = sp1.getLocationOnScreen();
+ leftLoc.translate(sp1.getWidth(), 0);
+ splitterLoc.translate(-(splitterLoc.x - leftLoc.x) / 2, 30);
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ // run robot
+ Robot robot = Util.createRobot();
+ robot.setAutoDelay(ROBOT_DELAY);
+
+ robot.mouseMove(splitterLoc.x, splitterLoc.y);
+ Util.waitForIdle(robot);
+
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseMove(splitterLoc.x - 50, splitterLoc.y);
+ Color c = robot.getPixelColor(splitterLoc.x - 50, splitterLoc.y);
+ System.out.println("Actual: "+c+", (not) expected: "+AWT_VERIFY_COLOR+" at "+(splitterLoc.x - 50)+", "+ splitterLoc.y);
+ if (!ignoreFail && c.equals(AWT_VERIFY_COLOR)) {
+ fail("The JSplitPane drag-n-drop image did not pass pixel color check and is overlapped");
+ }
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ clickAndBlink(robot, splitterLoc);
+
+ return clicked;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JSplitPaneOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JTableInGlassPaneOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,87 @@
+/*
+ * 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 javax.swing.JComponent;
+import javax.swing.JTable;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JTable } component in GlassPane.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for JTable
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JTableInGlassPaneOverlapping
+ */
+public class JTableInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
+
+ {
+ testResize = false;
+ }
+
+ @Override
+ protected JComponent getSwingComponent() {
+ // Create columns names
+ String columnNames[] = {"Column 1", "Column 2", "Column 3"};
+
+ // Create some data
+ String dataValues[][] = {
+ {"12", "234", "67"},
+ {"-123", "43", "853"},
+ {"93", "89.2", "109"},
+ {"279", "9033", "3092"},
+ {"12", "234", "67"},
+ {"-123", "43", "853"},
+ {"93", "89.2", "109"},
+ {"279", "9033", "3092"},
+ {"12", "234", "67"},
+ {"-123", "43", "853"},
+ {"93", "89.2", "109"},
+ {"279", "9033", "3092"},
+ {"12", "234", "67"},
+ {"-123", "43", "853"},
+ {"93", "89.2", "109"},
+ {"279", "9033", "3092"}
+ };
+
+ // Create a new table instance
+ JTable jt = new JTable(dataValues, columnNames);
+ jt.getModel().addTableModelListener(new TableModelListener() {
+
+ public void tableChanged(TableModelEvent e) {
+ System.err.println("table changed");
+ }
+ });
+ return jt;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JTableInGlassPaneOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JTableOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,73 @@
+/*
+ * 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 javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JTable } component.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for JTable
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JTableOverlapping
+ */
+public class JTableOverlapping extends SimpleOverlappingTestBase {
+
+ @Override
+ protected JComponent getSwingComponent() {
+ // Create columns names
+ String columnNames[] = { "Column 1", "Column 2", "Column 3" };
+
+ // Create some data
+ String dataValues[][] =
+ {
+ { "12", "234", "67" },
+ { "-123", "43", "853" },
+ { "93", "89.2", "109" },
+ { "279", "9033", "3092" },
+ { "12", "234", "67" },
+ { "-123", "43", "853" },
+ { "93", "89.2", "109" },
+ { "279", "9033", "3092" },
+ { "12", "234", "67" },
+ { "-123", "43", "853" },
+ { "93", "89.2", "109" },
+ { "279", "9033", "3092" },
+ { "12", "234", "67" },
+ { "-123", "43", "853" },
+ { "93", "89.2", "109" },
+ { "279", "9033", "3092" }
+ };
+
+ // Create a new table instance
+ return new JTable( dataValues, columnNames );
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JTableOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JTextAreaInGlassPaneOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,53 @@
+/*
+ * 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.Dimension;
+import javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JTextArea } component in GlassPane.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JLabel
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JTextAreaInGlassPaneOverlapping
+ */
+public class JTextAreaInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JTextArea ch = new JTextArea();
+ ch.setPreferredSize(new Dimension(50, 50));
+ ch.setText("Swing component");
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JTextAreaInGlassPaneOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JTextAreaOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,52 @@
+/*
+ * 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.Dimension;
+import javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JTextArea } component.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JLabel
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JTextAreaOverlapping
+ */
+public class JTextAreaOverlapping extends SimpleOverlappingTestBase {
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JTextArea ch = new JTextArea();
+ ch.setPreferredSize(new Dimension(50, 50));
+ ch.setText("Swing component");
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JTextAreaOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JTextFieldInGlassPaneOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,53 @@
+/*
+ * 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.Dimension;
+import javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JTextField } component in GlassPane.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JLabel
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JTextFieldInGlassPaneOverlapping
+ */
+public class JTextFieldInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JTextField ch = new JTextField();
+ ch.setPreferredSize(new Dimension(50, 50));
+ ch.setText("Swing component");
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JTextFieldInGlassPaneOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JTextFieldOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,52 @@
+/*
+ * 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.Dimension;
+import javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JTextField } component.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JLabel
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JTextFieldOverlapping
+ */
+public class JTextFieldOverlapping extends SimpleOverlappingTestBase {
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JTextField ch = new JTextField();
+ ch.setPreferredSize(new Dimension(50, 50));
+ ch.setText("Swing component");
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JTextFieldOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JToggleButtonInGlassPaneOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,51 @@
+/*
+ * 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 javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JToggleButton } component in GlassPane.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JToggleButton
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JToggleButtonInGlassPaneOverlapping
+ */
+public class JToggleButtonInGlassPaneOverlapping extends GlassPaneOverlappingTestBase {
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JToggleButton ch = new JToggleButton();
+ ch.setText("Swing component");
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JToggleButtonInGlassPaneOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JToggleButtonOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,50 @@
+/*
+ * 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 javax.swing.*;
+
+/**
+ * AWT/Swing overlapping test for {@link javax.swing.JToggleButton } component.
+ * <p>See base class for details.
+ */
+/*
+@test
+@summary Simple Overlapping test for javax.swing.JToggleButton
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main JToggleButtonOverlapping
+ */
+public class JToggleButtonOverlapping extends SimpleOverlappingTestBase {
+
+ @Override
+ protected JComponent getSwingComponent() {
+ JToggleButton ch = new JToggleButton();
+ ch.setText("Swing component");
+ return ch;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new JToggleButtonOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/MixingFrameResizing.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,127 @@
+/*
+ * 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.Color;
+import java.awt.Dimension;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import javax.swing.JFrame;
+import javax.swing.SpringLayout;
+import javax.swing.SwingUtilities;
+
+/**
+ * AWT/Swing overlapping test.
+ * <p>This test puts heavyweight component into JFrame and verifies that it's being drawn correctly after resizing the frame.
+ * <p>See base class for test info.
+ */
+/*
+@test
+@bug 6777370
+@summary Issues when resizing the JFrame with HW components
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main MixingFrameResizing
+ */
+public class MixingFrameResizing extends OverlappingTestBase {
+
+ {testEmbeddedFrame = true;}
+
+ private JFrame frame = null;
+ private Point lLoc;
+ private Point lLoc2;
+ private Dimension size;
+
+ protected void prepareControls() {
+ if(frame != null) {
+ frame.setVisible(false);
+ }
+ frame = new JFrame("Mixing : Frame Resizing test");
+ frame.setLayout(new SpringLayout());
+ frame.setSize(50, 50);
+ frame.setVisible(true);
+ propagateAWTControls(frame);
+ Util.waitTillShown(frame);
+ }
+
+ @Override
+ protected boolean performTest() {
+ int BORDER_SHIFT = frameBorderCounter();
+ BORDER_SHIFT = Math.abs(BORDER_SHIFT) == 1 ? BORDER_SHIFT : (BORDER_SHIFT / 2);
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ lLoc = frame.getLocationOnScreen();
+ size = frame.getSize();
+ lLoc2 = frame.getContentPane().getLocationOnScreen();
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ Robot robot = Util.createRobot();
+ robot.setAutoDelay(ROBOT_DELAY/2);
+
+ // resize window
+ robot.mouseMove(lLoc.x + size.width / 2 + BORDER_SHIFT, lLoc.y + size.height + BORDER_SHIFT);
+ Util.waitForIdle(robot);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ for (int i = 0; i < 10; i++) {
+ robot.mouseMove(lLoc.x + size.width / 2 + BORDER_SHIFT, lLoc.y + size.height + BORDER_SHIFT + 20 * i);
+ }
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ robot.mouseMove(lLoc.x + size.width + BORDER_SHIFT, lLoc.y + size.height + BORDER_SHIFT);
+ Util.waitForIdle(robot);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ for (int i = 0; i < 10; i++) {
+ robot.mouseMove(lLoc.x + size.width + BORDER_SHIFT + 20 * i, lLoc.y + size.height + BORDER_SHIFT);
+ }
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ Util.waitForIdle(robot);
+ // check if component is visible on the opened space
+ try {
+ Thread.sleep(300); //some more wait for Solaris (for some reason)
+ }catch(Exception ex) {}
+ lLoc2.translate(75, 75);
+ Color c = robot.getPixelColor(lLoc2.x, lLoc2.y);
+ System.out.println("Actual: "+c+", expected: "+AWT_VERIFY_COLOR);
+
+ if (!c.equals(AWT_VERIFY_COLOR)) {
+ fail("HW component is not visible after resizing");
+ }
+
+ return true;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ if (System.getProperty("os.name").toLowerCase().contains("os x")) {
+ System.out.println("Aqua L&F ignores setting color to component. Test passes on Mac OS X.");
+ return;
+ }
+ instance = new MixingFrameResizing();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/MixingPanelsResizing.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,462 @@
+/*
+ * 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.*;
+import java.awt.event.InputEvent;
+import javax.swing.*;
+import java.io.*;
+
+/**
+ * AWT/Swing overlapping test for Panel and JPanel behavior during resizing.
+ * <p>See <a href="https://bugs.openjdk.java.net/browse/JDK-6786219">JDK-6786219</a> for details
+ */
+/*
+@test
+@bug 6786219
+@summary Issues when resizing the frame after mixing of heavy weight & light weight components
+@author sergey.grinev@oracle.com: area=awt.mixing
+@build FrameBorderCounter
+@run main MixingPanelsResizing
+ */
+public class MixingPanelsResizing {
+
+ static volatile boolean failed = false;
+
+ private static JFrame frame;
+ private static JButton jbutton;
+ private static Button awtButton;
+ private static JButton jbutton2;
+ private static Button awtButton2;
+ private static final Color jbColor = Color.RED;
+ private static final Color awtColor = Color.ORANGE;
+ private static final Color jb2Color = Color.BLUE;
+ private static final Color awt2Color = Color.CYAN;
+ private static final int ROBOT_DELAY = 500;
+
+ private static Point lLoc;
+ private static int borderShift;
+
+ private static int frameBorderCounter() {
+ String JAVA_HOME = System.getProperty("java.home");
+ try {
+ Process p = Runtime.getRuntime().exec(JAVA_HOME + "/bin/java FrameBorderCounter");
+ try {
+ p.waitFor();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ if (p.exitValue() != 0) {
+ throw new RuntimeException("FrameBorderCounter exited with not null code!\n" + readInputStream(p.getErrorStream()));
+ }
+ return Integer.parseInt(readInputStream(p.getInputStream()).trim());
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static String readInputStream(InputStream is) throws IOException {
+ byte[] buffer = new byte[4096];
+ int len = 0;
+ StringBuilder sb = new StringBuilder();
+ try (InputStreamReader isr = new InputStreamReader(is)) {
+ while ((len = is.read(buffer)) > 0) {
+ sb.append(new String(buffer, 0, len));
+ }
+ }
+ return sb.toString();
+ }
+
+ private static void init() throws Exception {
+ //*** Create instructions for the user here ***
+
+ borderShift = frameBorderCounter();
+ borderShift = Math.abs(borderShift) == 1 ? borderShift : (borderShift / 2);
+ String[] instructions = {
+ "This is an AUTOMATIC test, simply wait until it is done.",
+ "The result (passed or failed) will be shown in the",
+ "message window below."
+ };
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ Sysout.createDialog();
+ Sysout.printInstructions(instructions);
+
+ // prepare controls
+
+ frame = new JFrame();
+
+ Panel awtPanel = new Panel();
+ awtPanel.setBackground(Color.GREEN);
+ awtButton = new Button("AWTButton");
+ awtPanel.add(awtButton);
+ awtButton.setForeground(awtColor);
+ awtButton.setBackground(awtColor);
+ jbutton = new JButton("SwingButton");
+ awtPanel.add(jbutton);
+ jbutton.setForeground(jbColor);
+ jbutton.setBackground(jbColor);
+
+ JPanel jPanel = new JPanel();
+ jbutton2 = new JButton("SwingButton2");
+ jPanel.add(jbutton2);
+ jbutton2.setForeground(jb2Color);
+ jbutton2.setBackground(jb2Color);
+ awtButton2 = new Button("AWT Button2");
+ jPanel.add(awtButton2);
+ awtButton2.setForeground(awt2Color);
+ awtButton2.setBackground(awt2Color);
+ jPanel.setBackground(Color.YELLOW);
+
+ frame.add(awtPanel, BorderLayout.SOUTH);
+ frame.add(jPanel, BorderLayout.NORTH);
+
+ frame.pack();
+ frame.setVisible(true);
+ }
+ });
+
+ /////////////////////////
+
+ final Robot robot = Util.createRobot();
+ robot.setAutoDelay(ROBOT_DELAY);
+
+ Util.waitForIdle(robot);
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ lLoc = frame.getLocationOnScreen();
+ lLoc.translate(frame.getWidth() + borderShift, frame.getHeight() + borderShift);
+ }
+ });
+
+ //grow
+ robot.mouseMove(lLoc.x, lLoc.y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+
+ Runnable test = new Runnable() {
+
+ public void run() {
+ Point btnLoc = jbutton.getLocationOnScreen();
+ Color c = robot.getPixelColor(btnLoc.x + 5, btnLoc.y + 5);
+ if (!c.equals(jbColor)) {
+ fail("JButton was not redrawn properly on AWT Panel during move");
+ }
+
+ btnLoc = awtButton.getLocationOnScreen();
+ c = robot.getPixelColor(btnLoc.x + 5, btnLoc.y + 5);
+ if (!c.equals(awtColor)) {
+ fail("AWT Button was not redrawn properly on AWT Panel during move");
+ }
+
+ btnLoc = jbutton2.getLocationOnScreen();
+ c = robot.getPixelColor(btnLoc.x + 5, btnLoc.y + 5);
+ if (!c.equals(jb2Color)) {
+ fail("JButton was not redrawn properly on JPanel during move");
+ }
+
+ btnLoc = awtButton2.getLocationOnScreen();
+ c = robot.getPixelColor(btnLoc.x + 5, btnLoc.y + 5);
+ if (!c.equals(awt2Color)) {
+ fail("ATW Button was not redrawn properly on JPanel during move");
+ }
+ }
+ };
+
+ for (int i = 0; i < 30; i++) {
+ test.run();
+ robot.mouseMove(lLoc.x + 20 * i, lLoc.y + 10 * i);
+ }
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ //back
+ System.out.println("fast back");
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ for (int i = 5; i >= 0; i--) {
+ test.run();
+ robot.mouseMove(lLoc.x + 120 * i, lLoc.y + 60 * i);
+ }
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ pass();
+ }//End init()
+ /*****************************************************
+ * Standard Test Machinery Section
+ * DO NOT modify anything in this section -- it's a
+ * standard chunk of code which has all of the
+ * synchronisation necessary for the test harness.
+ * By keeping it the same in all tests, it is easier
+ * to read and understand someone else's test, as
+ * well as insuring that all tests behave correctly
+ * with the test harness.
+ * There is a section following this for test-
+ * classes
+ ******************************************************/
+ private static boolean theTestPassed = false;
+ private static boolean testGeneratedInterrupt = false;
+ private static String failureMessage = "";
+ private static Thread mainThread = null;
+ private static int sleepTime = 300000;
+
+ // Not sure about what happens if multiple of this test are
+ // instantiated in the same VM. Being static (and using
+ // static vars), it aint gonna work. Not worrying about
+ // it for now.
+ public static void main(String args[]) throws Exception {
+ if (!Toolkit.getDefaultToolkit().isDynamicLayoutActive()) {
+ System.out.println("Dynamic layout is not active. Test passes.");
+ return;
+ }
+ mainThread = Thread.currentThread();
+ try {
+ init();
+ } catch (TestPassedException e) {
+ //The test passed, so just return from main and harness will
+ // interepret this return as a pass
+ return;
+ }
+ //At this point, neither test pass nor test fail has been
+ // called -- either would have thrown an exception and ended the
+ // test, so we know we have multiple threads.
+
+ //Test involves other threads, so sleep and wait for them to
+ // called pass() or fail()
+ try {
+ Thread.sleep(sleepTime);
+ //Timed out, so fail the test
+ throw new RuntimeException("Timed out after " + sleepTime / 1000 + " seconds");
+ } catch (InterruptedException e) {
+ //The test harness may have interrupted the test. If so, rethrow the exception
+ // so that the harness gets it and deals with it.
+ if (!testGeneratedInterrupt) {
+ throw e;
+ }
+
+ //reset flag in case hit this code more than once for some reason (just safety)
+ testGeneratedInterrupt = false;
+
+ if (theTestPassed == false) {
+ throw new RuntimeException(failureMessage);
+ }
+ }
+
+ }//main
+
+ public static synchronized void setTimeoutTo(int seconds) {
+ sleepTime = seconds * 1000;
+ }
+
+ public static synchronized void pass() {
+ Sysout.println("The test passed.");
+ Sysout.println("The test is over, hit Ctl-C to stop Java VM");
+ //first check if this is executing in main thread
+ if (mainThread == Thread.currentThread()) {
+ //Still in the main thread, so set the flag just for kicks,
+ // and throw a test passed exception which will be caught
+ // and end the test.
+ theTestPassed = true;
+ throw new TestPassedException();
+ }
+ theTestPassed = true;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
+ }//pass()
+
+ public static synchronized void fail() {
+ //test writer didn't specify why test failed, so give generic
+ fail("it just plain failed! :-)");
+ }
+
+ public static synchronized void fail(String whyFailed) {
+ Sysout.println("The test failed: " + whyFailed);
+ Sysout.println("The test is over, hit Ctl-C to stop Java VM");
+ //check if this called from main thread
+ if (mainThread == Thread.currentThread()) {
+ //If main thread, fail now 'cause not sleeping
+ throw new RuntimeException(whyFailed);
+ }
+ theTestPassed = false;
+ testGeneratedInterrupt = true;
+ failureMessage = whyFailed;
+ mainThread.interrupt();
+ }//fail()
+}// class JButtonInGlassPane
+class TestPassedException extends RuntimeException {
+}
+
+//*********** End Standard Test Machinery Section **********
+//************ Begin classes defined for the test ****************
+// if want to make listeners, here is the recommended place for them, then instantiate
+// them in init()
+
+/* Example of a class which may be written as part of a test
+class NewClass implements anInterface
+{
+static int newVar = 0;
+
+public void eventDispatched(AWTEvent e)
+{
+//Counting events to see if we get enough
+eventCount++;
+
+if( eventCount == 20 )
+{
+//got enough events, so pass
+
+JButtonInGlassPane.pass();
+}
+else if( tries == 20 )
+{
+//tried too many times without getting enough events so fail
+
+JButtonInGlassPane.fail();
+}
+
+}// eventDispatched()
+
+}// NewClass class
+
+ */
+//************** End classes defined for the test *******************
+/****************************************************
+Standard Test Machinery
+DO NOT modify anything below -- it's a standard
+chunk of code whose purpose is to make user
+interaction uniform, and thereby make it simpler
+to read and understand someone else's test.
+ ****************************************************/
+/**
+This is part of the standard test machinery.
+It creates a dialog (with the instructions), and is the interface
+for sending text messages to the user.
+To print the instructions, send an array of strings to Sysout.createDialog
+WithInstructions method. Put one line of instructions per array entry.
+To display a message for the tester to see, simply call Sysout.println
+with the string to be displayed.
+This mimics System.out.println but works within the test harness as well
+as standalone.
+ */
+class Sysout {
+
+ private static TestDialog dialog;
+
+ public static void createDialogWithInstructions(String[] instructions) {
+ dialog = new TestDialog(new Frame(), "Instructions");
+ dialog.printInstructions(instructions);
+ dialog.setVisible(true);
+ println("Any messages for the tester will display here.");
+ }
+
+ public static void createDialog() {
+ dialog = new TestDialog(new Frame(), "Instructions");
+ String[] defInstr = {"Instructions will appear here. ", ""};
+ dialog.printInstructions(defInstr);
+ dialog.setVisible(true);
+ println("Any messages for the tester will display here.");
+ }
+
+ public static void printInstructions(String[] instructions) {
+ dialog.printInstructions(instructions);
+ }
+
+ public static void println(String messageIn) {
+ dialog.displayMessage(messageIn);
+ System.out.println(messageIn);
+ }
+}// Sysout class
+
+/**
+This is part of the standard test machinery. It provides a place for the
+test instructions to be displayed, and a place for interactive messages
+to the user to be displayed.
+To have the test instructions displayed, see Sysout.
+To have a message to the user be displayed, see Sysout.
+Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog {
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog(Frame frame, String name) {
+ super(frame, name);
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea("", 15, maxStringLength, scrollBoth);
+ add("North", instructionsText);
+
+ messageText = new TextArea("", 5, maxStringLength, scrollBoth);
+ add("Center", messageText);
+
+ pack();
+
+ setVisible(true);
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions(String[] instructions) {
+ //Clear out any current instructions
+ instructionsText.setText("");
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for (int i = 0; i < instructions.length; i++) {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[i];
+ while (remainingStr.length() > 0) {
+ //if longer than max then chop off first max chars to print
+ if (remainingStr.length() >= maxStringLength) {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.lastIndexOf(' ', maxStringLength - 1);
+
+ if (posOfSpace <= 0) {
+ posOfSpace = maxStringLength - 1;
+ }
+
+ printStr = remainingStr.substring(0, posOfSpace + 1);
+ remainingStr = remainingStr.substring(posOfSpace + 1);
+ } //else just print
+ else {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append(printStr + "\n");
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage(String messageIn) {
+ messageText.append(messageIn + "\n");
+ System.out.println(messageIn);
+ }
+}// TestDialog class
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/OpaqueOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,164 @@
+/*
+ * 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 com.sun.awt.AWTUtilities;
+import java.awt.Frame;
+import java.awt.Panel;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import javax.swing.JButton;
+import javax.swing.SwingUtilities;
+
+/**
+ * AWT/Swing overlapping test for opaque Swing components.
+ * <p>This test verify if AWT components are drawn correctly under opaque components.
+ * <p>See <a href="https://bugs.openjdk.java.net/browse/JDK-6776743">JDK-6776743</a> for details
+ * <p>See base class for test info.
+ */
+/*
+@test
+@bug 6776743
+@summary Opaque overlapping test for each AWT component
+@run main OpaqueOverlapping
+ */
+public class OpaqueOverlapping extends OverlappingTestBase {
+
+ {
+ useClickValidation = false;
+ failMessage = "Opacity test mismatchs";
+
+ // CR 6994264 (Choice autohides dropdown on Solaris 10)
+ skipClassNames = new String[] { "Choice" };
+ }
+ private String testSeq;
+ private final static String checkSeq = "010000101";
+ private Point heavyLoc;
+ private JButton light;
+ private Frame frame = null;
+
+ protected void prepareControls() {
+ testSeq = "";
+ // Create components
+ if(frame != null) {
+ frame.setVisible(false);
+ }
+ frame = new Frame("OpaqueOverlapping mixing test");
+ final Panel panel = new Panel();
+ panel.setLayout(null);
+
+ propagateAWTControls(panel);
+
+ // Overlap the buttons
+ currentAwtControl.setBounds(30, 30, 200, 200);
+
+ light = new JButton(" LW Button ");
+ light.setBounds(10, 10, 50, 50);
+
+ // Put the components into the frame
+ panel.add(light);
+ frame.add(panel);
+ frame.setBounds(50, 50, 400, 400);
+ frame.setVisible(true);
+
+ currentAwtControl.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ panel.setComponentZOrder(light, 0);
+ frame.validate();
+ testSeq = testSeq + "0";
+ }
+ });
+ light.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
+ panel.setComponentZOrder(currentAwtControl, 0);
+ frame.validate();
+ testSeq = testSeq + "1";
+ }
+ });
+ }
+
+ @Override
+ protected boolean performTest() {
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ heavyLoc = currentAwtControl.getLocationOnScreen();
+ }
+ });
+ } catch (Exception e) {
+ }
+ Robot robot = Util.createRobot();
+ robot.setAutoDelay(ROBOT_DELAY);
+
+ Util.waitForIdle(robot);
+
+ // Move the mouse pointer to the position where both
+ // components overlap
+ robot.mouseMove(heavyLoc.x + 5, heavyLoc.y + 5);
+
+ // Now perform the click at this point for 9 times
+ // In the middle of the process toggle the opaque
+ // flag value.
+ for (int i = 0; i < 9; ++i) {
+ if (i == 3) {
+ AWTUtilities.setComponentMixingCutoutShape(light,
+ new Rectangle());
+ }
+ if (i == 6) {
+ AWTUtilities.setComponentMixingCutoutShape(light,
+ null);
+ }
+
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ Util.waitForIdle(robot);
+
+ if (currentAwtControl.getClass() == java.awt.Choice.class && i != 1 && i != 6 && i != 8) {
+ // due to the fact that Choice doesn't get mouseClicked event if its dropdown is shown
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ Util.waitForIdle(robot);
+ }
+ }
+
+ Util.waitForIdle(robot);
+
+ boolean result = testSeq.equals(checkSeq);
+ if (!result) {
+ System.err.println("Expected: " + checkSeq);
+ System.err.println("Observed: " + testSeq);
+ }
+ return result;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new OpaqueOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/OpaqueOverlappingChoice.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+
+/**
+ * AWT/Swing overlapping test for opaque Choice.
+ *
+ * This test case was separated from {@link OpaqueOverlapping} due to CR 6994264 (Choice autohides dropdown on Solaris 10)
+ */
+/*
+@test
+@bug 6994264
+@summary Opaque overlapping test for Choice AWT component
+@run main OpaqueOverlappingChoice
+ */
+public class OpaqueOverlappingChoice extends OpaqueOverlapping {
+ {
+ onlyClassName = "Choice";
+ skipClassNames = null;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new OpaqueOverlappingChoice();
+ OverlappingTestBase.doMain(args);
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/OverlappingTestBase.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,800 @@
+/*
+ * 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.*;
+import java.awt.event.*;
+import java.awt.peer.ComponentPeer;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import javax.swing.*;
+import sun.awt.*;
+import java.io.*;
+
+/**
+ * <p>This class provides basis for AWT Mixing testing.
+ * <p>It provides all standard test machinery and should be used by
+ * extending and overriding next methods:
+ * <li> {@link OverlappingTestBase#prepareControls()} - setup UI components
+ * <li> {@link OverlappingTestBase#performTest()} - run particular test
+ * Those methods would be run in the loop for each AWT component.
+ * <p>Current AWT component should be added to the tested UI by {@link OverlappingTestBase#propagateAWTControls(java.awt.Container) ()}.
+ * There AWT components are prepared to be tested as being overlayed by other (e.g. Swing) components - they are colored to
+ * {@link OverlappingTestBase#AWT_BACKGROUND_COLOR} and throws failure on catching mouse event.
+ * <p> Validation of component being overlayed should be tested by {@link OverlappingTestBase#clickAndBlink(java.awt.Robot, java.awt.Point) }
+ * See each method javadoc for more details.
+ *
+ * <p>Due to test machinery limitations all test should be run from their own main() by calling next coe
+ * <code>
+ * public static void main(String args[]) throws InterruptedException {
+ * instance = new YourTestInstance();
+ * OverlappingTestBase.doMain(args);
+ * }
+ * </code>
+ *
+ * @author Sergey Grinev
+ */
+public abstract class OverlappingTestBase {
+ // working variables
+ private static volatile boolean wasHWClicked = false;
+ private static volatile boolean passed = true;
+ // constants
+ /**
+ * Default color for AWT component used for validate correct drawing of overlapping. <b>Never</b> use it for lightweight components.
+ */
+ protected static final Color AWT_BACKGROUND_COLOR = new Color(21, 244, 54);
+ protected static Color AWT_VERIFY_COLOR = AWT_BACKGROUND_COLOR;
+ protected static final int ROBOT_DELAY = 500;
+ private static final String[] simpleAwtControls = {"Button", "Checkbox", "Label", "TextArea"};
+ /**
+ * Generic strings array. To be used for population of List based controls.
+ */
+ protected static final String[] petStrings = {"Bird", "Cat", "Dog", "Rabbit", "Rhynocephalia Granda", "Bear", "Tiger", "Mustang"};
+ // "properties"
+ /**
+ * Tests customization. Set this variable to test only control from java.awt
+ * <p>Usage of this variable should be marked with CR being the reason.
+ * <p>Do not use this variable simultaneously with {@link OverlappingTestBase#skipClassNames}
+ */
+ protected String onlyClassName = null;
+ /**
+ * For customizing tests. List classes' simple names to skip them from testings.
+ * <p>Usage of this variable should be marked with CR being the reason.
+ */
+ protected String[] skipClassNames = null;
+ /**
+ * Set to false to avoid event delivery validation
+ * @see OverlappingTestBase#clickAndBlink(java.awt.Robot, java.awt.Point, boolean)
+ */
+ protected boolean useClickValidation = true;
+ /**
+ * Set to false if test doesn't supposed to verify EmbeddedFrame
+ */
+ protected boolean testEmbeddedFrame = false;
+ /**
+ * Set this variable to true if testing embedded frame is impossible (on Mac, for instance, for now).
+ * The testEmbeddedFrame is explicitly set to true in dozen places.
+ */
+ protected boolean skipTestingEmbeddedFrame = false;
+
+ public static final boolean isMac = System.getProperty("os.name").toLowerCase().contains("os x");
+ private boolean isFrameBorderCalculated;
+ private int borderShift;
+
+ { if (Toolkit.getDefaultToolkit().getClass().getName().matches(".*L.*Toolkit")) {
+ // No EmbeddedFrame in LWToolkit/LWCToolkit, yet
+ // And it should be programmed some other way, too, in any case
+ System.err.println("skipTestingEmbeddedFrame");
+ skipTestingEmbeddedFrame = true;
+ }else {
+ System.err.println("do not skipTestingEmbeddedFrame");
+ }
+ }
+
+ protected int frameBorderCounter() {
+ if (!isFrameBorderCalculated) {
+ try {
+ new FrameBorderCounter(); // force compilation by jtreg
+ String JAVA_HOME = System.getProperty("java.home");
+ Process p = Runtime.getRuntime().exec(JAVA_HOME + "/bin/java FrameBorderCounter");
+ try {
+ p.waitFor();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ if (p.exitValue() != 0) {
+ throw new RuntimeException("FrameBorderCounter exited with not null code!\n" + readInputStream(p.getErrorStream()));
+ }
+ borderShift = Integer.parseInt(readInputStream(p.getInputStream()).trim());
+ isFrameBorderCalculated = true;
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+ return borderShift;
+ }
+
+ public void getVerifyColor() {
+ try {
+ final int size = 200;
+ final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ final Point[] p = new Point[1];
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run(){
+ JFrame frame = new JFrame("set back");
+ frame.getContentPane().setBackground(AWT_BACKGROUND_COLOR);
+ frame.setSize(size, size);
+ frame.setUndecorated(true);
+ frame.setVisible(true);
+ frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+ p[0] = frame.getLocation();
+ }
+ });
+ Robot robot = new Robot();
+ toolkit.realSync();
+ Thread.sleep(ROBOT_DELAY);
+ AWT_VERIFY_COLOR = robot.getPixelColor(p[0].x+size/2, p[0].y+size/2);
+ System.out.println("Color will be compared with " + AWT_VERIFY_COLOR + " instead of " + AWT_BACKGROUND_COLOR);
+ } catch (Exception e) {
+ System.err.println("Cannot get verify color: "+e.getMessage());
+ }
+ }
+
+ private String readInputStream(InputStream is) throws IOException {
+ byte[] buffer = new byte[4096];
+ int len = 0;
+ StringBuilder sb = new StringBuilder();
+ try (InputStreamReader isr = new InputStreamReader(is)) {
+ while ((len = is.read(buffer)) > 0) {
+ sb.append(new String(buffer, 0, len));
+ }
+ }
+ return sb.toString();
+ }
+
+ private void setupControl(final Component control) {
+ if (useClickValidation) {
+ control.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ System.err.println("ERROR: " + control.getClass() + " received mouse click.");
+ wasHWClicked = true;
+ }
+ });
+ }
+ control.setBackground(AWT_BACKGROUND_COLOR);
+ control.setForeground(AWT_BACKGROUND_COLOR);
+ control.setPreferredSize(new Dimension(150, 150));
+ control.setFocusable(false);
+ }
+
+ private void addAwtControl(java.util.List<Component> container, final Component control) {
+ String simpleName = control.getClass().getSimpleName();
+ if (onlyClassName != null && !simpleName.equals(onlyClassName)) {
+ return;
+ }
+ if (skipClassNames != null) {
+ for (String skipMe : skipClassNames) {
+ if (simpleName.equals(skipMe)) {
+ return;
+ }
+ }
+ }
+ setupControl(control);
+ container.add(control);
+ }
+
+ private void addSimpleAwtControl(java.util.List<Component> container, String className) {
+ try {
+ Class definition = Class.forName("java.awt." + className);
+ Constructor constructor = definition.getConstructor(new Class[]{String.class});
+ java.awt.Component component = (java.awt.Component) constructor.newInstance(new Object[]{"AWT Component " + className});
+ addAwtControl(container, component);
+ } catch (Exception ex) {
+ System.err.println(ex.getMessage());
+ fail("Setup error, this jdk doesn't have awt conrol " + className);
+ }
+ }
+
+ /**
+ * Adds current AWT control to container
+ * <p>N.B.: if testEmbeddedFrame == true this method will also add EmbeddedFrame over Canvas
+ * and it should be called <b>after</b> Frame.setVisible(true) call
+ * @param container container to hold AWT component
+ */
+ protected final void propagateAWTControls(Container container) {
+ if (currentAwtControl != null) {
+ container.add(currentAwtControl);
+ } else { // embedded frame
+ try {
+
+ //create embedder
+ Canvas embedder = new Canvas();
+ embedder.setBackground(Color.RED);
+ embedder.setPreferredSize(new Dimension(150, 150));
+ container.add(embedder);
+ container.setVisible(true); // create peer
+
+ long frameWindow = 0;
+ String getWindowMethodName = "getHWnd";
+ if (Toolkit.getDefaultToolkit().getClass().getName().contains("XToolkit")) {
+ getWindowMethodName = "getWindow";
+ }
+ ComponentPeer peer = embedder.getPeer();
+// System.err.println("Peer: " + peer);
+ Method getWindowMethod = peer.getClass().getMethod(getWindowMethodName);
+ frameWindow = (Long) getWindowMethod.invoke(peer);
+// System.err.println("frame peer ID: " + frameWindow);
+
+ String eframeClassName = "sun.awt.windows.WEmbeddedFrame";
+ if (Toolkit.getDefaultToolkit().getClass().getName().contains("XToolkit")) {
+ eframeClassName = "sun.awt.X11.XEmbeddedFrame";
+ }
+ Class eframeClass = Class.forName(eframeClassName);
+ Constructor eframeCtor = eframeClass.getConstructor(long.class);
+ EmbeddedFrame eframe = (EmbeddedFrame) eframeCtor.newInstance(frameWindow);
+ setupControl(eframe);
+ eframe.setSize(new Dimension(150, 150));
+ eframe.setVisible(true);
+// System.err.println(eframe.getSize());
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ fail("Failed to instantiate EmbeddedFrame: " + ex.getMessage());
+ }
+ }
+ }
+ private static final Font hugeFont = new Font("Arial", Font.BOLD, 70);
+
+ private java.util.List<Component> getAWTControls() {
+ java.util.List<Component> components = new ArrayList<Component>();
+
+ for (String clazz : simpleAwtControls) {
+ addSimpleAwtControl(components, clazz);
+ }
+
+ TextField tf = new TextField();
+ tf.setFont(hugeFont);
+ addAwtControl(components, tf);
+
+ // more complex controls
+ Choice c = new Choice();
+ for (int i = 0; i < petStrings.length; i++) {
+ c.add(petStrings[i]);
+ }
+ addAwtControl(components, c);
+ c.setPreferredSize(null);
+ c.setFont(hugeFont); // to make control bigger as setPrefferedSize don't do his job here
+
+ List l = new List(petStrings.length);
+ for (int i = 0; i < petStrings.length; i++) {
+ l.add(petStrings[i]);
+ }
+ addAwtControl(components, l);
+
+ Canvas canvas = new Canvas();
+ canvas.setSize(100, 200);
+ addAwtControl(components, canvas);
+
+ Scrollbar sb = new Scrollbar(Scrollbar.VERTICAL, 500, 1, 0, 500);
+ addAwtControl(components, sb);
+
+ Scrollbar sb2 = new Scrollbar(Scrollbar.HORIZONTAL, 500, 1, 0, 500);
+ addAwtControl(components, sb2);
+
+ return components;
+ }
+ /**
+ * Default shift for {@link OverlappingTestBase#clickAndBlink(java.awt.Robot, java.awt.Point) }
+ */
+ protected static Point shift = new Point(16, 16);
+
+ /**
+ * Verifies point using specified AWT Robot. Supposes <code>defaultShift == true</code> for {@link OverlappingTestBase#clickAndBlink(java.awt.Robot, java.awt.Point, boolean) }.
+ * This method is used to verify controls by providing just their plain screen coordinates.
+ * @param robot AWT Robot. Usually created by {@link Util#createRobot() }
+ * @param lLoc point to verify
+ * @see OverlappingTestBase#clickAndBlink(java.awt.Robot, java.awt.Point, boolean)
+ */
+ protected void clickAndBlink(Robot robot, Point lLoc) {
+ clickAndBlink(robot, lLoc, true);
+ }
+ /**
+ * Default failure message for color check
+ * @see OverlappingTestBase#performTest()
+ */
+ protected String failMessageColorCheck = "The LW component did not pass pixel color check and is overlapped";
+ /**
+ * Default failure message event check
+ * @see OverlappingTestBase#performTest()
+ */
+ protected String failMessage = "The LW component did not received the click.";
+
+ private static boolean isValidForPixelCheck(Component component) {
+ if ((component instanceof java.awt.Scrollbar) || isMac && (component instanceof java.awt.Button)) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Preliminary validation - should be run <b>before</b> overlapping happens to ensure test is correct.
+ * @param robot AWT Robot. Usually created by {@link Util#createRobot() }
+ * @param lLoc point to validate to be <b>of</b> {@link OverlappingTestBase#AWT_BACKGROUND_COLOR}
+ * @param component tested component, should be pointed out as not all components are valid for pixel check.
+ */
+ protected void pixelPreCheck(Robot robot, Point lLoc, Component component) {
+ if (isValidForPixelCheck(component)) {
+ int tries = 10;
+ Color c = null;
+ while (tries-- > 0) {
+ c = robot.getPixelColor(lLoc.x, lLoc.y);
+ System.out.println("Precheck. color: "+c+" compare with "+AWT_VERIFY_COLOR);
+ if (c.equals(AWT_VERIFY_COLOR)) {
+ return;
+ }
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ }
+ }
+ System.err.println(lLoc + ": " + c);
+ fail("Dropdown test setup failure, colored part of AWT component is not located at click area");
+ }
+ }
+
+ /**
+ * Verifies point using specified AWT Robot.
+ * <p>Firstly, verifies point by color pixel check
+ * <p>Secondly, verifies event delivery by mouse click
+ * @param robot AWT Robot. Usually created by {@link Util#createRobot() }
+ * @param lLoc point to verify
+ * @param defaultShift if true verified position will be shifted by {@link OverlappingTestBase#shift }.
+ */
+ protected void clickAndBlink(Robot robot, Point lLoc, boolean defaultShift) {
+ Point loc = lLoc.getLocation();
+ //check color
+ Util.waitForIdle(robot);
+ try{
+ Thread.sleep(500);
+ }catch(Exception exx){
+ exx.printStackTrace();
+ }
+
+ if (defaultShift) {
+ loc.translate(shift.x, shift.y);
+ }
+ if (!(System.getProperty("os.name").toLowerCase().contains("os x"))) {
+ Color c = robot.getPixelColor(loc.x, loc.y);
+ System.out.println("C&B. color: "+c+" compare with "+AWT_VERIFY_COLOR);
+ if (c.equals(AWT_VERIFY_COLOR)) {
+ fail(failMessageColorCheck);
+ passed = false;
+ }
+
+ // perform click
+ Util.waitForIdle(robot);
+ }
+
+ robot.mouseMove(loc.x, loc.y);
+
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ Util.waitForIdle(robot);
+ }
+
+ /**
+ * This method should be overriden with code which setups UI for testing.
+ * Code in this method <b>will</b> be called only from AWT thread so Swing operations can be called directly.
+ *
+ * @see {@link OverlappingTestBase#propagateAWTControls(java.awt.Container) } for instructions about adding tested AWT control to UI
+ */
+ protected abstract void prepareControls();
+
+ /**
+ * This method should be overriden with test execution. It will <b>not</b> be called from AWT thread so all Swing operations should be treated accordingly.
+ * @return true if test passed. Otherwise fail with default fail message.
+ * @see {@link OverlappingTestBase#failMessage} default fail message
+ */
+ protected abstract boolean performTest();
+ /**
+ * This method can be overriden with cleanup routines. It will be called from AWT thread so all Swing operations should be treated accordingly.
+ */
+ protected void cleanup() {
+ // intentionally do nothing
+ }
+ /**
+ * Currect tested AWT Control. Usually shouldn't be accessed directly.
+ *
+ * @see {@link OverlappingTestBase#propagateAWTControls(java.awt.Container) } for instructions about adding tested AWT control to UI
+ */
+ protected Component currentAwtControl;
+
+ private void testComponent(Component component) throws InterruptedException, InvocationTargetException {
+ currentAwtControl = component;
+ System.out.println("Testing " + currentAwtControl.getClass().getSimpleName());
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ prepareControls();
+ }
+ });
+ if (component != null) {
+ Util.waitTillShown(component);
+ }
+ Util.waitForIdle(null);
+ try {
+ Thread.sleep(500); // wait for graphic effects on systems like Win7
+ } catch (InterruptedException ex) {
+ }
+ if (!instance.performTest()) {
+ fail(failMessage);
+ passed = false;
+ }
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ cleanup();
+ }
+ });
+ }
+
+ private void testEmbeddedFrame() throws InvocationTargetException, InterruptedException {
+ System.out.println("Testing EmbeddedFrame");
+ currentAwtControl = null;
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ prepareControls();
+ }
+ });
+ Util.waitForIdle(null);
+ try {
+ Thread.sleep(500); // wait for graphic effects on systems like Win7
+ } catch (InterruptedException ex) {
+ }
+ if (!instance.performTest()) {
+ fail(failMessage);
+ passed = false;
+ }
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ cleanup();
+ }
+ });
+ }
+
+ private void testAwtControls() throws InterruptedException {
+ try {
+ for (Component component : getAWTControls()) {
+ testComponent(component);
+ }
+ if (testEmbeddedFrame && !skipTestingEmbeddedFrame) {
+ testEmbeddedFrame();
+ }
+ } catch (InvocationTargetException ex) {
+ ex.printStackTrace();
+ fail(ex.getMessage());
+ }
+ }
+ /**
+ * Used by standard test machinery. See usage at {@link OverlappingTestBase }
+ */
+ protected static OverlappingTestBase instance;
+
+ protected OverlappingTestBase() {
+ getVerifyColor();
+ }
+
+ /*****************************************************
+ * Standard Test Machinery Section
+ * DO NOT modify anything in this section -- it's a
+ * standard chunk of code which has all of the
+ * synchronisation necessary for the test harness.
+ * By keeping it the same in all tests, it is easier
+ * to read and understand someone else's test, as
+ * well as insuring that all tests behave correctly
+ * with the test harness.
+ * There is a section following this for test-
+ * classes
+ ******************************************************/
+ private static void init() throws InterruptedException {
+ //*** Create instructions for the user here ***
+ //System.setProperty("sun.awt.disableMixing", "true");
+
+ String[] instructions = {
+ "This is an AUTOMATIC test, simply wait until it is done.",
+ "The result (passed or failed) will be shown in the",
+ "message window below."
+ };
+ Sysout.createDialog();
+ Sysout.printInstructions(instructions);
+
+ instance.testAwtControls();
+
+ if (wasHWClicked) {
+ fail("HW component received the click.");
+ passed = false;
+ }
+ if (passed) {
+ pass();
+ }
+ }//End init()
+ private static boolean theTestPassed = false;
+ private static boolean testGeneratedInterrupt = false;
+ private static String failureMessage = "";
+ private static Thread mainThread = null;
+ private static int sleepTime = 300000;
+
+ // Not sure about what happens if multiple of this test are
+ // instantiated in the same VM. Being static (and using
+ // static vars), it aint gonna work. Not worrying about
+ // it for now.
+ /**
+ * Starting point for test runs. See usage at {@link OverlappingTestBase }
+ * @param args regular main args, not used.
+ * @throws InterruptedException
+ */
+ public static void doMain(String args[]) throws InterruptedException {
+ mainThread = Thread.currentThread();
+ try {
+ init();
+ } catch (TestPassedException e) {
+ //The test passed, so just return from main and harness will
+ // interepret this return as a pass
+ return;
+ }
+ //At this point, neither test pass nor test fail has been
+ // called -- either would have thrown an exception and ended the
+ // test, so we know we have multiple threads.
+
+ //Test involves other threads, so sleep and wait for them to
+ // called pass() or fail()
+ try {
+ Thread.sleep(sleepTime);
+ //Timed out, so fail the test
+ throw new RuntimeException("Timed out after " + sleepTime / 1000 + " seconds");
+ } catch (InterruptedException e) {
+ //The test harness may have interrupted the test. If so, rethrow the exception
+ // so that the harness gets it and deals with it.
+ if (!testGeneratedInterrupt) {
+ throw e;
+ }
+
+ //reset flag in case hit this code more than once for some reason (just safety)
+ testGeneratedInterrupt = false;
+
+ if (theTestPassed == false) {
+ throw new RuntimeException(failureMessage);
+ }
+ }
+
+ }//main
+
+ /**
+ * Test will fail if not passed after this timeout. Default timeout is 300 seconds.
+ * @param seconds timeout in seconds
+ */
+ public static synchronized void setTimeoutTo(int seconds) {
+ sleepTime = seconds * 1000;
+ }
+
+ /**
+ * Set test as passed. Usually shoudn't be called directly.
+ */
+ public static synchronized void pass() {
+ Sysout.println("The test passed.");
+ Sysout.println("The test is over, hit Ctl-C to stop Java VM");
+ //first check if this is executing in main thread
+ if (mainThread == Thread.currentThread()) {
+ //Still in the main thread, so set the flag just for kicks,
+ // and throw a test passed exception which will be caught
+ // and end the test.
+ theTestPassed = true;
+ throw new TestPassedException();
+ }
+ theTestPassed = true;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
+ }//pass()
+
+ /**
+ * Fail test generic message.
+ */
+ public static synchronized void fail() {
+ //test writer didn't specify why test failed, so give generic
+ fail("it just plain failed! :-)");
+ }
+
+ /**
+ * Fail test providing specific reason.
+ * @param whyFailed reason
+ */
+ public static synchronized void fail(String whyFailed) {
+ Sysout.println("The test failed: " + whyFailed);
+ Sysout.println("The test is over, hit Ctl-C to stop Java VM");
+ //check if this called from main thread
+ if (mainThread == Thread.currentThread()) {
+ //If main thread, fail now 'cause not sleeping
+ throw new RuntimeException(whyFailed);
+ }
+ theTestPassed = false;
+ testGeneratedInterrupt = true;
+ failureMessage = whyFailed;
+ mainThread.interrupt();
+ }//fail()
+}// class LWComboBox
+class TestPassedException extends RuntimeException {
+}
+
+//*********** End Standard Test Machinery Section **********
+//************ Begin classes defined for the test ****************
+// if want to make listeners, here is the recommended place for them, then instantiate
+// them in init()
+
+/* Example of a class which may be written as part of a test
+class NewClass implements anInterface
+{
+static int newVar = 0;
+
+public void eventDispatched(AWTEvent e)
+{
+//Counting events to see if we get enough
+eventCount++;
+
+if( eventCount == 20 )
+{
+//got enough events, so pass
+
+LWComboBox.pass();
+}
+else if( tries == 20 )
+{
+//tried too many times without getting enough events so fail
+
+LWComboBox.fail();
+}
+
+}// eventDispatched()
+
+}// NewClass class
+
+ */
+//************** End classes defined for the test *******************
+/****************************************************
+Standard Test Machinery
+DO NOT modify anything below -- it's a standard
+chunk of code whose purpose is to make user
+interaction uniform, and thereby make it simpler
+to read and understand someone else's test.
+ ****************************************************/
+/**
+This is part of the standard test machinery.
+It creates a dialog (with the instructions), and is the interface
+for sending text messages to the user.
+To print the instructions, send an array of strings to Sysout.createDialog
+WithInstructions method. Put one line of instructions per array entry.
+To display a message for the tester to see, simply call Sysout.println
+with the string to be displayed.
+This mimics System.out.println but works within the test harness as well
+as standalone.
+ */
+class Sysout {
+ private static TestDialog dialog;
+
+ public static void createDialogWithInstructions(String[] instructions) {
+ dialog = new TestDialog(new Frame(), "Instructions");
+ dialog.printInstructions(instructions);
+ //dialog.setVisible(true);
+ println("Any messages for the tester will display here.");
+ }
+
+ public static void createDialog() {
+ dialog = new TestDialog(new Frame(), "Instructions");
+ String[] defInstr = {"Instructions will appear here. ", ""};
+ dialog.printInstructions(defInstr);
+ //dialog.setVisible(true);
+ println("Any messages for the tester will display here.");
+ }
+
+ public static void printInstructions(String[] instructions) {
+ dialog.printInstructions(instructions);
+ }
+
+ public static void println(String messageIn) {
+ dialog.displayMessage(messageIn);
+ System.out.println(messageIn);
+ }
+}// Sysout class
+
+/**
+This is part of the standard test machinery. It provides a place for the
+test instructions to be displayed, and a place for interactive messages
+to the user to be displayed.
+To have the test instructions displayed, see Sysout.
+To have a message to the user be displayed, see Sysout.
+Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog {
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog(Frame frame, String name) {
+ super(frame, name);
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea("", 15, maxStringLength, scrollBoth);
+ add("North", instructionsText);
+
+ messageText = new TextArea("", 5, maxStringLength, scrollBoth);
+ add("Center", messageText);
+
+ pack();
+
+ //setVisible(true);
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions(String[] instructions) {
+ //Clear out any current instructions
+ instructionsText.setText("");
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for (int i = 0; i < instructions.length; i++) {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[i];
+ while (remainingStr.length() > 0) {
+ //if longer than max then chop off first max chars to print
+ if (remainingStr.length() >= maxStringLength) {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.lastIndexOf(' ', maxStringLength - 1);
+
+ if (posOfSpace <= 0) {
+ posOfSpace = maxStringLength - 1;
+ }
+
+ printStr = remainingStr.substring(0, posOfSpace + 1);
+ remainingStr = remainingStr.substring(posOfSpace + 1);
+ } //else just print
+ else {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append(printStr + "\n");
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage(String messageIn) {
+ messageText.append(messageIn + "\n");
+ System.out.println(messageIn);
+ }
+}// TestDialog class
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/SimpleOverlappingTestBase.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,160 @@
+/*
+ * 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.*;
+import java.awt.event.*;
+import javax.swing.*;
+
+/**
+ * Base class for testing overlapping of Swing and AWT component put into one frame.
+ * Validates drawing and event delivery at the components intersection.
+ * <p> See base class for usage
+ *
+ * @author Sergey Grinev
+*/
+public abstract class SimpleOverlappingTestBase extends OverlappingTestBase {
+
+ {
+ testEmbeddedFrame = true;
+ }
+
+ /**
+ * Event delivery validation. If set to true (default) tested lightweight component will be provided
+ * with mouse listener which should be called in order for test to pass.
+ */
+ protected final boolean useDefaultClickValidation;
+
+ /**
+ * Constructor which sets {@link SimpleOverlappingTestBase#useDefaultClickValidation }
+ * @param defaultClickValidation
+ */
+ protected SimpleOverlappingTestBase(boolean defaultClickValidation) {
+ super();
+ this.useDefaultClickValidation = defaultClickValidation;
+ }
+
+ public SimpleOverlappingTestBase() {
+ this(true);
+ }
+
+ //overridables
+ /**
+ * Successors override this method providing swing component for testing
+ * @return swing component to test
+ */
+ protected abstract JComponent getSwingComponent();
+
+ /**
+ * For tests debugging. Please, ignore.
+ */
+ protected static final boolean debug = false;
+
+ /**
+ * Should be set to true if test isn't using {@link SimpleOverlappingTestBase#useDefaultClickValidation }
+ */
+ protected volatile boolean wasLWClicked = false;
+
+ /**
+ * Current tested lightweight component
+ * @see SimpleOverlappingTestBase#getSwingComponent()
+ */
+ protected JComponent testedComponent;
+
+ /**
+ * Setups simple frame with lightweight component returned by {@link SimpleOverlappingTestBase#getSwingComponent() }
+ * Called by base class.
+ */
+ protected void prepareControls() {
+ wasLWClicked = false;
+
+ final JFrame f = new JFrame("Mixing : Simple Overlapping test");
+ f.setLayout(new SpringLayout());
+ f.setSize(200, 200);
+
+ testedComponent = getSwingComponent();
+
+ if (useDefaultClickValidation) {
+ testedComponent.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ wasLWClicked = true;
+ f.setVisible(false);
+ }
+ });
+ }
+
+ if (!debug) {
+ f.add(testedComponent);
+ } else {
+ System.err.println("Warning: DEBUG MODE");
+ }
+
+ propagateAWTControls(f);
+
+ f.setVisible(true);
+ }
+
+ /**
+ * AWT Robot instance. Shouldn't be used in most cases.
+ */
+ protected Robot robot;
+
+ /**
+ * Run test by {@link OverlappingTestBase#clickAndBlink(java.awt.Robot, java.awt.Point) } validation for current lightweight component.
+ * <p>Called by base class.
+ * @return true if test passed
+ */
+ protected boolean performTest() {
+ testedComponent.requestFocus();
+
+ // run robot
+ robot = Util.createRobot();
+ robot.setAutoDelay(20);
+
+ // get coord
+ Point lLoc = !debug ? testedComponent.getLocationOnScreen() : new Point(70, 30);
+ Util.waitForIdle(null);
+ /* this is a workaround for certain jtreg(?) focus issue:
+ tests fail starting after failing mixing tests but always pass alone.
+ */
+ JFrame ancestor = (JFrame)(testedComponent.getTopLevelAncestor());
+ if( ancestor != null ) {
+ Point ancestorLoc = ancestor.getLocationOnScreen();
+ ancestorLoc.translate(ancestor.getWidth()/2-15, 2);
+ robot.mouseMove(ancestorLoc.x, ancestorLoc.y);
+ Util.waitForIdle(robot);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(50);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ Util.waitForIdle(robot);
+ }
+
+ clickAndBlink(robot, lLoc);
+ Util.waitForIdle(null);
+
+ return wasLWClicked;
+ }
+
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/Util.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,601 @@
+/*
+ * 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.Component;
+import java.awt.Frame;
+import java.awt.Dialog;
+import java.awt.Window;
+import java.awt.Button;
+import java.awt.Point;
+import java.awt.Dimension;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import java.awt.IllegalComponentStateException;
+import java.awt.AWTException;
+import java.awt.AWTEvent;
+
+import java.awt.event.InputEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.event.ActionEvent;
+import java.awt.event.FocusEvent;
+import java.awt.event.WindowListener;
+import java.awt.event.WindowFocusListener;
+import java.awt.event.FocusListener;
+import java.awt.event.ActionListener;
+
+import java.awt.peer.FramePeer;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import java.security.PrivilegedAction;
+import java.security.AccessController;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * <p>This class contains utilities useful for regression testing.
+ * <p>When using jtreg you would include this class into the build
+ * list via something like:
+ * <pre>
+ &library ../../../../share/lib/AWT_Mixing/src/regtesthelpers/
+ &build Util
+ &run main YourTest
+ </pre>
+ * Note that if you are about to create a test based on
+ * Applet-template, then put those lines into html-file, not in java-file.
+ * <p> And put an
+ * import regtesthelpers.Util;
+ * into the java source of test.
+*/
+public final class Util {
+ private Util() {} // this is a helper class with static methods :)
+
+ /*
+ * @throws RuntimeException when creation failed
+ */
+ public static Robot createRobot() {
+ try {
+ return new Robot();
+ } catch (AWTException e) {
+ throw new RuntimeException("Error: unable to create robot", e);
+ }
+ }
+
+ public static Frame createEmbeddedFrame(final Frame embedder)
+ throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException, NoSuchMethodException,
+ InstantiationException, InvocationTargetException
+ {
+ Toolkit tk = Toolkit.getDefaultToolkit();
+ FramePeer frame_peer = (FramePeer) embedder.getPeer();
+ System.out.println("frame's peer = " + frame_peer);
+ if ("sun.awt.windows.WToolkit".equals(tk.getClass().getName())) {
+ Class comp_peer_class =
+ Class.forName("sun.awt.windows.WComponentPeer");
+ System.out.println("comp peer class = " + comp_peer_class);
+ Field hwnd_field = comp_peer_class.getDeclaredField("hwnd");
+ hwnd_field.setAccessible(true);
+ System.out.println("hwnd_field =" + hwnd_field);
+ long hwnd = hwnd_field.getLong(frame_peer);
+ System.out.println("hwnd = " + hwnd);
+
+ Class clazz = Class.forName("sun.awt.windows.WEmbeddedFrame");
+ Constructor constructor = clazz.getConstructor (new Class [] {Long.TYPE});
+ return (Frame) constructor.newInstance (new Object[] {hwnd});
+ } else if ("sun.awt.X11.XToolkit".equals(tk.getClass().getName())) {
+ Class x_base_window_class = Class.forName("sun.awt.X11.XBaseWindow");
+ System.out.println("x_base_window_class = " + x_base_window_class);
+ Method get_window = x_base_window_class.getMethod("getWindow", new Class[0]);
+ System.out.println("get_window = " + get_window);
+ long window = (Long) get_window.invoke(frame_peer, new Object[0]);
+ System.out.println("window = " + window);
+ Class clazz = Class.forName("sun.awt.X11.XEmbeddedFrame");
+ Constructor constructor = clazz.getConstructor (new Class [] {Long.TYPE, Boolean.TYPE});
+ return (Frame) constructor.newInstance (new Object[] {window, true});
+ }
+
+ throw new RuntimeException("Unexpected toolkit - " + tk);
+ }
+
+ /**
+ * Makes the window visible and waits until it's shown.
+ */
+ public static void showWindowWait(Window win) {
+ win.setVisible(true);
+ waitTillShown(win);
+ }
+
+ /**
+ * Moves mouse pointer in the center of given {@code comp} component
+ * using {@code robot} parameter.
+ */
+ public static void pointOnComp(final Component comp, final Robot robot) {
+ Rectangle bounds = new Rectangle(comp.getLocationOnScreen(), comp.getSize());
+ robot.mouseMove(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2);
+ }
+
+ /**
+ * Moves mouse pointer in the center of a given {@code comp} component
+ * and performs a left mouse button click using the {@code robot} parameter
+ * with the {@code delay} delay between press and release.
+ */
+ public static void clickOnComp(final Component comp, final Robot robot, int delay) {
+ pointOnComp(comp, robot);
+ robot.delay(delay);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(delay);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ }
+
+ /**
+ * Moves mouse pointer in the center of a given {@code comp} component
+ * and performs a left mouse button click using the {@code robot} parameter
+ * with the default delay between press and release.
+ */
+ public static void clickOnComp(final Component comp, final Robot robot) {
+ clickOnComp(comp, robot, 50);
+ }
+
+ /*
+ * Clicks on a title of Frame/Dialog.
+ * WARNING: it may fail on some platforms when the window is not wide enough.
+ */
+ public static void clickOnTitle(final Window decoratedWindow, final Robot robot) {
+ Point p = decoratedWindow.getLocationOnScreen();
+ Dimension d = decoratedWindow.getSize();
+
+ if (decoratedWindow instanceof Frame || decoratedWindow instanceof Dialog) {
+ robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)decoratedWindow.getInsets().top/2);
+ robot.delay(50);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(50);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ }
+ }
+
+ public static void waitForIdle(final Robot robot) {
+ // we do not use robot for now, use SunToolkit.realSync() instead
+ ((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ }
+
+ public static Field getField(final Class klass, final String fieldName) {
+ return AccessController.doPrivileged(new PrivilegedAction<Field>() {
+ public Field run() {
+ try {
+ Field field = klass.getDeclaredField(fieldName);
+ assert (field != null);
+ field.setAccessible(true);
+ return field;
+ } catch (SecurityException se) {
+ throw new RuntimeException("Error: unexpected exception caught!", se);
+ } catch (NoSuchFieldException nsfe) {
+ throw new RuntimeException("Error: unexpected exception caught!", nsfe);
+ }
+ }
+ });
+ }
+
+ /*
+ * Waits for a notification and for a boolean condition to become true.
+ * The method returns when the above conditions are fullfilled or when the timeout
+ * occurs.
+ *
+ * @param condition the object to be notified and the booelan condition to wait for
+ * @param timeout the maximum time to wait in milliseconds
+ * @param catchExceptions if {@code true} the method catches InterruptedException
+ * @return the final boolean value of the {@code condition}
+ * @throws InterruptedException if the awaiting proccess has been interrupted
+ */
+ public static boolean waitForConditionEx(final AtomicBoolean condition, long timeout)
+ throws InterruptedException
+ {
+ synchronized (condition) {
+ long startTime = System.currentTimeMillis();
+ while (!condition.get()) {
+ condition.wait(timeout);
+ if (System.currentTimeMillis() - startTime >= timeout ) {
+ break;
+ }
+ }
+ }
+ return condition.get();
+ }
+
+ /*
+ * The same as {@code waitForConditionEx(AtomicBoolean, long)} except that it
+ * doesn't throw InterruptedException.
+ */
+ public static boolean waitForCondition(final AtomicBoolean condition, long timeout) {
+ try {
+ return waitForConditionEx(condition, timeout);
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Error: unexpected exception caught!", e);
+ }
+ }
+
+ /*
+ * The same as {@code waitForConditionEx(AtomicBoolean, long)} but without a timeout.
+ */
+ public static void waitForConditionEx(final AtomicBoolean condition)
+ throws InterruptedException
+ {
+ synchronized (condition) {
+ while (!condition.get()) {
+ condition.wait();
+ }
+ }
+ }
+
+ /*
+ * The same as {@code waitForConditionEx(AtomicBoolean)} except that it
+ * doesn't throw InterruptedException.
+ */
+ public static void waitForCondition(final AtomicBoolean condition) {
+ try {
+ waitForConditionEx(condition);
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Error: unexpected exception caught!", e);
+ }
+ }
+
+ public static void waitTillShownEx(final Component comp) throws InterruptedException {
+ while (true) {
+ try {
+ Thread.sleep(100);
+ comp.getLocationOnScreen();
+ break;
+ } catch (IllegalComponentStateException e) {}
+ }
+ }
+ public static void waitTillShown(final Component comp) {
+ try {
+ waitTillShownEx(comp);
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Error: unexpected exception caught!", e);
+ }
+ }
+
+ /**
+ * Drags from one point to another with the specified mouse button pressed.
+ *
+ * @param robot a robot to use for moving the mouse, etc.
+ * @param startPoint a start point of the drag
+ * @param endPoint an end point of the drag
+ * @param button one of {@code InputEvent.BUTTON1_MASK},
+ * {@code InputEvent.BUTTON2_MASK}, {@code InputEvent.BUTTON3_MASK}
+ *
+ * @throws IllegalArgumentException if {@code button} is not one of
+ * {@code InputEvent.BUTTON1_MASK}, {@code InputEvent.BUTTON2_MASK},
+ * {@code InputEvent.BUTTON3_MASK}
+ */
+ public static void drag(Robot robot, Point startPoint, Point endPoint, int button) {
+ if (!(button == InputEvent.BUTTON1_MASK || button == InputEvent.BUTTON2_MASK
+ || button == InputEvent.BUTTON3_MASK))
+ {
+ throw new IllegalArgumentException("invalid mouse button");
+ }
+
+ robot.mouseMove(startPoint.x, startPoint.y);
+ robot.mousePress(button);
+ try {
+ mouseMove(robot, startPoint, endPoint);
+ } finally {
+ robot.mouseRelease(button);
+ }
+ }
+
+ /**
+ * Moves the mouse pointer from one point to another.
+ * Uses Bresenham's algorithm.
+ *
+ * @param robot a robot to use for moving the mouse
+ * @param startPoint a start point of the drag
+ * @param endPoint an end point of the drag
+ */
+ public static void mouseMove(Robot robot, Point startPoint, Point endPoint) {
+ int dx = endPoint.x - startPoint.x;
+ int dy = endPoint.y - startPoint.y;
+
+ int ax = Math.abs(dx) * 2;
+ int ay = Math.abs(dy) * 2;
+
+ int sx = signWOZero(dx);
+ int sy = signWOZero(dy);
+
+ int x = startPoint.x;
+ int y = startPoint.y;
+
+ int d = 0;
+
+ if (ax > ay) {
+ d = ay - ax/2;
+ while (true){
+ robot.mouseMove(x, y);
+ robot.delay(50);
+
+ if (x == endPoint.x){
+ return;
+ }
+ if (d >= 0){
+ y = y + sy;
+ d = d - ax;
+ }
+ x = x + sx;
+ d = d + ay;
+ }
+ } else {
+ d = ax - ay/2;
+ while (true){
+ robot.mouseMove(x, y);
+ robot.delay(50);
+
+ if (y == endPoint.y){
+ return;
+ }
+ if (d >= 0){
+ x = x + sx;
+ d = d - ay;
+ }
+ y = y + sy;
+ d = d + ax;
+ }
+ }
+ }
+
+ private static int signWOZero(int i){
+ return (i > 0)? 1: -1;
+ }
+
+ private static int sign(int n) {
+ return n < 0 ? -1 : n == 0 ? 0 : 1;
+ }
+
+ /** Returns {@code WindowListener} instance that diposes {@code Window} on
+ * "window closing" event.
+ *
+ * @return the {@code WindowListener} instance that could be set
+ * on a {@code Window}. After that
+ * the {@code Window} is disposed when "window closed"
+ * event is sent to the {@code Window}
+ */
+ public static WindowListener getClosingWindowAdapter() {
+ return new WindowAdapter () {
+ public void windowClosing(WindowEvent e) {
+ e.getWindow().dispose();
+ }
+ };
+ }
+
+ /*
+ * The values directly map to the ones of
+ * sun.awt.X11.XWM & sun.awt.motif.MToolkit classes.
+ */
+ public final static int
+ UNDETERMINED_WM = 1,
+ NO_WM = 2,
+ OTHER_WM = 3,
+ OPENLOOK_WM = 4,
+ MOTIF_WM = 5,
+ CDE_WM = 6,
+ ENLIGHTEN_WM = 7,
+ KDE2_WM = 8,
+ SAWFISH_WM = 9,
+ ICE_WM = 10,
+ METACITY_WM = 11,
+ COMPIZ_WM = 12,
+ LG3D_WM = 13;
+
+ /*
+ * Returns -1 in case of not X Window or any problems.
+ */
+ public static int getWMID() {
+ Class clazz = null;
+ try {
+ if ("sun.awt.X11.XToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
+ clazz = Class.forName("sun.awt.X11.XWM");
+ } else if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
+ clazz = Class.forName("sun.awt.motif.MToolkit");
+ }
+ } catch (ClassNotFoundException cnfe) {
+ cnfe.printStackTrace();
+ }
+ if (clazz == null) {
+ return -1;
+ }
+
+ try {
+ final Class _clazz = clazz;
+ Method m_getWMID = (Method)AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ try {
+ Method method = _clazz.getDeclaredMethod("getWMID", new Class[] {});
+ if (method != null) {
+ method.setAccessible(true);
+ }
+ return method;
+ } catch (NoSuchMethodException e) {
+ assert false;
+ } catch (SecurityException e) {
+ assert false;
+ }
+ return null;
+ }
+ });
+ return ((Integer)m_getWMID.invoke(null, new Object[] {})).intValue();
+ } catch (IllegalAccessException iae) {
+ iae.printStackTrace();
+ } catch (InvocationTargetException ite) {
+ ite.printStackTrace();
+ }
+ return -1;
+ }
+
+
+ ////////////////////////////
+ // Some stuff to test focus.
+ ////////////////////////////
+
+ private static WindowGainedFocusListener wgfListener = new WindowGainedFocusListener();
+ private static FocusGainedListener fgListener = new FocusGainedListener();
+ private static ActionPerformedListener apListener = new ActionPerformedListener();
+
+ private abstract static class EventListener {
+ AtomicBoolean notifier = new AtomicBoolean(false);
+ Component comp;
+ boolean printEvent;
+
+ public void listen(Component comp, boolean printEvent) {
+ this.comp = comp;
+ this.printEvent = printEvent;
+ notifier.set(false);
+ setListener(comp);
+ }
+
+ public AtomicBoolean getNotifier() {
+ return notifier;
+ }
+
+ abstract void setListener(Component comp);
+
+ void printAndNotify(AWTEvent e) {
+ if (printEvent) {
+ System.err.println(e);
+ }
+ synchronized (notifier) {
+ notifier.set(true);
+ notifier.notifyAll();
+ }
+ }
+ }
+
+ private static class WindowGainedFocusListener extends EventListener implements WindowFocusListener {
+
+ void setListener(Component comp) {
+ ((Window)comp).addWindowFocusListener(this);
+ }
+
+ public void windowGainedFocus(WindowEvent e) {
+
+ ((Window)comp).removeWindowFocusListener(this);
+ printAndNotify(e);
+ }
+
+ public void windowLostFocus(WindowEvent e) {}
+ }
+
+ private static class FocusGainedListener extends EventListener implements FocusListener {
+
+ void setListener(Component comp) {
+ comp.addFocusListener(this);
+ }
+
+ public void focusGained(FocusEvent e) {
+ comp.removeFocusListener(this);
+ printAndNotify(e);
+ }
+
+ public void focusLost(FocusEvent e) {}
+ }
+
+ private static class ActionPerformedListener extends EventListener implements ActionListener {
+
+ void setListener(Component comp) {
+ ((Button)comp).addActionListener(this);
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ ((Button)comp).removeActionListener(this);
+ printAndNotify(e);
+ }
+ }
+
+ private static boolean trackEvent(int eventID, Component comp, Runnable action, int time, boolean printEvent) {
+ EventListener listener = null;
+
+ switch (eventID) {
+ case WindowEvent.WINDOW_GAINED_FOCUS:
+ listener = wgfListener;
+ break;
+ case FocusEvent.FOCUS_GAINED:
+ listener = fgListener;
+ break;
+ case ActionEvent.ACTION_PERFORMED:
+ listener = apListener;
+ break;
+ }
+
+ listener.listen(comp, printEvent);
+ action.run();
+ return Util.waitForCondition(listener.getNotifier(), time);
+ }
+
+ /*
+ * Tracks WINDOW_GAINED_FOCUS event for a window caused by an action.
+ * @param window the window to track the event for
+ * @param action the action to perform
+ * @param time the max time to wait for the event
+ * @param printEvent should the event received be printed or doesn't
+ * @return true if the event has been received, otherwise false
+ */
+ public static boolean trackWindowGainedFocus(Window window, Runnable action, int time, boolean printEvent) {
+ return trackEvent(WindowEvent.WINDOW_GAINED_FOCUS, window, action, time, printEvent);
+ }
+
+ /*
+ * Tracks FOCUS_GAINED event for a component caused by an action.
+ * @see #trackWindowGainedFocus
+ */
+ public static boolean trackFocusGained(Component comp, Runnable action, int time, boolean printEvent) {
+ return trackEvent(FocusEvent.FOCUS_GAINED, comp, action, time, printEvent);
+ }
+
+ /*
+ * Tracks ACTION_PERFORMED event for a button caused by an action.
+ * @see #trackWindowGainedFocus
+ */
+ public static boolean trackActionPerformed(Button button, Runnable action, int time, boolean printEvent) {
+ return trackEvent(ActionEvent.ACTION_PERFORMED, button, action, time, printEvent);
+ }
+
+ /*
+ * Requests focus on the component provided and waits for the result.
+ * @return true if the component has been focused, false otherwise.
+ */
+ public static boolean focusComponent(Component comp, int time) {
+ return focusComponent(comp, time, false);
+ }
+ public static boolean focusComponent(final Component comp, int time, boolean printEvent) {
+ return trackFocusGained(comp,
+ new Runnable() {
+ public void run() {
+ comp.requestFocus();
+ }
+ },
+ time, printEvent);
+
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/ViewportOverlapping.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,151 @@
+/*
+ * 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.BorderLayout;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.SwingUtilities;
+
+/**
+ * AWT/Swing overlapping test for viewport
+ * <p>This test verify if AWT components are drawn correctly being partially shown through viewport
+ * <p>See <a href="http://monaco.sfbay.sun.com/detail.jsf?cr=6778882">CR6778882</a> for details
+ * <p>See base class for test info.
+ */
+/*
+@test
+@bug 6778882
+@summary Viewport overlapping test for each AWT component
+@author sergey.grinev@oracle.com: area=awt.mixing
+@run main ViewportOverlapping
+ */
+public class ViewportOverlapping extends OverlappingTestBase {
+
+ private volatile int frameClicked;
+ private Point hLoc;
+ private Point vLoc;
+ private Point testLoc;
+ private Point resizeLoc;
+
+ private JFrame f;
+ private JPanel p;
+ private JButton b;
+ private JScrollPane scrollPane;
+
+ protected void prepareControls() {
+ p = new JPanel(new GridLayout(0, 1));
+ propagateAWTControls(p);
+ b = new JButton("Space extender");
+ p.add(b);
+ p.setPreferredSize(new Dimension(500, 500));
+ scrollPane = new JScrollPane(p);
+
+ f = new JFrame();
+ f.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ frameClicked++;
+ }
+ });
+ f.getContentPane().add(scrollPane, BorderLayout.CENTER);
+ ((JComponent) f.getContentPane()).setBorder(
+ BorderFactory.createEmptyBorder(50, 50, 50, 50));
+ f.setSize(400, 400);
+ f.setLocationRelativeTo(null);
+ f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ f.setVisible(true);
+ }
+
+ @Override
+ protected boolean performTest() {
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ // prepare test data
+ frameClicked = 0;
+
+ b.requestFocus();
+
+ scrollPane.getHorizontalScrollBar().setUnitIncrement(40);
+ scrollPane.getVerticalScrollBar().setUnitIncrement(40);
+
+ hLoc = scrollPane.getHorizontalScrollBar().getLocationOnScreen();
+ hLoc.translate(scrollPane.getHorizontalScrollBar().getWidth() - 3, 3);
+ vLoc = scrollPane.getVerticalScrollBar().getLocationOnScreen();
+ vLoc.translate(3, scrollPane.getVerticalScrollBar().getHeight() - 3);
+
+ testLoc = p.getLocationOnScreen();
+ testLoc.translate(-3, -3);
+
+ resizeLoc = f.getLocationOnScreen();
+ resizeLoc.translate(f.getWidth() - 1, f.getHeight() - 1);
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ // run robot
+ Robot robot = Util.createRobot();
+ robot.setAutoDelay(ROBOT_DELAY);
+
+ robot.mouseMove(hLoc.x, hLoc.y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ Util.waitForIdle(robot);
+
+ robot.mouseMove(vLoc.x, vLoc.y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ Util.waitForIdle(robot);
+
+ clickAndBlink(robot, testLoc, false);
+ robot.mouseMove(resizeLoc.x, resizeLoc.y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseMove(resizeLoc.x + 5, resizeLoc.y + 5);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ Util.waitForIdle(robot);
+
+ clickAndBlink(robot, testLoc, false);
+ return frameClicked == 2;
+ }
+
+ // this strange plumbing stuff is required due to "Standard Test Machinery" in base class
+ public static void main(String args[]) throws InterruptedException {
+ instance = new ViewportOverlapping();
+ OverlappingTestBase.doMain(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Robot/ModifierRobotKey/ModifierRobotKeyTest.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,230 @@
+/*
+ * Copyright (c) 2007, 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.*;
+import java.awt.event.*;
+
+import static jdk.testlibrary.Asserts.assertTrue;
+
+/*
+ * @test
+ * @summary Make sure that modifier key mask is set when robot press
+ * some key with one or more modifiers.
+ *
+ * @library ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @run main ModifierRobotKeyTest
+ */
+
+public class ModifierRobotKeyTest extends KeyAdapter {
+
+ private boolean focusGained = false;
+ private boolean startTest = false;
+ private ExtendedRobot robot;
+ private Frame frame;
+ private Canvas canvas;
+
+ private volatile boolean tempPress = false;
+
+ private int[] textKeys, modifierKeys, inputMasks;
+ private boolean[] modifierStatus, textStatus;
+
+ private final static int waitDelay = 5000;
+ private Object tempLock = new Object();
+ private Object keyLock = new Object();
+
+ public static void main(String[] args) throws Exception {
+ ModifierRobotKeyTest test = new ModifierRobotKeyTest();
+ test.doTest();
+ }
+
+ public ModifierRobotKeyTest() throws Exception {
+ modifierKeys = new int[3];
+ modifierKeys[0] = KeyEvent.VK_SHIFT;
+ modifierKeys[1] = KeyEvent.VK_CONTROL;
+ modifierKeys[2] = KeyEvent.VK_ALT;
+
+ inputMasks = new int[3];
+ inputMasks[0] = InputEvent.SHIFT_MASK;
+ inputMasks[1] = InputEvent.CTRL_MASK;
+ inputMasks[2] = InputEvent.ALT_MASK;
+
+ modifierStatus = new boolean[modifierKeys.length];
+
+ textKeys = new int[2];
+ textKeys[0] = KeyEvent.VK_A;
+
+ String os = System.getProperty("os.name").toLowerCase();
+
+ if (os.contains("solaris") || os.contains("sunos"))
+ textKeys[1] = KeyEvent.VK_S;
+ else if (os.contains("os x"))
+ textKeys[1] = KeyEvent.VK_K;
+ else
+ textKeys[1] = KeyEvent.VK_I;
+
+ textStatus = new boolean[textKeys.length];
+
+ EventQueue.invokeAndWait( () -> { initializeGUI(); });
+ }
+
+ public void keyPressed(KeyEvent event) {
+
+ tempPress = true;
+ synchronized (tempLock) { tempLock.notifyAll(); }
+
+ if (! startTest) {
+ return;
+ }
+ for (int x = 0; x < inputMasks.length; x++) {
+ if ((event.getModifiers() & inputMasks[x]) != 0) {
+ System.out.println("Modifier set: " + event.getKeyModifiersText(inputMasks[x]));
+ modifierStatus[x] = true;
+ }
+ }
+ for (int x = 0; x < textKeys.length; x++) {
+ if (event.getKeyCode() == textKeys[x]) {
+ System.out.println("Text set: " + event.getKeyText(textKeys[x]));
+ textStatus[x] = true;
+ }
+ }
+
+ synchronized (keyLock) { keyLock.notifyAll(); }
+ }
+
+ private void initializeGUI() {
+ frame = new Frame("Test frame");
+ canvas = new Canvas();
+ canvas.addFocusListener(new FocusAdapter() {
+ public void focusGained(FocusEvent event) { focusGained = true; }
+ });
+ canvas.addKeyListener(this);
+ frame.setLayout(new BorderLayout());
+ frame.add(canvas);
+ frame.setSize(200, 200);
+ frame.setVisible(true);
+ }
+
+ public void doTest() throws Exception {
+ robot = new ExtendedRobot();
+
+ robot.mouseMove((int) frame.getLocationOnScreen().getX() + frame.getSize().width / 2,
+ (int) frame.getLocationOnScreen().getY() + frame.getSize().height / 2);
+ robot.click(MouseEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+
+ assertTrue(focusGained, "FAIL: Canvas gained focus!");
+
+ for (int i = 0; i < modifierKeys.length; i++) {
+ for (int j = 0; j < textKeys.length; j++) {
+ tempPress = false;
+ robot.keyPress(modifierKeys[i]);
+ robot.waitForIdle();
+ if (! tempPress) {
+ synchronized (tempLock) { tempLock.wait(waitDelay); }
+ }
+ assertTrue(tempPress, "FAIL: keyPressed triggered for i=" + i);
+
+ resetStatus();
+ startTest = true;
+ robot.keyPress(textKeys[j]);
+ robot.waitForIdle();
+ if (! modifierStatus[i] || ! textStatus[j]) {
+ synchronized (keyLock) { keyLock.wait(waitDelay); }
+ }
+
+
+ assertTrue(modifierStatus[i] && textStatus[j],
+ "FAIL: KeyEvent not proper!"+
+ "Key checked: i=" + i + "; j=" + j+
+ "ModifierStatus = " + modifierStatus[i]+
+ "TextStatus = " + textStatus[j]);
+ startTest = false;
+ robot.keyRelease(textKeys[j]);
+ robot.waitForIdle();
+ robot.keyRelease(modifierKeys[i]);
+ robot.waitForIdle();
+ }
+ }
+
+ for (int i = 0; i < modifierKeys.length; i++) {
+ for (int j = i + 1; j < modifierKeys.length; j++) {
+ for (int k = 0; k < textKeys.length; k++) {
+ tempPress = false;
+ robot.keyPress(modifierKeys[i]);
+ robot.waitForIdle();
+ if (! tempPress) {
+ synchronized (tempLock) { tempLock.wait(waitDelay); }
+ }
+
+ assertTrue(tempPress, "FAIL: MultiKeyTest: keyPressed triggered for i=" + i);
+
+ tempPress = false;
+ robot.keyPress(modifierKeys[j]);
+ robot.waitForIdle();
+ if (! tempPress) {
+ synchronized (tempLock) { tempLock.wait(waitDelay); }
+ }
+ assertTrue(tempPress, "FAIL: MultiKeyTest keyPressed triggered for j=" + j);
+
+ resetStatus();
+ startTest = true;
+ robot.keyPress(textKeys[k]);
+ robot.waitForIdle();
+ if (! modifierStatus[i] || ! modifierStatus[j] || ! textStatus[k]) {
+ synchronized (keyLock) {
+ keyLock.wait(waitDelay);
+ }
+ }
+ assertTrue(modifierStatus[i] && modifierStatus[j] && textStatus[k],
+ "FAIL: KeyEvent not proper!"+
+ "Key checked: i=" + i + "; j=" + j + "; k=" + k+
+ "Modifier1Status = " + modifierStatus[i]+
+ "Modifier2Status = " + modifierStatus[j]+
+ "TextStatus = " + textStatus[k]);
+
+ startTest = false;
+ robot.keyRelease(textKeys[k]);
+ robot.waitForIdle();
+ robot.keyRelease(modifierKeys[j]);
+ robot.waitForIdle();
+ robot.keyRelease(modifierKeys[i]);
+ robot.waitForIdle();
+ }
+ }
+ }
+
+ frame.dispose();
+ }
+
+ private void resetStatus() {
+ for (int i = 0; i < modifierStatus.length; i++) {
+ modifierStatus[i] = false;
+ }
+ for (int i = 0; i < textStatus.length; i++) {
+ textStatus[i] = false;
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Toolkit/LockingKeyStateTest/LockingKeyStateTest.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,126 @@
+/*
+ * 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.*;
+import java.awt.event.KeyEvent;
+
+/*
+ @test
+ @summary verify LOCK buttons toogle
+ @author Yuri.Nesterenko, Dmitriy.Ermashov
+ @library ../../../../lib/testlibrary
+ @build ExtendedRobot
+ @run main LockingKeyStateTest
+*/
+
+public class LockingKeyStateTest {
+
+ Frame frame;
+ ExtendedRobot robot;
+
+ // Note that Kana lock you may actually toggle only if you have one.
+ static int[] lockingKeys = { KeyEvent.VK_CAPS_LOCK, KeyEvent.VK_NUM_LOCK,
+ KeyEvent.VK_SCROLL_LOCK, KeyEvent.VK_KANA_LOCK };
+ boolean[] getSupported = new boolean[lockingKeys.length];
+ boolean[] setSupported = new boolean[lockingKeys.length];
+ boolean[] state0 = new boolean[lockingKeys.length];
+
+ Toolkit toolkit = Toolkit.getDefaultToolkit();
+
+ LockingKeyStateTest() throws Exception {
+ robot = new ExtendedRobot();
+ EventQueue.invokeAndWait( this::createGui );
+ }
+
+ void toggleAllTrue(){toggleAll(true);}
+ void toggleAllFalse(){toggleAll(false);}
+ void toggleAll(boolean b) {
+ for(int i = 0; i < lockingKeys.length; i++) {
+ if(setSupported[i]) {
+ toolkit.setLockingKeyState(lockingKeys[i], b);
+ }
+ }
+ }
+
+ void checkAllTrue(){checkAll(true);}
+ void checkAllFalse(){checkAll(false);}
+ void checkAll(boolean b) {
+ for(int i = 0; i < lockingKeys.length; i++) {
+ if(getSupported[i] && setSupported[i]) {
+ if (!(toolkit.getLockingKeyState(lockingKeys[i]) == b))
+ throw new RuntimeException("State of "+KeyEvent.getKeyText(lockingKeys[i])+" is not "+b);
+ System.out.println("OK, state of "+KeyEvent.getKeyText(lockingKeys[i])+" is "+b);
+ }
+ }
+ }
+
+ void restoreAll() {
+ for(int i = 0; i < lockingKeys.length; i++) {
+ if(setSupported[i] && getSupported[i]) {
+ toolkit.setLockingKeyState(lockingKeys[i], state0[i]);
+ }
+ }
+ }
+
+ public void createGui() {
+ for(int i = 0; i < lockingKeys.length; i++) {
+ getSupported[i] = false;
+ setSupported[i] = false;
+ try {
+ state0[i] = toolkit.getLockingKeyState(lockingKeys[i]);
+ getSupported[i] = true;
+ toolkit.setLockingKeyState(lockingKeys[i], state0[i]);
+ setSupported[i] = true;
+ } catch (UnsupportedOperationException uoe) {
+ }
+ System.out.println(" State get/set of "+KeyEvent.getKeyText(lockingKeys[i])+" is supported? "+
+ getSupported[i]+", "+setSupported[i]);
+ }
+ frame = new Frame("LockingKeyStateTest Title");
+ frame.setSize(200,200);
+ frame.setVisible(true);
+ }
+
+ void doTest() throws Exception{
+ robot.waitForIdle();
+ robot.mouseMove(frame.getLocationOnScreen().x + frame.getWidth() / 2,
+ frame.getLocationOnScreen().y + frame.getHeight() / 2);
+ robot.click();
+
+ EventQueue.invokeAndWait( this::toggleAllTrue );
+ robot.waitForIdle(2000);
+ EventQueue.invokeAndWait( this::checkAllTrue );
+ EventQueue.invokeAndWait( this::toggleAllFalse );
+ robot.waitForIdle(2000);
+ EventQueue.invokeAndWait( this::checkAllFalse );
+ EventQueue.invokeAndWait( this::restoreAll );
+ robot.waitForIdle();
+
+ frame.dispose();
+ }
+
+ public static void main(String argv[]) throws Exception {
+ LockingKeyStateTest af = new LockingKeyStateTest();
+ af.doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/datatransfer/MappingGenerationTest/MappingGenerationTest.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,183 @@
+/*
+ * 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.datatransfer.DataFlavor;
+import java.awt.datatransfer.SystemFlavorMap;
+import java.util.List;
+
+/*
+ @test
+ @bug 4512530 8027148
+ @summary tests that mappings for text flavors are generated properly
+ @author das@sparc.spb.su area=datatransfer
+*/
+
+public class MappingGenerationTest {
+
+ private static final SystemFlavorMap fm =
+ (SystemFlavorMap)SystemFlavorMap.getDefaultFlavorMap();
+
+ public static void main(String[] args) {
+ test1();
+ test2();
+ test3();
+ test4();
+ test5();
+ test6();
+ }
+
+ /**
+ * Verifies that Lists returned from getNativesForFlavor() and
+ * getFlavorsForNative() are not modified with a subsequent call
+ * to addUnencodedNativeForFlavor() and addFlavorForUnencodedNative()
+ * respectively.
+ */
+ public static void test1() {
+ DataFlavor df = new DataFlavor("text/plain-test1", null);
+ String nat = "native1";
+
+ List<String> natives = fm.getNativesForFlavor(df);
+ fm.addUnencodedNativeForFlavor(df, nat);
+ List<String> nativesNew = fm.getNativesForFlavor(df);
+ if (natives.equals(nativesNew)) {
+ System.err.println("orig=" + natives);
+ System.err.println("new=" + nativesNew);
+ throw new RuntimeException("Test failed");
+ }
+
+ List<DataFlavor> flavors = fm.getFlavorsForNative(nat);
+ fm.addFlavorForUnencodedNative(nat, df);
+ List<DataFlavor> flavorsNew = fm.getFlavorsForNative(nat);
+ if (flavors.equals(flavorsNew)) {
+ System.err.println("orig=" + flavors);
+ System.err.println("new=" + flavorsNew);
+ throw new RuntimeException("Test failed");
+ }
+ }
+
+ /**
+ * Verifies that SystemFlavorMap is not affected by modification of
+ * the Lists returned from getNativesForFlavor() and
+ * getFlavorsForNative().
+ */
+ public static void test2() {
+ DataFlavor df = new DataFlavor("text/plain-test2", null);
+ String nat = "native2";
+ DataFlavor extraDf = new DataFlavor("text/test", null);
+
+ List<String> natives = fm.getNativesForFlavor(df);
+ natives.add("Should not be here");
+ java.util.List nativesNew = fm.getNativesForFlavor(df);
+ if (natives.equals(nativesNew)) {
+ System.err.println("orig=" + natives);
+ System.err.println("new=" + nativesNew);
+ throw new RuntimeException("Test failed");
+ }
+
+ List<DataFlavor> flavors = fm.getFlavorsForNative(nat);
+ flavors.add(extraDf);
+ java.util.List flavorsNew = fm.getFlavorsForNative(nat);
+ if (flavors.equals(flavorsNew)) {
+ System.err.println("orig=" + flavors);
+ System.err.println("new=" + flavorsNew);
+ throw new RuntimeException("Test failed");
+ }
+ }
+
+ /**
+ * Verifies that addUnencodedNativeForFlavor() for a particular text flavor
+ * doesn't affect mappings for other flavors.
+ */
+ public static void test3() {
+ DataFlavor df1 = new DataFlavor("text/plain-test3", null);
+ DataFlavor df2 = new DataFlavor("text/plain-test3; charset=Unicode; class=java.io.Reader", null);
+ String nat = "native3";
+ List<String> natives = fm.getNativesForFlavor(df2);
+ fm.addUnencodedNativeForFlavor(df1, nat);
+ List<String> nativesNew = fm.getNativesForFlavor(df2);
+ if (!natives.equals(nativesNew)) {
+ System.err.println("orig=" + natives);
+ System.err.println("new=" + nativesNew);
+ throw new RuntimeException("Test failed");
+ }
+ }
+
+ /**
+ * Verifies that addUnencodedNativeForFlavor() really adds the specified
+ * flavor-to-native mapping to the existing mappings.
+ */
+ public static void test4() {
+ DataFlavor df = new DataFlavor("text/plain-test4; charset=Unicode; class=java.io.Reader", null);
+ String nat = "native4";
+ List<String> natives = fm.getNativesForFlavor(df);
+ if (!natives.contains(nat)) {
+ fm.addUnencodedNativeForFlavor(df, nat);
+ List<String> nativesNew = fm.getNativesForFlavor(df);
+ natives.add(nat);
+ if (!natives.equals(nativesNew)) {
+ System.err.println("orig=" + natives);
+ System.err.println("new=" + nativesNew);
+ throw new RuntimeException("Test failed");
+ }
+ }
+ }
+
+ /**
+ * Verifies that a flavor doesn't have any flavor-to-native mappings after
+ * a call to setNativesForFlavor() with this flavor and an empty native
+ * array as arguments.
+ */
+ public static void test5() {
+ final DataFlavor flavor =
+ new DataFlavor("text/plain-TEST5; charset=Unicode", null);
+
+ fm.getNativesForFlavor(flavor);
+
+ fm.setNativesForFlavor(flavor, new String[0]);
+
+ List<String> natives = fm.getNativesForFlavor(flavor);
+
+ if (!natives.isEmpty()) {
+ System.err.println("natives=" + natives);
+ throw new RuntimeException("Test failed");
+ }
+ }
+
+ /**
+ * Verifies that a native doesn't have any native-to-flavor mappings after
+ * a call to setFlavorsForNative() with this native and an empty flavor
+ * array as arguments.
+ */
+ public static void test6() {
+ final String nat = "STRING";
+ fm.getFlavorsForNative(nat);
+ fm.setFlavorsForNative(nat, new DataFlavor[0]);
+
+ List<DataFlavor> flavors = fm.getFlavorsForNative(nat);
+
+ if (!flavors.isEmpty()) {
+ System.err.println("flavors=" + flavors);
+ throw new RuntimeException("Test failed");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/dnd/DragInterceptorAppletTest/DragInterceptorAppletTest.html Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,48 @@
+<!--
+ 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.
+-->
+
+<html>
+<!--
+ @test
+ @bug 6887703
+ @summary Unsigned applet can retrieve the dragged information before drop action occurs
+ @author : area=dnd
+ @library ../../regtesthelpers
+ @library ../../regtesthelpers/process
+ @build Util
+ @build ProcessResults ProcessCommunicator
+ @run applet/othervm DragInterceptorAppletTest.html
+
+-->
+<head>
+<title> Unsigned applet can retrieve the dragged information before drop action occurs </title>
+</head>
+<body>
+
+<h1>DragInterceptorAppletTest<br>Bug ID: 6887703</h1>
+
+<p> This is an AUTOMATIC test, simply wait for completion </p>
+
+<APPLET CODE="DragInterceptorAppletTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/dnd/DragInterceptorAppletTest/DragInterceptorAppletTest.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+
+/*
+ test
+ @bug 6887703
+ @summary Unsigned applet can retrieve the dragged information before drop action occurs
+ @author : area=dnd
+ @run applet DragInterceptorAppletTest.html
+*/
+
+/**
+ * DragInterceptorAppletTest.java
+ *
+ * summary: Unsigned applet can retrieve the dragged information before drop action occurs
+ */
+
+import static java.lang.Thread.sleep;
+
+import test.java.awt.regtesthelpers.process.ProcessCommunicator;
+import test.java.awt.regtesthelpers.process.ProcessResults;
+import test.java.awt.regtesthelpers.Util;
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.InputEvent;
+
+public class DragInterceptorAppletTest extends Applet {
+
+ public void init() {
+ setLayout(new BorderLayout());
+ }//End init()
+
+ public void start() {
+
+ SourceFrame sourceFrame = new SourceFrame();
+
+ Util.waitForIdle(null);
+
+ String [] args = new String [] {
+ String.valueOf(sourceFrame.getNextLocationX()),
+ String.valueOf(sourceFrame.getNextLocationY()),
+ String.valueOf(sourceFrame.getDragSourcePointX()),
+ String.valueOf(sourceFrame.getDragSourcePointY()),
+ };
+ String classpath = System.getProperty("java.class.path");
+ ProcessResults processResults =
+ ProcessCommunicator.executeChildProcess(this.getClass(),classpath,args);
+
+ verifyTestResults(processResults);
+
+ }// start()
+
+ private static void verifyTestResults(ProcessResults processResults) {
+
+ switch (processResults.getExitValue()) {
+ case InterprocessMessages.DATA_WAS_INTERCEPTED_AND_EXCEPTION_HANDLER_WAS_NOT_TRIGGERED:
+ processResults.printProcessErrorOutput(System.err);
+ throw new RuntimeException("TEST IS FAILED: Target applet can intercept data " +
+ "without a clipboard permission and an exception handler was not triggered.");
+ //Unreachable...
+
+ case InterprocessMessages.DATA_WAS_INTERCEPTED:
+ processResults.printProcessErrorOutput(System.err);
+ throw new RuntimeException("TEST IS FAILED: Target applet can intercept data " +
+ "without a clipboard permission");
+ //Unreachable...
+
+ case InterprocessMessages.EXCEPTION_HANDLER_WAS_NOT_TRIGGERED:
+ processResults.printProcessErrorOutput(System.err);
+ throw new RuntimeException("TEST IS FAILED: An exception handler was not triggered.");
+ //Unreachable...
+
+ }
+
+ // The child process throws an exception. do not look at the stderr.
+ processResults.verifyStdErr(System.err);
+ processResults.verifyProcessExitValue(System.err);
+ processResults.printProcessStandartOutput(System.out);
+ }
+
+ //We cannot make an instance of the applet without the default constructor
+ public DragInterceptorAppletTest() {
+ super();
+ }
+
+ //We need in this constructor to pass frame position between JVMs
+ public DragInterceptorAppletTest(Point targetFrameLocation, Point dragSourcePoint)
+ throws InterruptedException
+ {
+ DragInterceptorFrame targetFrame = new DragInterceptorFrame(targetFrameLocation);
+
+ Util.waitForIdle(null);
+
+ final Robot robot = Util.createRobot();
+
+ robot.mouseMove((int)dragSourcePoint.getX(),(int)dragSourcePoint.getY());
+ sleep(100);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ sleep(100);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ sleep(100);
+
+ Util.drag(robot, dragSourcePoint, targetFrame.getDropTargetPoint(),
+ InputEvent.BUTTON1_MASK);
+
+ sleep(2000);
+ ProcessCommunicator.destroyProcess();
+ }
+
+ enum InterprocessArguments {
+ TARGET_FRAME_X_POSITION_ARGUMENT,
+ TARGET_FRAME_Y_POSITION_ARGUMENT,
+ DRAG_SOURCE_POINT_X_ARGUMENT,
+ DRAG_SOURCE_POINT_Y_ARGUMENT;
+
+ int extract (String [] args) {
+ return Integer.parseInt(args[this.ordinal()]);
+ }
+ }
+
+ public static void main (String [] args) {
+ Point dragSourcePoint = new Point(InterprocessArguments.DRAG_SOURCE_POINT_X_ARGUMENT.extract(args),
+ InterprocessArguments.DRAG_SOURCE_POINT_Y_ARGUMENT.extract(args));
+ Point targetFrameLocation = new Point(InterprocessArguments.TARGET_FRAME_X_POSITION_ARGUMENT.extract(args),
+ InterprocessArguments.TARGET_FRAME_Y_POSITION_ARGUMENT.extract(args));
+ try {
+ new DragInterceptorAppletTest(targetFrameLocation, dragSourcePoint);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+}// class DragInterceptorAppletTest
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/dnd/DragInterceptorAppletTest/DragInterceptorFrame.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2007, 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.*;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.dnd.*;
+import java.io.IOException;
+import java.security.Permission;
+import java.security.AccessControlException;
+
+class DragInterceptorFrame extends Frame implements DropTargetListener {
+
+ private static int exitMessage = InterprocessMessages.TEST_PASSED;
+ private static boolean dataIsAccessible = false;
+ private static boolean exceptionHasBeenThrown = false;
+
+ DragInterceptorFrame(Point location) {
+ System.setSecurityManager(new ClipboardDefender());
+ initGUI(location);
+ setDropTarget(new DropTarget(this, DnDConstants.ACTION_COPY,
+ this));
+ }
+
+ private void initGUI(Point location) {
+ this.setLocation(location);
+ this.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ DragInterceptorFrame.this.dispose();
+ }
+ });
+ setSize (200, 200);
+ this.setVisible(true);
+ }
+
+ public void dragEnter(DropTargetDragEvent dtde) {
+ // We want to set the exception handler on EDT
+ Thread.currentThread().setUncaughtExceptionHandler (
+ new Thread.UncaughtExceptionHandler() {
+ public void uncaughtException(Thread t, Throwable e) {
+ exceptionHasBeenThrown = true;
+ }
+ }
+ );
+ examineTransferable(dtde);
+ }
+
+ public void dragOver(DropTargetDragEvent dtde) {
+ examineTransferable(dtde);
+ }
+
+ public void dropActionChanged(DropTargetDragEvent dtde) {
+ examineTransferable(dtde);
+ }
+
+ public void dragExit(DropTargetEvent dte) {}
+
+ public void drop(DropTargetDropEvent dtde) {
+
+ if (dataIsAccessible && !exceptionHasBeenThrown) {
+ exitMessage = InterprocessMessages.DATA_WAS_INTERCEPTED_AND_EXCEPTION_HANDLER_WAS_NOT_TRIGGERED;
+ } else if (dataIsAccessible) {
+ exitMessage = InterprocessMessages.DATA_WAS_INTERCEPTED;
+ } else if (!exceptionHasBeenThrown) {
+ exitMessage = InterprocessMessages.EXCEPTION_HANDLER_WAS_NOT_TRIGGERED;
+ }
+
+ // This returns the diagnostic code from the child VM
+ System.exit(exitMessage);
+ }
+
+ Point getDropTargetPoint() {
+ return new Point((int)getLocationOnScreen().getX()+(getWidth()/2),
+ (int)getLocationOnScreen().getY()+(getHeight()/2));
+ }
+
+ private void examineTransferable(DropTargetDragEvent dtde) {
+ if (dtde.getCurrentDataFlavorsAsList().contains(DataFlavor.stringFlavor)) {
+ dtde.acceptDrag(DnDConstants.ACTION_COPY);
+ try{
+ if (null != dtde.getTransferable().getTransferData(DataFlavor.stringFlavor)) {
+ dataIsAccessible = true;
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ exitMessage = InterprocessMessages.UNEXPECTED_IO_EXCEPTION;
+ } catch (UnsupportedFlavorException e) {
+ e.printStackTrace();
+ exitMessage = InterprocessMessages.UNEXPECTED_UNSUPPORTED_FLAVOR_EXCEPTION;
+ }
+ }
+ }
+
+ static class ClipboardDefender extends SecurityManager {
+ public void checkPermission(Permission p) {
+ if (p instanceof java.awt.AWTPermission &&
+ p.getName().equals("accessClipboard")) {
+ throw new AccessControlException("access denied ");
+ }
+ }
+ }
+
+ public static void main(String[] args) {
+ new DragInterceptorFrame(new Point(200,200));
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/dnd/DragInterceptorAppletTest/InterprocessMessages.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+
+public interface InterprocessMessages {
+ final static int TEST_PASSED = 0;
+ final static int DATA_WAS_INTERCEPTED = 212;
+ final static int EXCEPTION_HANDLER_WAS_NOT_TRIGGERED = 213;
+ final static int DATA_WAS_INTERCEPTED_AND_EXCEPTION_HANDLER_WAS_NOT_TRIGGERED = 214;
+
+ final static int UNEXPECTED_IO_EXCEPTION = 400;
+ final static int UNEXPECTED_UNSUPPORTED_FLAVOR_EXCEPTION = 401;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/dnd/DragInterceptorAppletTest/SourceFrame.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2007, 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 test.java.awt.regtesthelpers.Util;
+
+import java.awt.*;
+import java.awt.datatransfer.StringSelection;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DragGestureEvent;
+
+class SourceFrame extends Frame implements DragGestureListener {
+
+ SourceFrame() {
+ super("Source File List Frame");
+ initGUI();
+ new DragSource().createDefaultDragGestureRecognizer(this,
+ DnDConstants.ACTION_COPY,this);
+ }
+
+ private void initGUI() {
+ this.addWindowListener(Util.getClosingWindowAdapter());
+ this.setLocation(300,250);
+ this.setSize(200,200);
+ this.setVisible(true);
+ }
+
+ int getNextLocationX() {
+ return getX()+getWidth();
+ }
+
+ int getNextLocationY() {
+ return getY();
+ }
+
+ int getDragSourcePointX() {
+ return (int)getLocationOnScreen().getX()+(getWidth()/2);
+ }
+
+ int getDragSourcePointY() {
+ return (int)getLocationOnScreen().getY()+ (getHeight()/2);
+ }
+
+ public void dragGestureRecognized(DragGestureEvent dge) {
+ dge.startDrag(null, new StringSelection("A TEXT"));
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/dnd/InterJVMGetDropSuccessTest/InterJVMGetDropSuccessTest.html Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,43 @@
+<!--
+ 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.
+-->
+
+<html>
+<!--
+ @test
+ @bug 4658741
+ @summary verifies that getDropSuccess() returns correct value for inter-JVM DnD
+ @author das@sparc.spb.su area=dnd
+ @run applet InterJVMGetDropSuccessTest.html
+ -->
+<head>
+<title> </title>
+</head>
+<body>
+
+<h1>InterJVMGetDropSuccessTest<br>Bug ID: 4658741</h1>
+
+<p> This is an AUTOMATIC test, simply wait for completion </p>
+
+<APPLET CODE="InterJVMGetDropSuccessTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/dnd/InterJVMGetDropSuccessTest/InterJVMGetDropSuccessTest.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,499 @@
+/*
+ * 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.
+ */
+
+/*
+ test
+ @bug 4658741
+ @summary verifies that getDropSuccess() returns correct value for inter-JVM DnD
+ @author das@sparc.spb.su area=dnd
+ @run applet InterJVMGetDropSuccessTest.html
+*/
+
+// Note there is no @ in front of test above. This is so that the
+// harness will not mistake this file as a test file. It should
+// only see the html file as a test file. (the harness runs all
+// valid test files, so it would run this test twice if this file
+// were valid as well as the html file.)
+// Also, note the area= after Your Name in the author tag. Here, you
+// should put which functional area the test falls in. See the
+// AWT-core home page -> test areas and/or -> AWT team for a list of
+// areas.
+// Note also the 'InterJVMGetDropSuccessTest.html' in the run tag. This should
+// be changed to the name of the test.
+
+
+/**
+ * InterJVMGetDropSuccessTest.java
+ *
+ * summary: verifies that getDropSuccess() returns correct value for inter-JVM DnD
+ */
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.datatransfer.*;
+import java.awt.dnd.*;
+import java.awt.event.*;
+import java.io.*;
+import javax.swing.*;
+
+
+//Automated tests should run as applet tests if possible because they
+// get their environments cleaned up, including AWT threads, any
+// test created threads, and any system resources used by the test
+// such as file descriptors. (This is normally not a problem as
+// main tests usually run in a separate VM, however on some platforms
+// such as the Mac, separate VMs are not possible and non-applet
+// tests will cause problems). Also, you don't have to worry about
+// synchronisation stuff in Applet tests they way you do in main
+// tests...
+
+
+public class InterJVMGetDropSuccessTest extends Applet {
+
+ private int returnCode = Util.CODE_NOT_RETURNED;
+ private boolean successCodes[] = { true, false };
+ private int dropCount = 0;
+
+ final Frame frame = new Frame("Target Frame");
+
+ final DropTargetListener dropTargetListener = new DropTargetAdapter() {
+ public void drop(DropTargetDropEvent dtde) {
+ dtde.acceptDrop(DnDConstants.ACTION_COPY);
+ dtde.dropComplete(successCodes[dropCount]);
+ dropCount++;
+ }
+ };
+ final DropTarget dropTarget = new DropTarget(frame, dropTargetListener);
+
+ public void init() {
+ //Create instructions for the user here, as well as set up
+ // the environment -- set the layout manager, add buttons,
+ // etc.
+
+ String[] instructions =
+ {
+ "This is an AUTOMATIC test",
+ "simply wait until it is done"
+ };
+ Sysout.createDialog( );
+ Sysout.printInstructions( instructions );
+
+ frame.setTitle("Test frame");
+ frame.setBounds(100, 100, 150, 150);
+ } // init()
+
+ public void start() {
+
+ frame.setVisible(true);
+
+ try {
+ Thread.sleep(Util.FRAME_ACTIVATION_TIMEOUT);
+
+ Point p = frame.getLocationOnScreen();
+ Dimension d = frame.getSize();
+
+ String javaPath = System.getProperty("java.home", "");
+ String command = javaPath + File.separator + "bin" +
+ File.separator + "java -cp " + System.getProperty("test.classes", ".") +
+ " Child " +
+ p.x + " " + p.y + " " + d.width + " " + d.height;
+
+ Process process = Runtime.getRuntime().exec(command);
+ returnCode = process.waitFor();
+
+ InputStream errorStream = process.getErrorStream();
+ int count = errorStream.available();
+ if (count > 0) {
+ byte[] b = new byte[count];
+ errorStream.read(b);
+ System.err.println("========= Child VM System.err ========");
+ System.err.print(new String(b));
+ System.err.println("======================================");
+ }
+
+ InputStream outputStream = process.getInputStream();
+ count = outputStream.available();
+ if (count > 0) {
+ byte[] b = new byte[count];
+ outputStream.read(b);
+ System.err.println("========= Child VM System.out ========");
+ System.err.print(new String(b));
+ System.err.println("======================================");
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ switch (returnCode) {
+ case Util.CODE_NOT_RETURNED:
+ throw new RuntimeException("Child VM: failed to start");
+ case Util.CODE_FAILURE:
+ throw new RuntimeException("Child VM: abnormal termination");
+ default:
+ if (dropCount == 2) {
+ int expectedRetCode = 0;
+ if (successCodes[0]) {
+ expectedRetCode |= Util.CODE_FIRST_SUCCESS;
+ }
+ if (successCodes[1]) {
+ expectedRetCode |= Util.CODE_SECOND_SUCCESS;
+ }
+ if (expectedRetCode != returnCode) {
+ throw new RuntimeException("The test failed. Expected:" +
+ expectedRetCode + ". Returned:" +
+ returnCode);
+ }
+ }
+ break;
+ }
+ } // start()
+} // class InterJVMGetDropSuccessTest
+
+final class Util implements AWTEventListener {
+ public static final int CODE_NOT_RETURNED = -1;
+ public static final int CODE_FIRST_SUCCESS = 0x2;
+ public static final int CODE_SECOND_SUCCESS = 0x2;
+ public static final int CODE_FAILURE = 0x1;
+
+ public static final int FRAME_ACTIVATION_TIMEOUT = 3000;
+
+ static final Object SYNC_LOCK = new Object();
+ static final int MOUSE_RELEASE_TIMEOUT = 1000;
+
+ static final Util theInstance = new Util();
+
+ static {
+ Toolkit.getDefaultToolkit().addAWTEventListener(theInstance, AWTEvent.MOUSE_EVENT_MASK);
+ }
+
+ public static Point getCenterLocationOnScreen(Component c) {
+ Point p = c.getLocationOnScreen();
+ Dimension d = c.getSize();
+ p.translate(d.width / 2, d.height / 2);
+ return p;
+ }
+
+ public static int sign(int n) {
+ return n < 0 ? -1 : n == 0 ? 0 : 1;
+ }
+
+ private Component clickedComponent = null;
+
+ private void reset() {
+ clickedComponent = null;
+ }
+
+ public void eventDispatched(AWTEvent e) {
+ if (e.getID() == MouseEvent.MOUSE_RELEASED) {
+ clickedComponent = (Component)e.getSource();
+ synchronized (SYNC_LOCK) {
+ SYNC_LOCK.notifyAll();
+ }
+ }
+ }
+
+ public static boolean pointInComponent(Robot robot, Point p, Component comp)
+ throws InterruptedException {
+ return theInstance.pointInComponentImpl(robot, p, comp);
+ }
+
+ private boolean pointInComponentImpl(Robot robot, Point p, Component comp)
+ throws InterruptedException {
+ robot.waitForIdle();
+ reset();
+ robot.mouseMove(p.x, p.y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ synchronized (SYNC_LOCK) {
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ SYNC_LOCK.wait(MOUSE_RELEASE_TIMEOUT);
+ }
+
+ Component c = clickedComponent;
+
+ while (c != null && c != comp) {
+ c = c.getParent();
+ }
+
+ return c == comp;
+ }
+}
+
+class Child {
+ static class DragSourceDropListener extends DragSourceAdapter {
+ private boolean finished = false;
+ private boolean dropSuccess = false;
+
+ public void reset() {
+ finished = false;
+ dropSuccess = false;
+ }
+
+ public boolean isDropFinished() {
+ return finished;
+ }
+
+ public boolean getDropSuccess() {
+ return dropSuccess;
+ }
+
+ public void dragDropEnd(DragSourceDropEvent dsde) {
+ finished = true;
+ dropSuccess = dsde.getDropSuccess();
+ synchronized (Util.SYNC_LOCK) {
+ Util.SYNC_LOCK.notifyAll();
+ }
+ }
+ }
+
+ final Frame frame = new Frame("Source Frame");
+ final DragSource dragSource = DragSource.getDefaultDragSource();
+ final DragSourceDropListener dragSourceListener = new DragSourceDropListener();
+ final Transferable transferable = new StringSelection("TEXT");
+ final DragGestureListener dragGestureListener = new DragGestureListener() {
+ public void dragGestureRecognized(DragGestureEvent dge) {
+ dge.startDrag(null, transferable, dragSourceListener);
+ }
+ };
+ final DragGestureRecognizer dragGestureRecognizer =
+ dragSource.createDefaultDragGestureRecognizer(frame, DnDConstants.ACTION_COPY,
+ dragGestureListener);
+
+ public static void main(String[] args) {
+ Child child = new Child();
+ child.run(args);
+ }
+
+ public void run(String[] args) {
+ try {
+ if (args.length != 4) {
+ throw new RuntimeException("Incorrect command line arguments.");
+ }
+
+ int x = Integer.parseInt(args[0]);
+ int y = Integer.parseInt(args[1]);
+ int w = Integer.parseInt(args[2]);
+ int h = Integer.parseInt(args[3]);
+
+ frame.setBounds(300, 200, 150, 150);
+ frame.setVisible(true);
+
+ Thread.sleep(Util.FRAME_ACTIVATION_TIMEOUT);
+
+ Point sourcePoint = Util.getCenterLocationOnScreen(frame);
+
+ Point targetPoint = new Point(x + w / 2, y + h / 2);
+
+ Robot robot = new Robot();
+ robot.mouseMove(sourcePoint.x, sourcePoint.y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ for (Point p = new Point(sourcePoint); !p.equals(targetPoint);
+ p.translate(Util.sign(targetPoint.x - p.x),
+ Util.sign(targetPoint.y - p.y))) {
+ robot.mouseMove(p.x, p.y);
+ Thread.sleep(50);
+ }
+
+ synchronized (Util.SYNC_LOCK) {
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ Util.SYNC_LOCK.wait(Util.FRAME_ACTIVATION_TIMEOUT);
+ }
+
+ if (!dragSourceListener.isDropFinished()) {
+ throw new RuntimeException("Drop not finished");
+ }
+
+ boolean success1 = dragSourceListener.getDropSuccess();
+
+ dragSourceListener.reset();
+ robot.mouseMove(sourcePoint.x, sourcePoint.y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ for (Point p = new Point(sourcePoint); !p.equals(targetPoint);
+ p.translate(Util.sign(targetPoint.x - p.x),
+ Util.sign(targetPoint.y - p.y))) {
+ robot.mouseMove(p.x, p.y);
+ Thread.sleep(50);
+ }
+
+ synchronized (Util.SYNC_LOCK) {
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ Util.SYNC_LOCK.wait(Util.FRAME_ACTIVATION_TIMEOUT);
+ }
+
+ if (!dragSourceListener.isDropFinished()) {
+ throw new RuntimeException("Drop not finished");
+ }
+
+ boolean success2 = dragSourceListener.getDropSuccess();
+ int retCode = 0;
+
+ if (success1) {
+ retCode |= Util.CODE_FIRST_SUCCESS;
+ }
+ if (success2) {
+ retCode |= Util.CODE_SECOND_SUCCESS;
+ }
+ // This returns the diagnostic code from the child VM
+ System.exit(retCode);
+ } catch (Throwable e) {
+ e.printStackTrace();
+ // This returns the diagnostic code from the child VM
+ System.exit(Util.CODE_FAILURE);
+ }
+ } // run()
+} // class child
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+ {
+ private static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.show();
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.show();
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ }
+
+ }// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+ {
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("South", messageText);
+
+ pack();
+
+ show();
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ }
+
+ }// TestDialog class
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/dnd/NoFormatsCrashTest/NoFormatsCrashTest.html Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,45 @@
+<!--
+ 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.
+-->
+
+<html>
+<!--
+ @test
+ @bug 4870762
+ @summary tests that a drop target JVM doesn't crash if the source doesn't export
+ data in native formats.
+ @author das@sparc.spb.su area=dnd
+ @run applet NoFormatsCrashTest.html
+ -->
+<head>
+<title> </title>
+</head>
+<body>
+
+<h1>NoFormatsCrashTest<br>Bug ID: 4870762</h1>
+
+<p> This is an AUTOMATIC test, simply wait for completion </p>
+
+<APPLET CODE="NoFormatsCrashTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/dnd/NoFormatsCrashTest/NoFormatsCrashTest.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,488 @@
+/*
+ * 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.
+ */
+
+/*
+ test
+ @bug 4870762
+ @summary tests that a drop target JVM doesn't crash if the source doesn't export
+ data in native formats.
+ @author das@sparc.spb.su area=dnd
+ @compile NoFormatsCrashTest.java
+ @run applet NoFormatsCrashTest.html
+*/
+
+// Note there is no @ in front of test above. This is so that the
+// harness will not mistake this file as a test file. It should
+// only see the html file as a test file. (the harness runs all
+// valid test files, so it would run this test twice if this file
+// were valid as well as the html file.)
+// Also, note the area= after Your Name in the author tag. Here, you
+// should put which functional area the test falls in. See the
+// AWT-core home page -> test areas and/or -> AWT team for a list of
+// areas.
+// Note also the 'NoFormatsCrashTest.html' in the run tag. This should
+// be changed to the name of the test.
+
+
+/**
+ * NoFormatsCrashTest.java
+ *
+ * summary: tests that a drop target JVM doesn't crash if the source doesn't export
+ * data in native formats.
+ */
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.datatransfer.*;
+import java.awt.dnd.*;
+import java.awt.event.*;
+import java.io.*;
+
+
+//Automated tests should run as applet tests if possible because they
+// get their environments cleaned up, including AWT threads, any
+// test created threads, and any system resources used by the test
+// such as file descriptors. (This is normally not a problem as
+// main tests usually run in a separate VM, however on some platforms
+// such as the Mac, separate VMs are not possible and non-applet
+// tests will cause problems). Also, you don't have to worry about
+// synchronisation stuff in Applet tests they way you do in main
+// tests...
+
+
+public class NoFormatsCrashTest extends Applet {
+
+ final Frame frame = new Frame();
+ private volatile Process process;
+
+ static final int FRAME_ACTIVATION_TIMEOUT = 2000;
+
+ public static void main(String[] args) {
+ NoFormatsCrashTest test = new NoFormatsCrashTest();
+ test.run(args);
+ }
+
+ public void run(String[] args) {
+ try {
+ if (args.length != 4) {
+ throw new RuntimeException("Incorrect command line arguments.");
+ }
+
+ int x = Integer.parseInt(args[0]);
+ int y = Integer.parseInt(args[1]);
+ int w = Integer.parseInt(args[2]);
+ int h = Integer.parseInt(args[3]);
+
+ Panel panel = new DragSourcePanel();
+
+ frame.setTitle("Drag source frame");
+ frame.setLocation(500, 200);
+ frame.add(panel);
+ frame.pack();
+ frame.setVisible(true);
+
+ Thread.sleep(FRAME_ACTIVATION_TIMEOUT);
+
+ Point sourcePoint = panel.getLocationOnScreen();
+ Dimension d = panel.getSize();
+ sourcePoint.translate(d.width / 2, d.height / 2);
+
+ Point targetPoint = new Point(x + w / 2, y + h / 2);
+
+ Robot robot = new Robot();
+ robot.mouseMove(sourcePoint.x, sourcePoint.y);
+ robot.keyPress(KeyEvent.VK_CONTROL);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ for (; !sourcePoint.equals(targetPoint);
+ sourcePoint.translate(sign(targetPoint.x - sourcePoint.x),
+ sign(targetPoint.y - sourcePoint.y))) {
+ robot.mouseMove(sourcePoint.x, sourcePoint.y);
+ Thread.sleep(50);
+ }
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.keyRelease(KeyEvent.VK_CONTROL);
+
+ Thread.sleep(FRAME_ACTIVATION_TIMEOUT);
+
+ if (process.isAlive()) {
+ process.destroy();
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ } // run()
+
+ public void init() {
+ //Create instructions for the user here, as well as set up
+ // the environment -- set the layout manager, add buttons,
+ // etc.
+
+ String[] instructions =
+ {
+ "This is an AUTOMATIC test",
+ "simply wait until it is done"
+ };
+ Sysout.createDialog( );
+ Sysout.printInstructions( instructions );
+
+ frame.setTitle("Drop target frame");
+ frame.setLocation(200, 200);
+
+ } // init()
+
+ public void start() {
+ DropTargetPanel panel = new DropTargetPanel();
+ frame.add(panel);
+ frame.pack();
+ frame.setVisible(true);
+
+ try {
+ Thread.sleep(FRAME_ACTIVATION_TIMEOUT);
+
+ Point p = frame.getLocationOnScreen();
+ Dimension d = frame.getSize();
+
+ String javaPath = System.getProperty("java.home", "");
+ String command = javaPath + File.separator + "bin" +
+ File.separator + "java -cp " + System.getProperty("test.classes", ".") +
+ " NoFormatsCrashTest " +
+ p.x + " " + p.y + " " + d.width + " " + d.height;
+
+ process = Runtime.getRuntime().exec(command);
+ ProcessResults pres = ProcessResults.doWaitFor(process);
+ System.err.println("Child VM return code: " + pres.exitValue);
+
+ if (pres.stderr != null && pres.stderr.length() > 0) {
+ System.err.println("========= Child VM System.err ========");
+ System.err.print(pres.stderr);
+ System.err.println("======================================");
+ }
+
+ if (pres.stdout != null && pres.stdout.length() > 0) {
+ System.err.println("========= Child VM System.out ========");
+ System.err.print(pres.stdout);
+ System.err.println("======================================");
+ }
+
+ } catch (Throwable e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+
+ if (panel.isTestFailed()) {
+ throw new RuntimeException();
+ }
+ } // start()
+
+ public static int sign(int n) {
+ return n < 0 ? -1 : n > 0 ? 1 : 0;
+ }
+} // class NoFormatsCrashTest
+
+class TestTransferable implements Transferable {
+
+ public static DataFlavor dataFlavor = null;
+ static final Object data = new Object();
+
+ static {
+ DataFlavor df = null;
+ try {
+ df = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType +
+ "; class=java.lang.Object");
+ } catch (ClassNotFoundException e) {
+ throw new ExceptionInInitializerError(e);
+ }
+ dataFlavor = df;
+ }
+
+ public DataFlavor[] getTransferDataFlavors() {
+ return new DataFlavor[] { dataFlavor };
+ }
+
+ public boolean isDataFlavorSupported(DataFlavor df) {
+ return dataFlavor.equals(df);
+ }
+
+ public Object getTransferData(DataFlavor df)
+ throws UnsupportedFlavorException, IOException {
+ if (!isDataFlavorSupported(df)) {
+ throw new UnsupportedFlavorException(df);
+ }
+ return data;
+ }
+}
+
+class DragSourcePanel extends Panel {
+ public DragSourcePanel() {
+ final Transferable t = new TestTransferable();
+ final DragSourceListener dsl = new DragSourceAdapter() {
+ public void dragDropEnd(DragSourceDropEvent dtde) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ // This finishes child VM
+ System.exit(0);
+ }
+ };
+ final DragGestureListener dgl = new DragGestureListener() {
+ public void dragGestureRecognized(DragGestureEvent dge) {
+ dge.startDrag(null, t, dsl);
+ }
+ };
+ final DragSource ds = DragSource.getDefaultDragSource();
+ final DragGestureRecognizer dgr =
+ ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY,
+ dgl);
+ }
+
+ public Dimension getPreferredSize() {
+ return new Dimension(100, 100);
+ }
+}
+
+class DropTargetPanel extends Panel {
+ private boolean testFailed = false;
+ public DropTargetPanel() {
+ final DropTargetListener dtl = new DropTargetAdapter() {
+ public void dragOver(DropTargetDragEvent dtde) {
+ try {
+ dtde.getCurrentDataFlavorsAsList();
+ } catch (Exception e) {
+ testFailed = true;
+ e.printStackTrace();
+ }
+ }
+ public void drop(DropTargetDropEvent dtde) {
+ dtde.rejectDrop();
+ }
+ };
+ final DropTarget dt = new DropTarget(this, dtl);
+ }
+
+ public boolean isTestFailed() {
+ return testFailed;
+ }
+
+ public Dimension getPreferredSize() {
+ return new Dimension(100, 100);
+ }
+}
+
+class ProcessResults {
+ public int exitValue;
+ public String stdout;
+ public String stderr;
+
+ public ProcessResults() {
+ exitValue = -1;
+ stdout = "";
+ stderr = "";
+ }
+
+ /**
+ * Method to perform a "wait" for a process and return its exit value.
+ * This is a workaround for <code>Process.waitFor()</code> never returning.
+ */
+ public static ProcessResults doWaitFor(Process p) {
+ ProcessResults pres = new ProcessResults();
+
+ InputStream in = null;
+ InputStream err = null;
+
+ try {
+ in = p.getInputStream();
+ err = p.getErrorStream();
+
+ boolean finished = false;
+
+ while (!finished) {
+ try {
+ while (in.available() > 0) {
+ pres.stdout += (char)in.read();
+ }
+ while (err.available() > 0) {
+ pres.stderr += (char)err.read();
+ }
+ // Ask the process for its exitValue. If the process
+ // is not finished, an IllegalThreadStateException
+ // is thrown. If it is finished, we fall through and
+ // the variable finished is set to true.
+ pres.exitValue = p.exitValue();
+ finished = true;
+ }
+ catch (IllegalThreadStateException e) {
+ // Process is not finished yet;
+ // Sleep a little to save on CPU cycles
+ Thread.currentThread().sleep(500);
+ }
+ }
+ if (in != null) in.close();
+ if (err != null) err.close();
+ }
+ catch (Throwable e) {
+ System.err.println("doWaitFor(): unexpected exception");
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ return pres;
+ }
+}
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+ {
+ private static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.show();
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.show();
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ }
+
+ }// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+ {
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("South", messageText);
+
+ pack();
+
+ show();
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ }
+
+ }// TestDialog class
--- a/jdk/test/java/awt/regtesthelpers/process/ProcessCommunicator.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/test/java/awt/regtesthelpers/process/ProcessCommunicator.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -25,21 +25,22 @@
import java.io.*;
-/** This class is created to solve interprocess communication problems.
+/**
+ * This class is created to solve interprocess communication problems.
* When you need to write a regression test which should verify inter jvm
* behavior such as DnD data transfer, Clipboard data transfer, focus
* transfer etc., you could use the next scenario:
*
* 1. Write an implementation for the parent JVM, using applet test.
- * 2. Write an implimentation for the child JVM or native application, using
+ * 2. Write an implementation for the child JVM or native application, using
* main() function.
* 3. Execute child process using ProcessCommunicator.executeChildProcess()
* method.
- * 4. You can decide whetherthe test is passed on the basis of
+ * 4. You can decide whether the test is passed on the basis of
* ProcessResults class data.
*
- * Note: The class is not thread safe. You should access its methods only from the same
- * thread.
+ * Note: The class is not thread safe. You should access its methods only from
+ * the same thread.
*/
public class ProcessCommunicator {
@@ -48,31 +49,34 @@
private static final String javaPath = javaHome + File.separator + "bin" +
File.separator + "java ";
private static String command = "";
+ private static volatile Process process;
private ProcessCommunicator() {}
- /** The same as {#link #executeChildProcess(Class,String)} except
- * the {@code classPathArgument} parameter. The class path
- * parameter is for the debug purposes
+ /**
+ * The same as {#link #executeChildProcess(Class,String)} except
+ * the {@code classPathArgument} parameter. The class path
+ * parameter is for the debug purposes
*
- * @param classToExecute is passed to the child JVM
- * @param classPathArguments class path for the child JVM
- * @param args arguments that will be passed to the executed class
- * @return results of the executed {@code Process}
+ * @param classToExecute is passed to the child JVM
+ * @param classPathArguments class path for the child JVM
+ * @param args arguments that will be passed to the executed class
+ * @return results of the executed {@code Process}
*/
public static ProcessResults executeChildProcess(final Class classToExecute,
final String classPathArguments, final String [] args)
{
try {
String command = buildCommand(classToExecute, classPathArguments, args);
- Process process = Runtime.getRuntime().exec(command);
+ process = Runtime.getRuntime().exec(command);
return doWaitFor(process);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
- /** Executes child {code Process}
+ /**
+ * Executes child {code Process}
*
* @param classToExecute class to be executed as a child java process
* @param args args to be passed in to the child process
@@ -86,11 +90,11 @@
/**
* Waits for a process and return its results.
- * This is a workaround for <code>Process.waitFor()</code> never returning.
+ * This is a workaround for {@code Process.waitFor()} never returning.
*
* @return results of the executed {@code Process}
*/
- private static ProcessResults doWaitFor(final Process p) {
+ public static ProcessResults doWaitFor(final Process p) {
ProcessResults pres = new ProcessResults();
final InputStream in;
@@ -133,13 +137,14 @@
return pres;
}
- /** Builds command on the basis of the passed class name,
- * class path and arguments.
+ /**
+ * Builds command on the basis of the passed class name,
+ * class path and arguments.
*
* @param classToExecute with class will be executed in the new JVM
* @param classPathArguments java class path (only for test purposes)
* @param args arguments for the new application. This could be used
- * to pass some information from the parnent to child JVM.
+ * to pass some information from the parent to child JVM.
* @return command to execute the {@code Process}
*/
private static String buildCommand(final Class classToExecute,
@@ -162,11 +167,24 @@
return command;
}
- /** Could be used for the debug purposes.
+ /**
+ * Could be used for the debug purposes.
*
- * @return command that was build to execute the child process
+ * @return command that was build to execute the child process
*/
public static String getExecutionCommand () {
return command;
}
+
+ /**
+ * Terminates the process created by {@code executeChildProcess} methods.
+ */
+ public static void destroyProcess() {
+ if (process != null) {
+ if (process.isAlive()) {
+ process.destroy();
+ }
+ process = null;
+ }
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/security/WarningWindowDisposeTest/WarningWindowDisposeCrashTest.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+/*
+ @test
+ @bug 8041490
+ @summary tests that the WarningWindow's surface is invalidated on dispose
+ @author Petr Pchelko
+ @run main/othervm WarningWindowDisposeCrashTest
+*/
+
+
+import sun.applet.AppletSecurity;
+import sun.awt.SunToolkit;
+
+import java.awt.*;
+
+public class WarningWindowDisposeCrashTest {
+ public static void main(String[] args) throws Exception {
+ System.setSecurityManager(new AppletSecurity() {
+ @Override
+ public void checkPackageAccess (String s){
+ }
+ });
+
+ Frame f = new Frame();
+ f.setVisible(true);
+ ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+ Thread.sleep(1000);
+ f.dispose();
+ // If the bug is present VM could crash after this call
+ for (int i = 0; i < 1000; i++) Toolkit.getDefaultToolkit().sync();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/Test8040656.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,311 @@
+/*
+ * 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.beans.Introspector;
+import java.beans.MethodDescriptor;
+
+/*
+ * @test
+ * @bug 8040656
+ * @summary Tests that a normal method is preferred to a synthetic one
+ * @author Sergey Malenkov
+ */
+
+public class Test8040656 {
+ public static void main(String[] args) throws Exception {
+ test(String.class, C.class);
+ test(String.class, C1.class);
+ test(String.class, C2.class);
+ test(String.class, C3.class);
+ test(String.class, C4.class);
+ test(String.class, C5.class);
+ test(String.class, C6.class);
+ test(String.class, C7.class);
+ test(String.class, C8.class);
+ test(String.class, C9.class);
+ }
+
+ private static void test(Class<?> type, Class<?> bean) throws Exception {
+ for (MethodDescriptor md : Introspector.getBeanInfo(bean).getMethodDescriptors()) {
+ if (md.getName().equals("getFoo")) {
+ if (type != md.getMethod().getReturnType()) {
+ throw new Error("unexpected type");
+ }
+ }
+ }
+ }
+
+ public interface A {
+ public Object getFoo();
+ }
+
+ public class C implements A {
+ @Override
+ public String getFoo() {
+ return null;
+ }
+ }
+
+ public class C1 implements A {
+ @Override
+ public String getFoo() {
+ return null;
+ }
+
+ public String getFoo1() {
+ return null;
+ }
+ }
+
+ public class C2 implements A {
+ @Override
+ public String getFoo() {
+ return null;
+ }
+
+ public String getFoo1() {
+ return null;
+ }
+
+ public String getFoo2() {
+ return null;
+ }
+ }
+
+ public class C3 implements A {
+ @Override
+ public String getFoo() {
+ return null;
+ }
+
+ public String getFoo1() {
+ return null;
+ }
+
+ public String getFoo2() {
+ return null;
+ }
+
+ public String getFoo3() {
+ return null;
+ }
+ }
+
+ public class C4 implements A {
+ @Override
+ public String getFoo() {
+ return null;
+ }
+
+ public String getFoo1() {
+ return null;
+ }
+
+ public String getFoo2() {
+ return null;
+ }
+
+ public String getFoo3() {
+ return null;
+ }
+
+ public String getFoo4() {
+ return null;
+ }
+ }
+
+ public class C5 implements A {
+ @Override
+ public String getFoo() {
+ return null;
+ }
+
+ public String getFoo1() {
+ return null;
+ }
+
+ public String getFoo2() {
+ return null;
+ }
+
+ public String getFoo3() {
+ return null;
+ }
+
+ public String getFoo4() {
+ return null;
+ }
+
+ public String getFoo5() {
+ return null;
+ }
+ }
+
+ public class C6 implements A {
+ @Override
+ public String getFoo() {
+ return null;
+ }
+
+ public String getFoo1() {
+ return null;
+ }
+
+ public String getFoo2() {
+ return null;
+ }
+
+ public String getFoo3() {
+ return null;
+ }
+
+ public String getFoo4() {
+ return null;
+ }
+
+ public String getFoo5() {
+ return null;
+ }
+
+ public String getFoo6() {
+ return null;
+ }
+ }
+
+ public class C7 implements A {
+ @Override
+ public String getFoo() {
+ return null;
+ }
+
+ public String getFoo1() {
+ return null;
+ }
+
+ public String getFoo2() {
+ return null;
+ }
+
+ public String getFoo3() {
+ return null;
+ }
+
+ public String getFoo4() {
+ return null;
+ }
+
+ public String getFoo5() {
+ return null;
+ }
+
+ public String getFoo6() {
+ return null;
+ }
+
+ public String getFoo7() {
+ return null;
+ }
+ }
+
+ public class C8 implements A {
+ @Override
+ public String getFoo() {
+ return null;
+ }
+
+ public String getFoo1() {
+ return null;
+ }
+
+ public String getFoo2() {
+ return null;
+ }
+
+ public String getFoo3() {
+ return null;
+ }
+
+ public String getFoo4() {
+ return null;
+ }
+
+ public String getFoo5() {
+ return null;
+ }
+
+ public String getFoo6() {
+ return null;
+ }
+
+ public String getFoo7() {
+ return null;
+ }
+
+ public String getFoo8() {
+ return null;
+ }
+ }
+
+ public class C9 implements A {
+ @Override
+ public String getFoo() {
+ return null;
+ }
+
+ public String getFoo1() {
+ return null;
+ }
+
+ public String getFoo2() {
+ return null;
+ }
+
+ public String getFoo3() {
+ return null;
+ }
+
+ public String getFoo4() {
+ return null;
+ }
+
+ public String getFoo5() {
+ return null;
+ }
+
+ public String getFoo6() {
+ return null;
+ }
+
+ public String getFoo7() {
+ return null;
+ }
+
+ public String getFoo8() {
+ return null;
+ }
+
+ public String getFoo9() {
+ return null;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/imageio/plugins/png/ReadMalformedPngTest.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,160 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 6945174
+ * @summary Test verifies that PNG image readr throw correct exception
+ * if image contains a chunk with incorrect length.
+ * @run main ReadMalformedPngTest
+ */
+
+import java.awt.Color;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import javax.imageio.IIOException;
+import javax.imageio.IIOImage;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageTypeSpecifier;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.ImageWriter;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.metadata.IIOMetadataNode;
+import javax.imageio.stream.ImageOutputStream;
+import org.w3c.dom.Node;
+
+public class ReadMalformedPngTest {
+
+ public static void main(String[] args) throws IOException {
+ ByteArrayInputStream bais = new ByteArrayInputStream(createTestPng());
+
+ IIOException expected = null;
+ try {
+ ImageIO.read(bais);
+ } catch (IIOException e) {
+ expected = e;
+ } catch (Throwable e) {
+ throw new RuntimeException("Test failed!", e);
+ }
+
+ if (expected == null) {
+ throw new RuntimeException("Test failed.");
+ }
+
+ System.out.println("Test passed.");
+ }
+
+ private static byte[] createTestPng() throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ BufferedImage img = createTestImage();
+
+ try {
+ ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
+
+ ImageWriter w = ImageIO.getImageWritersByFormatName("PNG").next();
+
+ w.setOutput(ios);
+
+ ImageWriteParam p = w.getDefaultWriteParam();
+
+ ImageTypeSpecifier t = ImageTypeSpecifier.createFromRenderedImage(img);
+
+ IIOMetadata m = w.getDefaultImageMetadata(t, p);
+
+ String nativeMetadataFormat = m.getNativeMetadataFormatName();
+
+ Node root = m.getAsTree(nativeMetadataFormat);
+
+ IIOMetadataNode textEntry = new IIOMetadataNode("tEXtEntry");
+ textEntry.setAttribute("keyword", "comment");
+ textEntry.setAttribute("value", "This is a test image for JDK-6945174");
+
+ IIOMetadataNode text = new IIOMetadataNode("tEXt");
+ text.appendChild(textEntry);
+
+ root.appendChild(text);
+
+ m.mergeTree(nativeMetadataFormat, root);
+
+ IIOImage iio_img = new IIOImage(img, null, m);
+
+ w.write(iio_img);
+
+ w.dispose();
+ ios.flush();
+ ios.close();
+ } catch (IOException e) {
+ throw new RuntimeException("Test failed.", e);
+ }
+
+ baos.flush();
+
+ byte[] data = baos.toByteArray();
+
+ adjustCommentLength(Integer.MAX_VALUE + 0x1000, data);
+
+ return data;
+ }
+
+ private static void adjustCommentLength(int v, byte[] data) {
+ final int pos = getCommentPos(data);
+ data[pos + 3] = (byte) (v & 0xFF);
+ v = v >> 8;
+ data[pos + 2] = (byte) (v & 0xFF);
+ v = v >> 8;
+ data[pos + 1] = (byte) (v & 0xFF);
+ v = v >> 8;
+ data[pos + 0] = (byte) (v & 0xFF);
+ }
+
+ private static int getCommentPos(byte[] d) {
+ int p = 8;
+ while (p + 8 < d.length) {
+ if (d[p + 4] == (byte) 0x74 && d[p + 5] == (byte) 0x45 &&
+ d[p + 6] == (byte) 0x58 && d[p + 7] == (byte) 0x74)
+ {
+ return p;
+ }
+ p++;
+ }
+ throw new RuntimeException("Test chunk was not found!");
+ }
+
+ private static BufferedImage createTestImage() {
+ final int w = 128;
+ final int h = 128;
+
+ BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_3BYTE_BGR);
+ Graphics2D g = img.createGraphics();
+ g.setPaint(new GradientPaint(0, 0, Color.blue,
+ w, h, Color.red));
+ g.fillRect(0, 0, w, h);
+ g.dispose();
+ return img;
+ }
+}
--- a/jdk/test/javax/swing/JMenuItem/8031573/bug8031573.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/test/javax/swing/JMenuItem/8031573/bug8031573.java Fri May 23 23:55:14 2014 +0000
@@ -28,7 +28,7 @@
import javax.swing.SwingUtilities;
/* @test
- * @bug 8031573
+ * @bug 8031573 8040279
* @summary [macosx] Checkmarks of JCheckBoxMenuItems aren't rendered
* in high resolution on Retina
* @author Alexander Scherbatiy
--- a/jdk/test/javax/swing/JOptionPane/8024926/bug8024926.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/test/javax/swing/JOptionPane/8024926/bug8024926.java Fri May 23 23:55:14 2014 +0000
@@ -31,7 +31,7 @@
/**
* @test
- * @bug 8024926
+ * @bug 8024926 8040279
* @summary [macosx] AquaIcon HiDPI support
* @author Alexander Scherbatiy
* @run applet/manual=yesno bug8024926.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JScrollBar/8039464/Test8039464.html Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,32 @@
+<!--
+ 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.
+-->
+
+<html>
+<body>
+Choose the variable applet size and try to resize the applet.
+The test passes the thumb is painted correctly.
+
+<applet width="400" height="200" code="Test8039464">
+</applet>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JScrollBar/8039464/Test8039464.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,92 @@
+/*
+ * 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.Container;
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+
+import javax.swing.JApplet;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JScrollBar;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+
+/*
+ * @test
+ * @bug 8039464
+ * @summary Tests enabling/disabling of titled border's caption
+ * @author Sergey Malenkov
+ * @run applet/manual=yesno Test8039464.html
+ */
+
+public class Test8039464 extends JApplet {
+ static {
+ try {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ } catch (Exception exception) {
+ throw new Error("unexpected", exception);
+ }
+ }
+
+ @Override
+ public void init() {
+ init(this);
+ }
+
+ private static void init(Container container) {
+ container.setLayout(new GridBagLayout());
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.fill = GridBagConstraints.BOTH;
+ gbc.gridx = 0;
+ gbc.gridy = 1;
+ JLabel label = new JLabel();
+ Dimension size = new Dimension(111, 0);
+ label.setPreferredSize(size);
+ label.setMinimumSize(size);
+ container.add(label, gbc);
+ gbc.gridx = 1;
+ gbc.weightx = 1;
+ container.add(new JScrollBar(JScrollBar.HORIZONTAL, 1, 111, 1, 1111), gbc);
+ gbc.gridx = 2;
+ gbc.gridy = 0;
+ gbc.weightx = 0;
+ gbc.weighty = 1;
+ container.add(new JScrollBar(JScrollBar.VERTICAL, 1, 111, 1, 1111), gbc);
+ }
+
+ public static void main(String[] args) throws Exception {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ JFrame frame = new JFrame("8039464");
+ init(frame);
+ frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ frame.pack();
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ }
+ });
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTextField/8036819/bug8036819.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,132 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @library ../../regtesthelpers
+ * @build Util
+ * @bug 8036819
+ * @summary JAB: mnemonics not read for textboxes
+ * @author Vivi An
+ * @run main bug8036819
+ */
+
+import javax.swing.*;
+import javax.swing.event.*;
+import java.awt.event.*;
+import java.awt.*;
+import sun.awt.SunToolkit;
+import javax.accessibility.*;
+
+public class bug8036819 {
+
+ public static volatile Boolean passed = false;
+
+ public static void main(String args[]) throws Throwable {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ createAndShowGUI();
+ }
+ });
+
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ toolkit.realSync();
+
+ Robot robo = new Robot();
+ robo.setAutoDelay(300);
+
+ // Using mnemonic key to focus on the textfield
+ Util.hitMnemonics(robo, KeyEvent.VK_P);
+ toolkit.realSync();
+
+ if (!passed){
+ throw new RuntimeException("Test failed.");
+ }
+ }
+
+ private static void createAndShowGUI() {
+ JFrame mainFrame = new JFrame("bug 8036819");
+
+ JLabel usernameLabel = new JLabel("Username: ");
+ JTextField usernameField = new JTextField(20);
+ usernameLabel.setDisplayedMnemonic(KeyEvent.VK_U);
+ usernameLabel.setLabelFor(usernameField);
+
+ JLabel pwdLabel = new JLabel("Password: ");
+ JTextField pwdField = new JTextField(20);
+ pwdLabel.setDisplayedMnemonic(KeyEvent.VK_P);
+ pwdLabel.setLabelFor(pwdField);
+
+ pwdField.addKeyListener(
+ new KeyListener(){
+ @Override
+ public void keyPressed(KeyEvent keyEvent) {
+ }
+
+ @Override
+ public void keyTyped(KeyEvent keyEvent) {
+ }
+
+ @Override
+ public void keyReleased(KeyEvent keyEvent){
+ JComponent comp = (JComponent) pwdField;
+ AccessibleContext ac = comp.getAccessibleContext();
+ AccessibleExtendedComponent aec = (AccessibleExtendedComponent)ac.getAccessibleComponent();
+ AccessibleKeyBinding akb = aec.getAccessibleKeyBinding();
+ if (akb != null){
+ int count = akb.getAccessibleKeyBindingCount();
+ if (count != 1){
+ passed = false;
+ return;
+ }
+
+ // there is 1 accessible key for the text field
+ System.out.println("Retrieved AccessibleKeyBinding for textfield " + count);
+
+ // the key code is KeyEvent.VK_P
+ Object o = akb.getAccessibleKeyBinding(0);
+ if (o instanceof KeyStroke){
+ javax.swing.KeyStroke key = (javax.swing.KeyStroke)o;
+ System.out.println("keystroke is " + key.getKeyCode());
+ if (key.getKeyCode() == KeyEvent.VK_P)
+ passed = true;
+ }
+ }
+ }
+ }
+ );
+
+ mainFrame.getContentPane().add(usernameLabel);
+ mainFrame.getContentPane().add(usernameField);
+ mainFrame.getContentPane().add(pwdLabel);
+ mainFrame.getContentPane().add(pwdField);
+
+ mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ mainFrame.setLayout(new FlowLayout(FlowLayout.LEFT));
+
+ mainFrame.setSize(200, 200);
+ mainFrame.setLocation(200, 200);
+ mainFrame.setVisible(true);
+ mainFrame.toFront();
+ }
+ }
--- a/jdk/test/javax/swing/border/Test4252164.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/test/javax/swing/border/Test4252164.java Fri May 23 23:55:14 2014 +0000
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 4252164
+ * @bug 4252164 8041917
* @summary Tests rounded LineBorder for components
* @author Sergey Malenkov
* @run applet/manual=yesno Test4252164.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/plaf/nimbus/8041725/bug8041725.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ */
+
+/* @test
+ @bug 8041725
+ @summary JList selection colors are not UIResource instances in Nimbus L&F
+ @author Anton Litvinov
+*/
+
+import java.awt.*;
+import javax.swing.*;
+import javax.swing.plaf.*;
+import javax.swing.plaf.nimbus.*;
+
+public class bug8041725 {
+ public static void main(String[] args) throws Exception {
+ UIManager.setLookAndFeel(new NimbusLookAndFeel());
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ JFrame frame = new JFrame("bug8041725");
+ frame.setSize(200, 200);
+ JList list = new JList(new String[]{"Item1", "Item2", "Item3"});
+ frame.getContentPane().add(list);
+ frame.pack();
+ frame.setVisible(true);
+
+ System.err.println("Test #1: No items are selected, list is enabled.");
+ testSelectionColors(list);
+
+ System.err.println("Test #2: No items are selected, list is disabled.");
+ list.setEnabled(false);
+ testSelectionColors(list);
+
+ System.err.println("Test #3: One item is selected, list is disabled.");
+ list.setSelectedIndex(0);
+ testSelectionColors(list);
+
+ System.err.println("Test #4: One item is selected, list is enabled.");
+ list.setEnabled(true);
+ testSelectionColors(list);
+
+ frame.dispose();
+ }
+ });
+ }
+
+ private static void testSelectionColors(JList list) {
+ Color selBackColor = list.getSelectionBackground();
+ if (!(selBackColor instanceof UIResource)) {
+ throw new RuntimeException(String.format(
+ "JList.getSelectionBackground() returned instance of '%s' instead of UIResource.",
+ selBackColor.getClass()));
+ }
+ Color selForeColor = list.getSelectionForeground();
+ if (!(selForeColor instanceof UIResource)) {
+ throw new RuntimeException(String.format(
+ "JList.getSelectionForeground() returned instance of '%s' instead of UIResource.",
+ selForeColor.getClass()));
+ }
+ }
+}
--- a/jdk/test/javax/swing/text/StyledEditorKit/8016833/bug8016833.java Thu May 22 20:24:42 2014 +0000
+++ b/jdk/test/javax/swing/text/StyledEditorKit/8016833/bug8016833.java Fri May 23 23:55:14 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -190,9 +190,9 @@
// not too wide
assertTrue(out3.getWidth() * 0.8 < out2.getWidth());
// not too low
- assertTrue(out3.getY() - (out1.getY() + out2.getHeight()) < 3);
+ assertTrue(out3.getY() - (out1.getY() + out2.getHeight() - 1) < 4);
// not too high
- assertTrue(out3.getY() - (out1.getY() + out2.getHeight()) > 0);
+ assertTrue(out3.getY() - (out1.getY() + out2.getHeight() - 1) > 0);
}
void testStrikthrough() {
@@ -217,7 +217,7 @@
// not too wide
assertTrue(out3.getWidth() * 0.8 < out2.getWidth());
// not too low
- assertTrue(out3.getY() - (out1.getY() + out2.getHeight()) < 0);
+ assertTrue(out3.getY() - (out1.getY() + out2.getHeight() - 1) < 0);
// not too high
assertTrue(out3.getY() - out1.getY() > 1);
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/xml/ws/8043129/MailTest.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,148 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8043129
+ * @summary JAF initialisation in SAAJ clashing with the one in javax.mail
+ * @author mkos
+ * @library javax.mail.jar
+ * @build MailTest
+ * @run main MailTest
+ */
+
+import javax.activation.CommandMap;
+import javax.activation.MailcapCommandMap;
+import javax.mail.BodyPart;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.Session;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+import javax.xml.soap.AttachmentPart;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+public class MailTest {
+
+ String host = null;
+ String user = "";
+ String password = null;
+ String from = null;
+ String to = null;
+
+ public static void main(String[] args) {
+ MailTest t = new MailTest();
+
+ t.user = "somebody@somewhere.com";
+ t.from = "somebody@somewhere.com";
+ t.to = "somebody@somewhere.com";
+
+ t.user = "somebody@somewhere.com";
+ t.password = "somepassword";
+ t.host = "somehost";
+
+ t.sendMail(); //this works
+
+ t.addSoapAttachement();
+ t.sendMail(); //after addAttachmentPart to soapmessage it do not work
+
+ // workaroundJAFSetup();
+ // t.sendMail(); //after workaround works again
+ }
+
+ void addSoapAttachement() {
+ try {
+ MessageFactory messageFactory = MessageFactory.newInstance();
+ SOAPMessage message = messageFactory.createMessage();
+ AttachmentPart a = message.createAttachmentPart();
+ a.setContentType("binary/octet-stream");
+ message.addAttachmentPart(a);
+ } catch (SOAPException e) {
+ e.printStackTrace();
+ }
+ }
+
+ void sendMail() {
+
+ try {
+ Properties props = new Properties();
+ props.put("mail.smtp.host", host);
+ props.put("mail.smtp.auth", "true");
+
+ Session session = Session.getInstance(props);
+ session.setDebug(true);
+
+ // Define message
+ MimeMessage message = new MimeMessage(session);
+ message.setFrom(new InternetAddress(from));
+ message.addRecipients(Message.RecipientType.TO, to);
+ message.setSubject("this is a multipart test");
+
+ Multipart multipart = new MimeMultipart();
+
+ BodyPart messageBodyPart1 = new MimeBodyPart();
+ messageBodyPart1.setText("please send also this Content\n ciao!");
+ multipart.addBodyPart(messageBodyPart1);
+
+ BodyPart messageBodyPart2 = new MimeBodyPart();
+ messageBodyPart2.setContent("<b>please</b> send also this Content <br>ciao!", "text/html; charset=UTF-8");
+ multipart.addBodyPart(messageBodyPart2);
+
+ message.setContent(multipart);
+
+ /*
+ Transport tr = session.getTransport("smtp");
+ tr.connect(host,user, password);
+ tr.sendMessage(message,InternetAddress.parse(to));
+ tr.close();
+ */
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ message.writeTo(baos);
+ String output = baos.toString();
+ System.out.println("output = " + output);
+ if (output.contains("also this Content")) {
+ System.out.println("Test PASSED.");
+ } else {
+ System.out.println("Test FAILED, missing content.");
+ throw new IllegalStateException("Test FAILED, missing content.");
+ }
+ } catch (MessagingException ignored) {
+ } catch (IOException ignored) {
+ }
+ }
+
+ // this is how the error can be worked around ...
+ static void workaroundJAFSetup() {
+ MailcapCommandMap mailMap = (MailcapCommandMap) CommandMap.getDefaultCommandMap();
+ mailMap.addMailcap("multipart/mixed;;x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
+ }
+}
Binary file jdk/test/javax/xml/ws/8043129/javax.mail.jar has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/awt/dnd/8024061/bug8024061.java Fri May 23 23:55:14 2014 +0000
@@ -0,0 +1,357 @@
+/*
+ * 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.
+ */
+
+/* @test
+ * @bug 8024061
+ * @summary Checks that no exception is thrown if dragGestureRecognized
+ * takes a while to complete.
+ */
+import sun.awt.OSInfo;
+import sun.awt.OSInfo.OSType;
+import sun.awt.SunToolkit;
+
+import java.awt.*;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.DragSourceDragEvent;
+import java.awt.dnd.DragSourceDropEvent;
+import java.awt.dnd.DragSourceEvent;
+import java.awt.dnd.DragSourceListener;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.DropTargetDragEvent;
+import java.awt.dnd.DropTargetDropEvent;
+import java.awt.dnd.DropTargetEvent;
+import java.awt.dnd.DropTargetListener;
+import java.awt.event.InputEvent;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import javax.swing.*;
+
+/**
+ * If dragGestureRecognized() takes a while to complete and if user performs a drag quickly,
+ * an exception is thrown from DropTargetListener.dragEnter when it calls
+ * DropTargetDragEvent.getTransferable().
+ * <p>
+ * This class introduces a delay in dragGestureRecognized() to cause the exception.
+ */
+public class bug8024061 {
+ private static final DataFlavor DropObjectFlavor;
+ private static final int DELAY = 1000;
+
+ private final DnDPanel panel1 = new DnDPanel(Color.yellow);
+ private final DnDPanel panel2 = new DnDPanel(Color.pink);
+ private final JFrame frame;
+
+ private static final CountDownLatch lock = new CountDownLatch(1);
+ private static volatile Exception dragEnterException = null;
+
+ static {
+ DataFlavor flavor = null;
+ try {
+ flavor = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType);
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ DropObjectFlavor = flavor;
+ }
+
+ bug8024061() {
+ frame = new JFrame("DnDWithRobot");
+ frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+
+ Dimension d = new Dimension(100, 100);
+
+ panel1.setPreferredSize(d);
+ panel2.setPreferredSize(d);
+
+ Container content = frame.getContentPane();
+ content.setLayout(new GridLayout(1, 2, 5, 5));
+ content.add(panel1);
+ content.add(panel2);
+
+ frame.pack();
+
+ DropObject drop = new DropObject();
+ drop.place(panel1, new Point(10, 10));
+ frame.setVisible(true);
+ }
+
+ public static void main(String[] args) throws AWTException, InvocationTargetException, InterruptedException {
+ OSType type = OSInfo.getOSType();
+ if (type != OSType.LINUX && type != OSType.SOLARIS) {
+ System.out.println("This test is for Linux and Solaris only... " +
+ "skipping!");
+ return;
+ }
+
+ final bug8024061[] dnd = {null};
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ dnd[0] = new bug8024061();
+ }
+ });
+ final Robot robot = new Robot();
+ robot.setAutoDelay(10);
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ toolkit.realSync();
+
+ JFrame frame = dnd[0].frame;
+ Point point = frame.getLocationOnScreen();
+ Point here = new Point(point.x + 35, point.y + 45);
+ Point there = new Point(point.x + 120, point.y + 45);
+ here.x += 25;
+ robot.mouseMove(here.x, here.y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ while (here.x < there.x) {
+ here.x += 20;
+ robot.mouseMove(here.x, here.y);
+ System.out.println("x = " + here.x);
+ }
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ toolkit.realSync();
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ System.out.println("finished");
+
+ try {
+ if (lock.await(5, TimeUnit.SECONDS)) {
+ if (dragEnterException == null) {
+ System.out.println("Test passed.");
+ } else {
+ System.out.println("Test failed.");
+ dragEnterException.printStackTrace();
+ throw new RuntimeException(dragEnterException);
+ }
+ } else {
+ System.out.println("Test failed. Timeout reached");
+ throw new RuntimeException("Timed out waiting for dragEnter()");
+ }
+ } finally {
+ frame.dispose();
+ }
+ }
+
+ class DropObject implements Transferable {
+ DnDPanel panel;
+ Color color = Color.CYAN;
+ int width = 50;
+ int height = 50;
+ int x;
+ int y;
+
+ void draw(Graphics2D g) {
+ Color savedColor = g.getColor();
+ g.setColor(color);
+ g.fillRect(x, y, width, height);
+ g.setColor(Color.lightGray);
+ g.drawRect(x, y, width, height);
+ g.setColor(savedColor);
+ }
+
+ boolean contains(int x, int y) {
+ return (x > this.x && x < this.x + width)
+ && (y > this.y && y < this.y + height);
+ }
+
+ @Override
+ public DataFlavor[] getTransferDataFlavors() {
+ return new DataFlavor[]{DropObjectFlavor};
+ }
+
+ void place(DnDPanel panel, Point location) {
+ if (panel != this.panel) {
+ x = location.x;
+ y = location.y;
+ if (this.panel != null) {
+ this.panel.setDropObject(null);
+ this.panel.repaint();
+ }
+ this.panel = panel;
+ this.panel.setDropObject(this);
+ this.panel.repaint();
+ }
+ }
+
+ @Override
+ public boolean isDataFlavorSupported(DataFlavor flavor) {
+ return DropObjectFlavor.equals(flavor);
+ }
+
+ @Override
+ public Object getTransferData(DataFlavor flavor)
+ throws UnsupportedFlavorException, IOException {
+ if (isDataFlavorSupported(flavor)) {
+ return this;
+ } else {
+ throw new UnsupportedFlavorException(flavor);
+ }
+ }
+ }
+
+ class DnDPanel extends JPanel {
+ DropObject dropObject;
+ final DragSource dragSource;
+ final DropTarget dropTarget;
+ final Color color;
+ final DragGestureListener dgListener;
+ final DragSourceListener dsListener;
+ final DropTargetListener dtListener;
+
+ DnDPanel(Color color) {
+ this.color = color;
+ this.dragSource = DragSource.getDefaultDragSource();
+ dgListener = new DragGestureListener() {
+ @Override
+ public void dragGestureRecognized(DragGestureEvent dge) {
+ Point location = dge.getDragOrigin();
+ if (dropObject != null && dropObject.contains(location.x, location.y)) {
+ dragSource.startDrag(dge, DragSource.DefaultCopyNoDrop, dropObject, dsListener);
+ try {
+ Thread.sleep(DELAY);
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+ };
+
+ dsListener = new DragSourceListener() {
+ @Override
+ public void dragEnter(DragSourceDragEvent dsde) {
+ }
+
+ @Override
+ public void dragOver(DragSourceDragEvent dsde) {
+ }
+
+ @Override
+ public void dropActionChanged(DragSourceDragEvent dsde) {
+ }
+
+ @Override
+ public void dragExit(DragSourceEvent dse) {
+ }
+
+ @Override
+ public void dragDropEnd(DragSourceDropEvent dsde) {
+ }
+ };
+
+ dtListener = new DropTargetListener() {
+ @Override
+ public void dragEnter(DropTargetDragEvent dtde) {
+ if (dropObject != null) {
+ dtde.rejectDrag();
+ return;
+ }
+ dtde.acceptDrag(DnDConstants.ACTION_MOVE);
+ try {
+ Transferable t = dtde.getTransferable();
+ Object data = t.getTransferData(DropObjectFlavor);
+ if (data != null) {
+ throw new Exception("getTransferData returned non-null");
+ }
+ } catch (Exception e) {
+ dragEnterException = e;
+ e.printStackTrace();
+ } finally {
+ lock.countDown();
+ }
+ }
+
+ @Override
+ public void dragOver(DropTargetDragEvent dtde) {
+ if (dropObject != null) {
+ dtde.rejectDrag();
+ return;
+ }
+ dtde.acceptDrag(DnDConstants.ACTION_MOVE);
+ }
+
+ @Override
+ public void dropActionChanged(DropTargetDragEvent dtde) {
+ }
+
+ @Override
+ public void dragExit(DropTargetEvent dte) {
+ }
+
+ @Override
+ public void drop(DropTargetDropEvent dtde) {
+ if (dropObject != null) {
+ dtde.rejectDrop();
+ return;
+ }
+ try {
+ dtde.acceptDrop(DnDConstants.ACTION_MOVE);
+ Transferable t = dtde.getTransferable();
+ DropObject dropObject = (DropObject) t.getTransferData(DropObjectFlavor);
+ Point location = dtde.getLocation();
+ dropObject.place(DnDPanel.this, location);
+ dtde.dropComplete(true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+ };
+
+ dragSource.createDefaultDragGestureRecognizer(this,
+ DnDConstants.ACTION_MOVE, dgListener);
+
+ dropTarget = new DropTarget(this, DnDConstants.ACTION_MOVE, dtListener, true);
+
+ }
+
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ Color savedColor = g.getColor();
+ g.setColor(color);
+ g.fillRect(0, 0, getWidth(), getHeight());
+ g.setColor(savedColor);
+ if (dropObject != null) {
+ dropObject.draw((Graphics2D) g);
+ }
+ }
+
+ void setDropObject(DropObject dropObject) {
+ this.dropObject = dropObject;
+ }
+
+ DropObject findDropObject(int x, int y) {
+ if (dropObject != null && dropObject.contains(x, y)) {
+ return dropObject;
+ }
+ return null;
+ }
+ }
+}