changeset 9258:6f4f5deb880d

Merge
author kvn
date Thu, 13 Mar 2014 14:55:50 -0700
parents a05bd28cef7f (current diff) 3c891a39428a (diff)
children 91cb60617489
files src/macosx/classes/sun/lwawt/macosx/event/NSEvent.java src/macosx/native/sun/awt/CWrapper.h src/solaris/native/java/net/PlainSocketImpl.c
diffstat 98 files changed, 3024 insertions(+), 1078 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Wed Feb 26 19:26:42 2014 +0100
+++ b/.hgtags	Thu Mar 13 14:55:50 2014 -0700
@@ -253,3 +253,6 @@
 fbf251b8ef8a4a2aa1fd58efc8d0d5c8e2fd582b jdk8-b127
 f644211c59fd7c1d0c81239c55b31e1d377d7650 jdk8-b128
 80568a19aab7300bc92baf2dc225be929f5b03ed jdk8-b129
+43386cc9a017a9f9e704760050086bb18b778ae0 jdk8-b130
+e291ac47c9a90366c3c0787a6f7ce547a2bda308 jdk8-b131
+43cb25339b5500871f41388a5197f1b01c4b57b8 jdk8-b132
--- a/make/mapfiles/libjava/mapfile-vers	Wed Feb 26 19:26:42 2014 +0100
+++ b/make/mapfiles/libjava/mapfile-vers	Thu Mar 13 14:55:50 2014 -0700
@@ -79,7 +79,7 @@
 		Java_java_io_FileInputStream_close0;
 		Java_java_io_FileInputStream_initIDs;
 		Java_java_io_FileInputStream_open;
-		Java_java_io_FileInputStream_read;
+		Java_java_io_FileInputStream_read0;
 		Java_java_io_FileInputStream_readBytes;
 		Java_java_io_FileInputStream_skip;
 		Java_java_io_FileOutputStream_close0;
@@ -98,11 +98,11 @@
 		Java_java_io_RandomAccessFile_initIDs;
 		Java_java_io_RandomAccessFile_length;
 		Java_java_io_RandomAccessFile_open;
-		Java_java_io_RandomAccessFile_read;
+		Java_java_io_RandomAccessFile_read0;
 		Java_java_io_RandomAccessFile_readBytes;
 		Java_java_io_RandomAccessFile_seek0;
 		Java_java_io_RandomAccessFile_setLength;
-		Java_java_io_RandomAccessFile_write;
+		Java_java_io_RandomAccessFile_write0;
 		Java_java_io_RandomAccessFile_writeBytes;
 		Java_java_io_UnixFileSystem_canonicalize0;
 		Java_java_io_UnixFileSystem_checkAccess;
--- a/make/mapfiles/libjfr/mapfile-vers	Wed Feb 26 19:26:42 2014 +0100
+++ b/make/mapfiles/libjfr/mapfile-vers	Thu Mar 13 14:55:50 2014 -0700
@@ -34,6 +34,7 @@
       Java_oracle_jrockit_jfr_VMJFR_getPeriod;
       Java_oracle_jrockit_jfr_VMJFR_descriptors;
       Java_oracle_jrockit_jfr_VMJFR_redefineClass0;
+      Java_oracle_jrockit_jfr_VMJFR_retransformClasses0;
       JNI_OnLoad;
   local:
       *;
--- a/src/macosx/classes/com/apple/laf/AquaImageFactory.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/classes/com/apple/laf/AquaImageFactory.java	Thu Mar 13 14:55:50 2014 -0700
@@ -48,6 +48,7 @@
 import com.apple.laf.AquaUtils.RecyclableSingleton;
 import java.util.Arrays;
 import java.util.List;
+import sun.awt.image.MultiResolutionBufferedImage;
 import sun.awt.image.MultiResolutionImage;
 
 public class AquaImageFactory {
@@ -230,7 +231,7 @@
 
         @Override
         protected Image getInstance() {
-            return Toolkit.getDefaultToolkit().getImage("NSImage://" + namedImage);
+            return getNSIcon(namedImage);
         }
     }
 
@@ -294,11 +295,27 @@
     }
 
     public static Icon getMenuItemCheckIcon() {
-        return new InvertableImageIcon(AquaUtils.generateLightenedImage(Toolkit.getDefaultToolkit().getImage("NSImage://NSMenuItemSelection"), 25));
+        return new InvertableImageIcon(AquaUtils.generateLightenedImage(
+                getNSIcon("NSMenuItemSelection"), 25));
     }
 
     public static Icon getMenuItemDashIcon() {
-        return new InvertableImageIcon(AquaUtils.generateLightenedImage(Toolkit.getDefaultToolkit().getImage("NSImage://NSMenuMixedState"), 25));
+        return new InvertableImageIcon(AquaUtils.generateLightenedImage(
+                getNSIcon("NSMenuMixedState"), 25));
+    }
+
+    private static Image getNSIcon(String imageName) {
+        Image icon = Toolkit.getDefaultToolkit()
+                .getImage("NSImage://" + imageName);
+
+        if (icon instanceof MultiResolutionImage) {
+            return icon;
+        }
+
+        Image icon2x = AquaUtils.getCImageCreator().createImageFromName(
+                imageName, 2 * icon.getWidth(null), 2 * icon.getHeight(null));
+        return new MultiResolutionBufferedImage(
+                BufferedImage.TYPE_INT_ARGB_PRE, 0, icon, icon2x);
     }
 
     public static class NineSliceMetrics {
--- a/src/macosx/classes/com/apple/laf/AquaUtils.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/classes/com/apple/laf/AquaUtils.java	Thu Mar 13 14:55:50 2014 -0700
@@ -48,6 +48,7 @@
 import sun.swing.SwingUtilities2;
 
 import com.apple.laf.AquaImageFactory.SlicedImageControl;
+import sun.awt.image.MultiResolutionBufferedImage;
 
 final class AquaUtils {
 
@@ -123,6 +124,13 @@
 
     static Image generateLightenedImage(final Image image, final int percent) {
         final GrayFilter filter = new GrayFilter(true, percent);
+        return (image instanceof MultiResolutionBufferedImage)
+                ? ((MultiResolutionBufferedImage) image).map(
+                        rv -> generateLightenedImage(rv, filter))
+                : generateLightenedImage(image, filter);
+    }
+
+    static Image generateLightenedImage(Image image, ImageFilter filter) {
         final ImageProducer prod = new FilteredImageSource(image.getSource(), filter);
         return Toolkit.getDefaultToolkit().createImage(prod);
     }
--- a/src/macosx/classes/sun/lwawt/LWChoicePeer.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/classes/sun/lwawt/LWChoicePeer.java	Thu Mar 13 14:55:50 2014 -0700
@@ -168,16 +168,16 @@
         @Override
         public void firePopupMenuWillBecomeVisible() {
             super.firePopupMenuWillBecomeVisible();
-            SwingUtilities.invokeLater(new Runnable() {
-                @Override
-                public void run() {
-                    JPopupMenu popupMenu = getPopupMenu();
-                    if (popupMenu != null) {
-                        if (popupMenu.getInvoker() != LWChoicePeer.this.getTarget()) {
-                            popupMenu.setVisible(false);
-                            popupMenu.show(LWChoicePeer.this.getTarget(), 0, 0);
-                        }
-                    }
+            SwingUtilities.invokeLater(() -> {
+                JPopupMenu popupMenu = getPopupMenu();
+                // Need to override the invoker for proper grab handling
+                if (popupMenu != null && 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();
+                    SwingUtilities.convertPointFromScreen(loc, this);
+                    popupMenu.setVisible(false);
+                    popupMenu.show(getTarget(), loc.x, loc.y);
                 }
             });
         }
--- a/src/macosx/classes/sun/lwawt/LWWindowPeer.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/classes/sun/lwawt/LWWindowPeer.java	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -684,7 +684,7 @@
     public void notifyNCMouseDown() {
         // Ungrab except for a click on a Dialog with the grabbing owner
         if (grabbingWindow != null &&
-            grabbingWindow != getOwnerFrameDialog(this))
+            !grabbingWindow.isOneOfOwnersOf(this))
         {
             grabbingWindow.ungrab();
         }
@@ -779,7 +779,7 @@
 
                 // Ungrab only if this window is not an owned window of the grabbing one.
                 if (!isGrabbing() && grabbingWindow != null &&
-                    grabbingWindow != getOwnerFrameDialog(this))
+                    !grabbingWindow.isOneOfOwnersOf(this))
                 {
                     grabbingWindow.ungrab();
                 }
@@ -1232,6 +1232,17 @@
         changeFocusedWindow(activate, null);
     }
 
+    private boolean isOneOfOwnersOf(LWWindowPeer peer) {
+        Window owner = (peer != null ? peer.getTarget().getOwner() : null);
+        while (owner != null) {
+            if ((LWWindowPeer)owner.getPeer() == this) {
+                return true;
+            }
+            owner = owner.getOwner();
+        }
+        return false;
+    }
+
     /*
      * Changes focused window on java level.
      */
@@ -1263,7 +1274,7 @@
         // - when the opposite (gaining focus) window is an owned/owner window.
         // - for a simple window in any case.
         if (!becomesFocused &&
-            (isGrabbing() || getOwnerFrameDialog(grabbingWindow) == this))
+            (isGrabbing() || this.isOneOfOwnersOf(grabbingWindow)))
         {
             if (focusLog.isLoggable(PlatformLogger.Level.FINE)) {
                 focusLog.fine("ungrabbing on " + grabbingWindow);
@@ -1282,6 +1293,11 @@
         postEvent(windowEvent);
     }
 
+    /*
+     * Retrieves the owner of the peer.
+     * Note: this method returns the owner which can be activated, (i.e. the instance
+     * of Frame or Dialog may be returned).
+     */
     static LWWindowPeer getOwnerFrameDialog(LWWindowPeer peer) {
         Window owner = (peer != null ? peer.getTarget().getOwner() : null);
         while (owner != null && !(owner instanceof Frame || owner instanceof Dialog)) {
--- a/src/macosx/classes/sun/lwawt/macosx/CClipboard.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/classes/sun/lwawt/macosx/CClipboard.java	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -40,20 +40,23 @@
  * sun.awt.datatransfer.DataTransferer.
  */
 
-public class CClipboard extends SunClipboard {
+final class CClipboard extends SunClipboard {
 
     public CClipboard(String name) {
         super(name);
     }
 
+    @Override
     public long getID() {
         return 0;
     }
 
+    @Override
     protected void clearNativeContext() {
         // Leaving Empty, as WClipboard.clearNativeContext is empty as well.
     }
 
+    @Override
     protected void setContentsNative(Transferable contents) {
 
         // Don't use delayed Clipboard rendering for the Transferable's data.
@@ -89,6 +92,39 @@
         notifyChanged();
     }
 
+    @Override
+    protected native long[] getClipboardFormats();
+    @Override
+    protected native byte[] getClipboardData(long format) throws IOException;
+
+    // 1.5 peer method
+    @Override
+    protected void unregisterClipboardViewerChecked() {
+        // no-op because we lack OS support. This requires 4048791, which requires 4048792
+    }
+
+    // 1.5 peer method
+    @Override
+    protected void registerClipboardViewerChecked()    {
+        // no-op because we lack OS support. This requires 4048791, which requires 4048792
+    }
+
+    // 1.5 peer method
+    // no-op. This appears to be win32 specific. Filed 4048790 for investigation
+    //protected Transferable createLocaleTransferable(long[] formats) throws IOException;
+
+    private native void declareTypes(long[] formats, SunClipboard newOwner);
+    private native void setData(byte[] data, long format);
+
+    /**
+     * Invokes native check whether a change count on the general pasteboard is different
+     * than when we set it. The different count value means the current owner lost
+     * pasteboard ownership and someone else put data on the clipboard.
+     * @since 1.7
+     */
+    native void checkPasteboard();
+
+    /*** Native Callbacks ***/
     private void notifyLostOwnership() {
         lostOwnershipImpl();
     }
@@ -100,32 +136,4 @@
         }
         clipboard.checkChange(clipboard.getClipboardFormats());
     }
-
-    protected native long[] getClipboardFormats();
-    protected native byte[] getClipboardData(long format) throws IOException;
-
-    // 1.5 peer method
-    protected void unregisterClipboardViewerChecked() {
-        // no-op because we lack OS support. This requires 4048791, which requires 4048792
-    }
-
-    // 1.5 peer method
-    protected void registerClipboardViewerChecked()    {
-        // no-op because we lack OS support. This requires 4048791, which requires 4048792
-    }
-
-    // 1.5 peer method
-    // no-op. This appears to be win32 specific. Filed 4048790 for investigation
-    //protected Transferable createLocaleTransferable(long[] formats) throws IOException;
-
-    public native void declareTypes(long[] formats, SunClipboard newOwner);
-    public native void setData(byte[] data, long format);
-
-    /**
-     * Invokes native check whether a change count on the general pasteboard is different
-     * than when we set it. The different count value means the current owner lost
-     * pasteboard ownership and someone else put data on the clipboard.
-     * @since 1.7
-     */
-    public native void checkPasteboard();
 }
--- a/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -56,11 +56,11 @@
     };
 
     static {
-        Map<String, Long> nameMap = new HashMap<String, Long>(predefinedClipboardNames.length, 1.0f);
-        Map<Long, String> formatMap = new HashMap<Long, String>(predefinedClipboardNames.length, 1.0f);
+        Map<String, Long> nameMap = new HashMap<>(predefinedClipboardNames.length, 1.0f);
+        Map<Long, String> formatMap = new HashMap<>(predefinedClipboardNames.length, 1.0f);
         for (int i = 1; i < predefinedClipboardNames.length; i++) {
-            nameMap.put(predefinedClipboardNames[i], new Long(i));
-            formatMap.put(new Long(i), predefinedClipboardNames[i]);
+            nameMap.put(predefinedClipboardNames[i], (long) i);
+            formatMap.put((long) i, predefinedClipboardNames[i]);
         }
         predefinedClipboardNameMap = Collections.synchronizedMap(nameMap);
         predefinedClipboardFormatMap = Collections.synchronizedMap(formatMap);
@@ -77,19 +77,11 @@
     public static final int CF_PNG         = 10;
     public static final int CF_JPEG        = 11;
 
-    public static final Long L_CF_TIFF = predefinedClipboardNameMap.get(predefinedClipboardNames[CF_TIFF]);
-
-    // Image file formats with java.awt.Image representation:
-    private static final Long[] imageFormats = new Long[] {
-        L_CF_TIFF
-    };
-
-
     private CDataTransferer() {}
 
     private static CDataTransferer fTransferer;
 
-    public static synchronized CDataTransferer getInstanceImpl() {
+    static synchronized CDataTransferer getInstanceImpl() {
         if (fTransferer == null) {
             fTransferer = new CDataTransferer();
         }
@@ -97,18 +89,22 @@
         return fTransferer;
     }
 
+    @Override
     public String getDefaultUnicodeEncoding() {
         return "utf-16le";
     }
 
+    @Override
     public boolean isLocaleDependentTextFormat(long format) {
         return format == CF_STRING;
     }
 
+    @Override
     public boolean isFileFormat(long format) {
         return format == CF_FILE;
     }
 
+    @Override
     public boolean isImageFormat(long format) {
         int ifmt = (int)format;
         switch(ifmt) {
@@ -122,43 +118,12 @@
         }
     }
 
-    protected Long[] getImageFormatsAsLongArray() {
-        return imageFormats;
-    }
-
-    public byte[] translateTransferable(Transferable contents, DataFlavor flavor, long format) throws IOException
-        {
-            byte[] bytes = super.translateTransferable(contents, flavor, format);
-
-            // 9-12-02 VL: we may need to do something like Windows here.
-            //if (format == CF_HTML) {
-            //    bytes = HTMLSupport.convertToHTMLFormat(bytes);
-            //}
-
-            return bytes;
-        }
-
-    protected Object translateBytesOrStream(InputStream stream, byte[] bytes, DataFlavor flavor, long format,
-                                            Transferable transferable) throws IOException
-        {
-            // 5-28-03 VL: [Radar 3266030]
-            // We need to do like Windows does here.
-            if (format == CF_HTML && flavor.isFlavorTextType()) {
-                if (stream == null) {
-                    stream = new ByteArrayInputStream(bytes);
-                    bytes = null;
-                }
-
-                stream = new HTMLDecodingInputStream(stream);
-            }
+    @Override
+    public Object translateBytes(byte[] bytes, DataFlavor flavor,
+                                    long format, Transferable transferable) throws IOException {
 
             if (format == CF_URL && URL.class.equals(flavor.getRepresentationClass()))
             {
-                if (bytes == null) {
-                    bytes = inputStreamToByteArray(stream);
-                    stream = null;
-                }
-
                 String charset = getDefaultTextCharset();
                 if (transferable != null && transferable.isDataFlavorSupported(javaTextEncodingFlavor)) {
                     try {
@@ -175,9 +140,9 @@
             }
 
             return super.translateBytes(bytes, flavor, format, transferable);
-        }
+    }
 
-
+    @Override
     synchronized protected Long getFormatForNativeAsLong(String str) {
         Long format = predefinedClipboardNameMap.get(str);
 
@@ -202,6 +167,7 @@
     // Get registered native format string for an index, return null if unknown:
     private native String formatForIndex(long index);
 
+    @Override
     protected String getNativeForFormat(long format) {
         String returnValue = null;
 
@@ -209,7 +175,7 @@
         if (format >= 0 && format < predefinedClipboardNames.length) {
             returnValue = predefinedClipboardNames[(int) format];
         } else {
-            Long formatObj = new Long(format);
+            Long formatObj = format;
             returnValue = predefinedClipboardFormatMap.get(formatObj);
 
             // predefinedClipboardFormatMap may not know this format:
@@ -233,10 +199,13 @@
 
     private final ToolkitThreadBlockedHandler handler = new CToolkitThreadBlockedHandler();
 
+    @Override
     public ToolkitThreadBlockedHandler getToolkitThreadBlockedHandler() {
         return handler;
     }
 
+    private native byte[] imageDataToPlatformImageBytes(int[] rData, int nW, int nH);
+    @Override
     protected byte[] imageToPlatformBytes(Image image, long format) {
         int w = image.getWidth(null);
         int h = image.getHeight(null);
@@ -252,32 +221,28 @@
     }
 
     private static native String[] nativeDragQueryFile(final byte[] bytes);
+    @Override
     protected String[] dragQueryFile(final byte[] bytes) {
         if (bytes == null) return null;
         if (new String(bytes).startsWith("Unsupported type")) return null;
         return nativeDragQueryFile(bytes);
     }
 
-    private native byte[] imageDataToPlatformImageBytes(int[] rData, int nW, int nH);
-
+    private native Image getImageForByteStream(byte[] bytes);
     /**
      * Translates a byte array which contains
      * platform-specific image data in the given format into an Image.
      */
-    protected Image platformImageBytesToImage(byte[] bytes, long format)
-        throws IOException
-    {
+    @Override
+    protected Image platformImageBytesToImage(byte[] bytes, long format) throws IOException {
         return getImageForByteStream(bytes);
     }
 
-    private native Image getImageForByteStream(byte[] bytes);
-
     @Override
     protected ByteArrayOutputStream convertFileListToBytes(ArrayList<String> fileList) throws IOException {
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        for (int i = 0; i < fileList.size(); i++)
-        {
-            byte[] bytes = fileList.get(i).getBytes();
+        for (String file : fileList) {
+            byte[] bytes = file.getBytes();
             bos.write(bytes, 0, bytes.length);
             bos.write(0);
         }
@@ -303,246 +268,3 @@
 }
 
 
-// ---- Code borrowed from WDataTransferer: ----
-// This will come handy for supporting HTML data.
-
-final class HTMLSupport {
-    public static final String ENCODING = "UTF-8";
-
-    public static final String VERSION = "Version:";
-    public static final String START_HTML = "StartHTML:";
-    public static final String END_HTML = "EndHTML:";
-    public static final String START_FRAGMENT = "StartFragment:";
-    public static final String END_FRAGMENT = "EndFragment:";
-    public static final String START_FRAGMENT_CMT = "<!--StartFragment-->";
-    public static final String END_FRAGMENT_CMT = "<!--EndFragment-->";
-    public static final String EOLN = "\r\n";
-
-    private static final String VERSION_NUM = "0.9";
-    private static final String HTML_START_END = "-1";
-
-    private static final int PADDED_WIDTH = 10;
-
-    private static final int HEADER_LEN =
-        VERSION.length() + VERSION_NUM.length() + EOLN.length() +
-        START_HTML.length() + HTML_START_END.length() + EOLN.length() +
-        END_HTML.length() + HTML_START_END.length() + EOLN.length() +
-        START_FRAGMENT.length() + PADDED_WIDTH + EOLN.length() +
-        END_FRAGMENT.length() + PADDED_WIDTH + EOLN.length() +
-        START_FRAGMENT_CMT.length() + EOLN.length();
-    private static final String HEADER_LEN_STR =
-        toPaddedString(HEADER_LEN, PADDED_WIDTH);
-
-    private static final String TRAILER = END_FRAGMENT_CMT + EOLN + '\0';
-
-    private static String toPaddedString(int n, int width) {
-        String string = "" + n;
-        int len = string.length();
-        if (n >= 0 && len < width) {
-            char[] array = new char[width - len];
-            Arrays.fill(array, '0');
-            StringBuffer buffer = new StringBuffer();
-            buffer.append(array);
-            buffer.append(string);
-            string = buffer.toString();
-        }
-        return string;
-    }
-
-    public static byte[] convertToHTMLFormat(byte[] bytes) {
-        StringBuffer header = new StringBuffer(HEADER_LEN);
-        header.append(VERSION);
-        header.append(VERSION_NUM);
-        header.append(EOLN);
-        header.append(START_HTML);
-        header.append(HTML_START_END);
-        header.append(EOLN);
-        header.append(END_HTML);
-        header.append(HTML_START_END);
-        header.append(EOLN);
-        header.append(START_FRAGMENT);
-        header.append(HEADER_LEN_STR);
-        header.append(EOLN);
-        header.append(END_FRAGMENT);
-        // Strip terminating NUL byte from array
-        header.append(toPaddedString(HEADER_LEN + bytes.length - 1,
-                                     PADDED_WIDTH));
-        header.append(EOLN);
-        header.append(START_FRAGMENT_CMT);
-        header.append(EOLN);
-
-        byte[] headerBytes = null, trailerBytes = null;
-
-        try {
-            headerBytes = new String(header).getBytes(ENCODING);
-            trailerBytes = TRAILER.getBytes(ENCODING);
-        } catch (UnsupportedEncodingException cannotHappen) {
-        }
-
-        byte[] retval = new byte[headerBytes.length + bytes.length - 1 +
-            trailerBytes.length];
-
-        System.arraycopy(headerBytes, 0, retval, 0, headerBytes.length);
-        System.arraycopy(bytes, 0, retval, headerBytes.length,
-                         bytes.length - 1);
-        System.arraycopy(trailerBytes, 0, retval,
-                         headerBytes.length + bytes.length - 1,
-                         trailerBytes.length);
-
-        return retval;
-    }
-}
-
-/**
-* This stream takes an InputStream which provides data in CF_HTML format,
- * strips off the description and context to extract the original HTML data.
- */
-class HTMLDecodingInputStream extends InputStream {
-
-    private final BufferedInputStream bufferedStream;
-    private boolean descriptionParsed = false;
-    private boolean closed = false;
-    private int index;
-    private int end;
-
-    // InputStreamReader uses an 8K buffer. The size is not customizable.
-    public static final int BYTE_BUFFER_LEN = 8192;
-
-    // CharToByteUTF8.getMaxBytesPerChar returns 3, so we should not buffer
-    // more chars than 3 times the number of bytes we can buffer.
-    public static final int CHAR_BUFFER_LEN = BYTE_BUFFER_LEN / 3;
-
-    private static final String FAILURE_MSG =
-        "Unable to parse HTML description: ";
-    private static final String INVALID_MSG = " invalid";
-
-    public HTMLDecodingInputStream(InputStream bytestream) throws IOException {
-        bufferedStream = new BufferedInputStream(bytestream, BYTE_BUFFER_LEN);
-    }
-
-    private void parseDescription() throws IOException {
-        bufferedStream.mark(BYTE_BUFFER_LEN);
-
-        BufferedReader bufferedReader = new BufferedReader
-            (new InputStreamReader(bufferedStream, HTMLSupport.ENCODING),
-             CHAR_BUFFER_LEN);
-        String version = bufferedReader.readLine().trim();
-        if (version == null || !version.startsWith(HTMLSupport.VERSION)) {
-            // Not MS-compliant HTML text. Return raw text from read().
-            index = 0;
-            end = -1;
-            bufferedStream.reset();
-            return;
-        }
-
-        String input;
-        boolean startHTML, endHTML, startFragment, endFragment;
-        startHTML = endHTML = startFragment = endFragment = false;
-
-        try {
-            do {
-                input = bufferedReader.readLine().trim();
-                if (input == null) {
-                    close();
-                    throw new IOException(FAILURE_MSG);
-                } else if (input.startsWith(HTMLSupport.START_HTML)) {
-                    int val = Integer.parseInt
-                    (input.substring(HTMLSupport.START_HTML.length(),
-                                     input.length()).trim());
-                    if (val >= 0) {
-                        index = val;
-                        startHTML = true;
-                    } else if (val != -1) {
-                        close();
-                        throw new IOException(FAILURE_MSG +
-                                              HTMLSupport.START_HTML +
-                                              INVALID_MSG);
-                    }
-                } else if (input.startsWith(HTMLSupport.END_HTML)) {
-                    int val = Integer.parseInt
-                    (input.substring(HTMLSupport.END_HTML.length(),
-                                     input.length()).trim());
-                    if (val >= 0) {
-                        end = val;
-                        endHTML = true;
-                    } else if (val != -1) {
-                        close();
-                        throw new IOException(FAILURE_MSG +
-                                              HTMLSupport.END_HTML +
-                                              INVALID_MSG);
-                    }
-                } else if (!startHTML && !endHTML &&
-                           input.startsWith(HTMLSupport.START_FRAGMENT)) {
-                    index = Integer.parseInt
-                    (input.substring(HTMLSupport.START_FRAGMENT.length(),
-                                     input.length()).trim());
-                    if (index < 0) {
-                        close();
-                        throw new IOException(FAILURE_MSG +
-                                              HTMLSupport.START_FRAGMENT +
-                                              INVALID_MSG);
-                    }
-                    startFragment = true;
-                } else if (!startHTML && !endHTML &&
-                           input.startsWith(HTMLSupport.END_FRAGMENT)) {
-                    end = Integer.parseInt
-                    (input.substring(HTMLSupport.END_FRAGMENT.length(),
-                                     input.length()).trim());
-                    if (end < 0) {
-                        close();
-                        throw new IOException(FAILURE_MSG +
-                                              HTMLSupport.END_FRAGMENT +
-                                              INVALID_MSG);
-                    }
-                    endFragment = true;
-                }
-            } while (!((startHTML && endHTML) ||
-                       (startFragment && endFragment)));
-        } catch (NumberFormatException e) {
-            close();
-            throw new IOException(FAILURE_MSG + e);
-        }
-
-        bufferedStream.reset();
-
-        for (int i = 0; i < index; i++) {
-            if (bufferedStream.read() == -1) {
-                close();
-                throw new IOException(FAILURE_MSG +
-                                      "Byte stream ends in description.");
-            }
-        }
-    }
-
-    public int read() throws IOException {
-        if (closed) {
-            throw new IOException("Stream closed");
-        }
-
-        if (!descriptionParsed) {
-            parseDescription(); // initializes 'index' and 'end'
-            descriptionParsed = true;
-        }
-
-        if (end != -1 && index >= end) {
-            return -1;
-        }
-
-        int retval = bufferedStream.read();
-        if (retval == -1) {
-            index = end = 0; // so future read() calls will fail quickly
-            return -1;
-        }
-
-        index++;
-    //    System.out.print((char)retval);
-        return retval;
-    }
-
-    public void close() throws IOException {
-        if (!closed) {
-            closed = true;
-            bufferedStream.close();
-        }
-    }
-}
--- a/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java	Thu Mar 13 14:55:50 2014 -0700
@@ -28,7 +28,6 @@
 import sun.lwawt.LWToolkit;
 import sun.lwawt.LWWindowPeer;
 import sun.lwawt.macosx.CocoaConstants;
-import sun.lwawt.macosx.event.NSEvent;
 
 import sun.awt.EmbeddedFrame;
 
--- a/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java	Thu Mar 13 14:55:50 2014 -0700
@@ -46,17 +46,16 @@
         @Override
         public void run() {
             try {
-                boolean navigateApps = false;
-                int dialogMode = target.getMode();
+                boolean navigateApps = !AccessController.doPrivileged(
+                        new GetBooleanAction("apple.awt.use-file-dialog-packages"));
+                boolean chooseDirectories = AccessController.doPrivileged(
+                        new GetBooleanAction("apple.awt.fileDialogForDirectories"));
 
-                navigateApps = true;
-
+                int dialogMode = target.getMode();
                 String title = target.getTitle();
                 if (title == null) {
                     title = " ";
                 }
-                Boolean chooseDirectories = AccessController.doPrivileged(
-                        new GetBooleanAction("apple.awt.fileDialogForDirectories"));
 
                 String[] userFileNames = nativeRunFileDialog(title,
                         dialogMode,
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -28,7 +28,7 @@
 import sun.awt.SunToolkit;
 import sun.lwawt.LWWindowPeer;
 import sun.lwawt.PlatformEventNotifier;
-import sun.lwawt.macosx.event.NSEvent;
+
 import java.awt.Toolkit;
 import java.awt.event.MouseEvent;
 import java.awt.event.InputEvent;
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -31,7 +31,6 @@
 import sun.awt.CGraphicsConfig;
 import sun.awt.CGraphicsEnvironment;
 import sun.lwawt.LWWindowPeer;
-import sun.lwawt.macosx.event.NSEvent;
 
 import sun.java2d.SurfaceData;
 import sun.java2d.opengl.CGLLayer;
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Thu Mar 13 14:55:50 2014 -0700
@@ -613,9 +613,7 @@
             // Add myself as a child
             if (owner != null && owner.isVisible()) {
                 CWrapper.NSWindow.addChildWindow(owner.getNSWindowPtr(), nsWindowPtr, CWrapper.NSWindow.NSWindowAbove);
-                if (target.isAlwaysOnTop()) {
-                    CWrapper.NSWindow.setLevel(nsWindowPtr, CWrapper.NSWindow.NSFloatingWindowLevel);
-                }
+                applyWindowLevel(target);
             }
 
             // Add my own children to myself
@@ -625,9 +623,7 @@
                     CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
                     if (pw != null && pw.isVisible()) {
                         CWrapper.NSWindow.addChildWindow(nsWindowPtr, pw.getNSWindowPtr(), CWrapper.NSWindow.NSWindowAbove);
-                        if (w.isAlwaysOnTop()) {
-                            CWrapper.NSWindow.setLevel(pw.getNSWindowPtr(), CWrapper.NSWindow.NSFloatingWindowLevel);
-                        }
+                        pw.applyWindowLevel(w);
                     }
                 }
             }
@@ -1050,8 +1046,14 @@
             CWrapper.NSWindow.addChildWindow(nsWindowOwnerPtr, nsWindowSelfPtr, CWrapper.NSWindow.NSWindowAbove);
         }
 
-        if (target.isAlwaysOnTop()) {
+        applyWindowLevel(target);
+    }
+
+    protected void applyWindowLevel(Window target) {
+        if (target.isAlwaysOnTop() && target.getType() != Window.Type.POPUP) {
             CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSFloatingWindowLevel);
+        } else if (target.getType() == Window.Type.POPUP) {
+            CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSPopUpMenuWindowLevel);
         }
     }
 
--- a/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -41,7 +41,7 @@
 import sun.java2d.*;
 import sun.print.*;
 
-public class CPrinterJob extends RasterPrinterJob {
+final class CPrinterJob extends RasterPrinterJob {
     // NOTE: This uses RasterPrinterJob as a base, but it doesn't use
     // all of the RasterPrinterJob functions. RasterPrinterJob will
     // break down printing to pieces that aren't necessary under MacOSX
@@ -89,6 +89,7 @@
      * returns true.
      * @see java.awt.GraphicsEnvironment#isHeadless
      */
+    @Override
     public boolean printDialog() throws HeadlessException {
         if (GraphicsEnvironment.isHeadless()) {
             throw new HeadlessException();
@@ -131,6 +132,7 @@
      * @see java.awt.GraphicsEnvironment#isHeadless
      * @since     1.2
      */
+    @Override
     public PageFormat pageDialog(PageFormat page) throws HeadlessException {
         if (GraphicsEnvironment.isHeadless()) {
             throw new HeadlessException();
@@ -156,12 +158,14 @@
      * @return clone of <code>page</code>, altered to describe a default
      *                      <code>PageFormat</code>.
      */
+    @Override
     public PageFormat defaultPage(PageFormat page) {
         PageFormat newPage = (PageFormat)page.clone();
         getDefaultPage(newPage);
         return newPage;
     }
 
+    @Override
     protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException {
         super.setAttributes(attributes);
 
@@ -216,7 +220,7 @@
         }
     }
 
-
+    @Override
     public void print(PrintRequestAttributeSet attributes) throws PrinterException {
         // NOTE: Some of this code is copied from RasterPrinterJob.
 
@@ -343,6 +347,7 @@
      * Returns the resolution in dots per inch across the width
      * of the page.
      */
+    @Override
     protected double getXRes() {
         // NOTE: This is not used in the CPrinterJob code path.
         return 0;
@@ -352,6 +357,7 @@
      * Returns the resolution in dots per inch down the height
      * of the page.
      */
+    @Override
     protected double getYRes() {
         // NOTE: This is not used in the CPrinterJob code path.
         return 0;
@@ -362,6 +368,7 @@
      * Value is in device pixels.
      * Not adjusted for orientation of the paper.
      */
+    @Override
     protected double getPhysicalPrintableX(Paper p) {
         // NOTE: This is not used in the CPrinterJob code path.
         return 0;
@@ -372,6 +379,7 @@
      * Value is in device pixels.
      * Not adjusted for orientation of the paper.
      */
+    @Override
     protected double getPhysicalPrintableY(Paper p) {
         // NOTE: This is not used in the CPrinterJob code path.
         return 0;
@@ -382,6 +390,7 @@
      * Value is in device pixels.
      * Not adjusted for orientation of the paper.
      */
+    @Override
     protected double getPhysicalPrintableWidth(Paper p) {
         // NOTE: This is not used in the CPrinterJob code path.
         return 0;
@@ -392,6 +401,7 @@
      * Value is in device pixels.
      * Not adjusted for orientation of the paper.
      */
+    @Override
     protected double getPhysicalPrintableHeight(Paper p) {
         // NOTE: This is not used in the CPrinterJob code path.
         return 0;
@@ -402,6 +412,7 @@
      * Value is in device pixels.
      * Not adjusted for orientation of the paper.
      */
+    @Override
     protected double getPhysicalPageWidth(Paper p) {
         // NOTE: This is not used in the CPrinterJob code path.
         return 0;
@@ -412,6 +423,7 @@
      * Value is in device pixels.
      * Not adjusted for orientation of the paper.
      */
+    @Override
     protected double getPhysicalPageHeight(Paper p) {
         // NOTE: This is not used in the CPrinterJob code path.
         return 0;
@@ -429,6 +441,7 @@
     /**
      * End a page.
      */
+    @Override
     protected void endPage(PageFormat format, Printable painter, int index) throws PrinterException {
         // NOTE: This is not used in the CPrinterJob code path.
         throw new PrinterException(sShouldNotReachHere);
@@ -441,6 +454,7 @@
      * page. The width and height of the band is
      * specified by the caller.
      */
+    @Override
     protected void printBand(byte[] data, int x, int y, int width, int height) throws PrinterException {
         // NOTE: This is not used in the CPrinterJob code path.
         throw new PrinterException(sShouldNotReachHere);
@@ -450,6 +464,7 @@
      * Called by the print() method at the start of
      * a print job.
      */
+    @Override
     protected void startDoc() throws PrinterException {
         // NOTE: This is not used in the CPrinterJob code path.
         throw new PrinterException(sShouldNotReachHere);
@@ -459,12 +474,14 @@
      * Called by the print() method at the end of
      * a print job.
      */
+    @Override
     protected void endDoc() throws PrinterException {
         // NOTE: This is not used in the CPrinterJob code path.
         throw new PrinterException(sShouldNotReachHere);
     }
 
     /* Called by cancelDoc */
+    @Override
     protected native void abortDoc();
 
     /**
@@ -502,10 +519,12 @@
     /**
      * validate the paper size against the current printer.
      */
+    @Override
     protected native void validatePaper(Paper origPaper, Paper newPaper );
 
     // The following methods are CPrinterJob specific.
 
+    @Override
     protected void finalize() {
         if (fNSPrintInfo != -1) {
             dispose(fNSPrintInfo);
--- a/src/macosx/classes/sun/lwawt/macosx/CPrinterJobDialog.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/classes/sun/lwawt/macosx/CPrinterJobDialog.java	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -29,7 +29,7 @@
 import java.awt.*;
 import java.awt.print.*;
 
-public class CPrinterJobDialog extends CPrinterDialog {
+final class CPrinterJobDialog extends CPrinterDialog {
     private Pageable fPageable;
     private boolean fAllowPrintToFile;
 
@@ -39,5 +39,6 @@
         fAllowPrintToFile = allowPrintToFile;
     }
 
+    @Override
     protected native boolean showDialog();
 }
--- a/src/macosx/classes/sun/lwawt/macosx/CPrinterPageDialog.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/classes/sun/lwawt/macosx/CPrinterPageDialog.java	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -29,7 +29,7 @@
 import java.awt.*;
 import java.awt.print.*;
 
-public class CPrinterPageDialog extends CPrinterDialog {
+final class CPrinterPageDialog extends CPrinterDialog {
     private PageFormat fPage;
     private Printable fPainter;
 
@@ -39,5 +39,6 @@
         fPainter = painter;
     }
 
+    @Override
     protected native boolean showDialog();
 }
--- a/src/macosx/classes/sun/lwawt/macosx/CPrinterSurfaceData.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/classes/sun/lwawt/macosx/CPrinterSurfaceData.java	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -40,11 +40,11 @@
 //    public static final SurfaceType IntArgbPQ = SurfaceType.IntArgb.deriveSubType(DESC_INT_ARGB_PQ);
     public static final SurfaceType IntRgbPQ = SurfaceType.IntRgb.deriveSubType(DESC_INT_RGB_PQ);
 
-    public static SurfaceData createData(PageFormat pf, long context) {
+    static SurfaceData createData(PageFormat pf, long context) {
         return new CPrinterSurfaceData(CPrinterGraphicsConfig.getConfig(pf), context);
     }
 
-    public CPrinterSurfaceData(GraphicsConfiguration gc, long context) {
+    private CPrinterSurfaceData(GraphicsConfiguration gc, long context) {
         super(IntRgbPQ, gc.getColorModel(), gc, gc.getBounds());
         initOps(context, this.fGraphicsStates, this.fGraphicsStatesObject, gc.getBounds().width, gc.getBounds().height);
     }
--- a/src/macosx/classes/sun/lwawt/macosx/CTrayIcon.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/classes/sun/lwawt/macosx/CTrayIcon.java	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -27,7 +27,6 @@
 
 import sun.awt.AWTAccessor;
 import sun.awt.SunToolkit;
-import sun.lwawt.macosx.event.NSEvent;
 
 import javax.swing.*;
 import java.awt.*;
@@ -76,8 +75,9 @@
                 menuPeer = (CPopupMenu)popup.getPeer();
                 if (menuPeer == null) {
                     popup.addNotify();
+                    menuPeer = (CPopupMenu)popup.getPeer();
                 }
-            }catch (Exception e){
+            } catch (Exception e) {
                 e.printStackTrace();
             }
         }
@@ -97,7 +97,12 @@
     //invocation from the AWTTrayIcon.m
     public long getPopupMenuModel(){
         if(popup == null) {
-            return 0L;
+            PopupMenu popupMenu = target.getPopupMenu();
+            if (popupMenu != null) {
+                popup = popupMenu;
+            } else {
+                return 0L;
+            }
         }
         return checkAndCreatePopupPeer().getModel();
     }
@@ -134,6 +139,10 @@
 
         dummyFrame.dispose();
 
+        if (popup != null) {
+            popup.removeNotify();
+        }
+
         LWCToolkit.targetDisposedPeer(target, this);
         target = null;
 
--- a/src/macosx/classes/sun/lwawt/macosx/CWarningWindow.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/classes/sun/lwawt/macosx/CWarningWindow.java	Thu Mar 13 14:55:50 2014 -0700
@@ -247,10 +247,7 @@
                             nsWindowPtr, CWrapper.NSWindow.NSWindowAbove);
 
                     // do not allow security warning to be obscured by other windows
-                    if (ownerWindow.isAlwaysOnTop()) {
-                        CWrapper.NSWindow.setLevel(nsWindowPtr,
-                                CWrapper.NSWindow.NSFloatingWindowLevel);
-                    }
+                    applyWindowLevel(ownerWindow);
                 }
             }
         }
--- a/src/macosx/classes/sun/lwawt/macosx/CWrapper.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/classes/sun/lwawt/macosx/CWrapper.java	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -25,73 +25,65 @@
 
 package sun.lwawt.macosx;
 
-import java.awt.geom.Rectangle2D;
-
-public final class CWrapper {
+final class CWrapper {
     private CWrapper() { }
 
-    public static final class NSWindow {
+    static final class NSWindow {
         // NSWindowOrderingMode
-        public static final int NSWindowAbove = 1;
-        public static final int NSWindowBelow = -1;
-        public static final int NSWindowOut = 0;
+        static final int NSWindowAbove = 1;
+        static final int NSWindowBelow = -1;
+        static final int NSWindowOut = 0;
 
         // Window level constants
         // The number of supported levels: (we'll use more in the future)
-        public static final int MAX_WINDOW_LEVELS = 2;
+        static final int MAX_WINDOW_LEVELS = 3;
         // The levels: (these are NOT real constants, these are keys. See native code.)
-        public static final int NSNormalWindowLevel = 0;
-        public static final int NSFloatingWindowLevel = 1;
+        static final int NSNormalWindowLevel = 0;
+        static final int NSFloatingWindowLevel = 1;
+        static final int NSPopUpMenuWindowLevel = 2;
 
         // 'level' is one of the keys defined above
-        public static native void setLevel(long window, int level);
+        static native void setLevel(long window, int level);
 
-        public static native void makeKeyAndOrderFront(long window);
-        public static native void makeKeyWindow(long window);
-        public static native void makeMainWindow(long window);
-        public static native boolean canBecomeMainWindow(long window);
-        public static native boolean isKeyWindow(long window);
+        static native void makeKeyAndOrderFront(long window);
+        static native void makeKeyWindow(long window);
+        static native void makeMainWindow(long window);
+        static native boolean canBecomeMainWindow(long window);
+        static native boolean isKeyWindow(long window);
 
-        public static native void orderFront(long window);
-        public static native void orderFrontRegardless(long window);
-        public static native void orderWindow(long window, int ordered, long relativeTo);
-        public static native void orderOut(long window);
+        static native void orderFront(long window);
+        static native void orderFrontRegardless(long window);
+        static native void orderWindow(long window, int ordered, long relativeTo);
+        static native void orderOut(long window);
 
-        public static native void addChildWindow(long parent, long child, int ordered);
-        public static native void removeChildWindow(long parent, long child);
+        static native void addChildWindow(long parent, long child, int ordered);
+        static native void removeChildWindow(long parent, long child);
 
-        public static native void setFrame(long window, int x, int y, int w, int h, boolean display);
+        static native void setAlphaValue(long window, float alpha);
+        static native void setOpaque(long window, boolean opaque);
+        static native void setBackgroundColor(long window, long color);
 
-        public static native void setAlphaValue(long window, float alpha);
-        public static native void setOpaque(long window, boolean opaque);
-        public static native void setBackgroundColor(long window, long color);
+        static native void miniaturize(long window);
+        static native void deminiaturize(long window);
+        static native boolean isZoomed(long window);
+        static native void zoom(long window);
 
-        public static native void miniaturize(long window);
-        public static native void deminiaturize(long window);
-        public static native boolean isZoomed(long window);
-        public static native void zoom(long window);
-
-        public static native void makeFirstResponder(long window, long responder);
+        static native void makeFirstResponder(long window, long responder);
     }
 
-    public static final class NSView {
-        public static native void addSubview(long view, long subview);
-        public static native void removeFromSuperview(long view);
+    static final class NSView {
+        static native void addSubview(long view, long subview);
+        static native void removeFromSuperview(long view);
 
-        public static native void setFrame(long view, int x, int y, int w, int h);
-        public static native Rectangle2D frame(long view);
-        public static native long window(long view);
+        static native void setFrame(long view, int x, int y, int w, int h);
+        static native long window(long view);
 
-        public static native void setHidden(long view, boolean hidden);
+        static native void setHidden(long view, boolean hidden);
 
-        public static native void setToolTip(long view, String msg);
+        static native void setToolTip(long view, String msg);
     }
 
-    public static final class NSObject {
-        public static native void release(long object);
-    }
-
-    public static final class NSColor {
-        public static native long clearColor();
+    static final class NSColor {
+        static native long clearColor();
     }
 }
--- a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -42,6 +42,7 @@
 import java.net.MalformedURLException;
 
 import sun.awt.*;
+import sun.awt.datatransfer.DataTransferer;
 import sun.lwawt.*;
 import sun.lwawt.LWWindowPeer.PeerType;
 import sun.security.action.GetBooleanAction;
@@ -112,8 +113,6 @@
     private static final boolean inAWT;
 
     public LWCToolkit() {
-        SunToolkit.setDataTransfererClassName("sun.lwawt.macosx.CDataTransferer");
-
         areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true"));
         //set system property if not yet assigned
         System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled);
@@ -159,25 +158,14 @@
         return new AppleSpecificColor(color);
     }
 
+    // This is only called from native code.
     static void systemColorsChanged() {
-        // This is only called from native code.
-        EventQueue.invokeLater(new Runnable() {
-            public void run() {
-                AccessController.doPrivileged (new PrivilegedAction<Object>() {
-                    public Object run() {
-                        try {
-                            final Method updateColorsMethod = SystemColor.class.getDeclaredMethod("updateSystemColors", new Class[0]);
-                            updateColorsMethod.setAccessible(true);
-                            updateColorsMethod.invoke(null, new Object[0]);
-                        } catch (final Throwable e) {
-                            e.printStackTrace();
-                            // swallow this if something goes horribly wrong
-                        }
-                        return null;
-                    }
-                });
-            }
-           });
+        EventQueue.invokeLater(() -> {
+            AccessController.doPrivileged ((PrivilegedAction<Object>) () -> {
+                AWTAccessor.getSystemColorAccessor().updateSystemColors();
+                return null;
+            });
+        });
     }
 
     public static LWCToolkit getLWCToolkit() {
@@ -442,6 +430,11 @@
     }
 
     @Override
+    public DataTransferer getDataTransferer() {
+        return CDataTransferer.getInstanceImpl();
+    }
+
+    @Override
     public boolean isAlwaysOnTopSupported() {
         return true;
     }
@@ -732,7 +725,7 @@
     /*
      * Returns true if the application (one of its windows) owns keyboard focus.
      */
-    public native boolean isApplicationActive();
+    native boolean isApplicationActive();
 
     /************************
      * Native methods section
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/macosx/classes/sun/lwawt/macosx/NSEvent.java	Thu Mar 13 14:55:50 2014 -0700
@@ -0,0 +1,261 @@
+/*
+ * 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
+ * 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.macosx;
+
+import java.awt.event.*;
+
+/**
+ * A class representing Cocoa NSEvent class with the fields only necessary for
+ * JDK functionality.
+ */
+final class NSEvent {
+    private int type;
+    private int modifierFlags;
+
+    // Mouse event information
+    private int clickCount;
+    private int buttonNumber;
+    private int x;
+    private int y;
+    private double scrollDeltaY;
+    private double scrollDeltaX;
+    private int absX;
+    private int absY;
+
+    // Key event information
+    private short keyCode;
+    private String charactersIgnoringModifiers;
+
+    // Called from native
+    NSEvent(int type, int modifierFlags, short keyCode, String charactersIgnoringModifiers) {
+        this.type = type;
+        this.modifierFlags = modifierFlags;
+        this.keyCode = keyCode;
+        this.charactersIgnoringModifiers = charactersIgnoringModifiers;
+    }
+
+    // Called from native
+    NSEvent(int type, int modifierFlags, int clickCount, int buttonNumber,
+                   int x, int y, int absX, int absY,
+                   double scrollDeltaY, double scrollDeltaX) {
+        this.type = type;
+        this.modifierFlags = modifierFlags;
+        this.clickCount = clickCount;
+        this.buttonNumber = buttonNumber;
+        this.x = x;
+        this.y = y;
+        this.absX = absX;
+        this.absY = absY;
+        this.scrollDeltaY = scrollDeltaY;
+        this.scrollDeltaX = scrollDeltaX;
+    }
+
+    int getType() {
+        return type;
+    }
+
+    int getModifierFlags() {
+        return modifierFlags;
+    }
+
+    int getClickCount() {
+        return clickCount;
+    }
+
+    int getButtonNumber() {
+        return buttonNumber;
+    }
+
+    int getX() {
+        return x;
+    }
+
+    int getY() {
+        return y;
+    }
+
+    double getScrollDeltaY() {
+        return scrollDeltaY;
+    }
+
+    double getScrollDeltaX() {
+        return scrollDeltaX;
+    }
+
+    int getAbsX() {
+        return absX;
+    }
+
+    int getAbsY() {
+        return absY;
+    }
+
+    short getKeyCode() {
+        return keyCode;
+    }
+
+    String getCharactersIgnoringModifiers() {
+        return charactersIgnoringModifiers;
+    }
+
+    @Override
+    public String toString() {
+        return "NSEvent[" + getType() + " ," + getModifierFlags() + " ,"
+                + getClickCount() + " ," + getButtonNumber() + " ," + getX() + " ,"
+                + getY() + " ," + getAbsX() + " ," + getAbsY()+ " ," + getKeyCode() + " ,"
+                + getCharactersIgnoringModifiers() + "]";
+    }
+
+    /*
+     * Converts an NSEvent button number to a MouseEvent constant.
+     */
+    static int nsToJavaButton(int buttonNumber) {
+        int jbuttonNumber = buttonNumber + 1;
+        switch (buttonNumber) {
+            case CocoaConstants.kCGMouseButtonLeft:
+                jbuttonNumber = MouseEvent.BUTTON1;
+                break;
+            case CocoaConstants.kCGMouseButtonRight:
+                jbuttonNumber = MouseEvent.BUTTON3;
+                break;
+            case CocoaConstants.kCGMouseButtonCenter:
+                jbuttonNumber = MouseEvent.BUTTON2;
+                break;
+        }
+        return jbuttonNumber;
+    }
+
+    /*
+     * Converts NPCocoaEvent types to AWT event types.
+     */
+    static int npToJavaEventType(int npEventType) {
+        int jeventType = 0;
+        switch (npEventType) {
+            case CocoaConstants.NPCocoaEventMouseDown:
+                jeventType = MouseEvent.MOUSE_PRESSED;
+                break;
+            case CocoaConstants.NPCocoaEventMouseUp:
+                jeventType = MouseEvent.MOUSE_RELEASED;
+                break;
+            case CocoaConstants.NPCocoaEventMouseMoved:
+                jeventType = MouseEvent.MOUSE_MOVED;
+                break;
+            case CocoaConstants.NPCocoaEventMouseEntered:
+                jeventType = MouseEvent.MOUSE_ENTERED;
+                break;
+            case CocoaConstants.NPCocoaEventMouseExited:
+                jeventType = MouseEvent.MOUSE_EXITED;
+                break;
+            case CocoaConstants.NPCocoaEventMouseDragged:
+                jeventType = MouseEvent.MOUSE_DRAGGED;
+                break;
+            case CocoaConstants.NPCocoaEventKeyDown:
+                jeventType = KeyEvent.KEY_PRESSED;
+                break;
+            case CocoaConstants.NPCocoaEventKeyUp:
+                jeventType = KeyEvent.KEY_RELEASED;
+                break;
+        }
+        return jeventType;
+    }
+
+    /*
+     * Converts NSEvent types to AWT event types.
+     */
+    static int nsToJavaEventType(int nsEventType) {
+        int jeventType = 0;
+        switch (nsEventType) {
+            case CocoaConstants.NSLeftMouseDown:
+            case CocoaConstants.NSRightMouseDown:
+            case CocoaConstants.NSOtherMouseDown:
+                jeventType = MouseEvent.MOUSE_PRESSED;
+                break;
+            case CocoaConstants.NSLeftMouseUp:
+            case CocoaConstants.NSRightMouseUp:
+            case CocoaConstants.NSOtherMouseUp:
+                jeventType = MouseEvent.MOUSE_RELEASED;
+                break;
+            case CocoaConstants.NSMouseMoved:
+                jeventType = MouseEvent.MOUSE_MOVED;
+                break;
+            case CocoaConstants.NSLeftMouseDragged:
+            case CocoaConstants.NSRightMouseDragged:
+            case CocoaConstants.NSOtherMouseDragged:
+                jeventType = MouseEvent.MOUSE_DRAGGED;
+                break;
+            case CocoaConstants.NSMouseEntered:
+                jeventType = MouseEvent.MOUSE_ENTERED;
+                break;
+            case CocoaConstants.NSMouseExited:
+                jeventType = MouseEvent.MOUSE_EXITED;
+                break;
+            case CocoaConstants.NSScrollWheel:
+                jeventType = MouseEvent.MOUSE_WHEEL;
+                break;
+            case CocoaConstants.NSKeyDown:
+                jeventType = KeyEvent.KEY_PRESSED;
+                break;
+            case CocoaConstants.NSKeyUp:
+                jeventType = KeyEvent.KEY_RELEASED;
+                break;
+        }
+        return jeventType;
+    }
+
+    /*
+     * Converts NSEvent mouse modifiers to AWT mouse modifiers.
+     */
+    static native int nsToJavaMouseModifiers(int buttonNumber,
+                                                    int modifierFlags);
+
+    /*
+     * Converts NSEvent key modifiers to AWT key modifiers.
+     */
+    static native int nsToJavaKeyModifiers(int modifierFlags);
+
+    /*
+     * Converts NSEvent key info to AWT key info.
+     */
+    static native boolean nsToJavaKeyInfo(int[] in, int[] out);
+
+    /*
+     * Converts NSEvent key modifiers to AWT key info.
+     */
+    static native void nsKeyModifiersToJavaKeyInfo(int[] in, int[] out);
+
+    /*
+     * There is a small number of NS characters that need to be converted
+     * into other characters before we pass them to AWT.
+     */
+    static native char nsToJavaChar(char nsChar, int modifierFlags);
+
+    static boolean isPopupTrigger(int jmodifiers) {
+        final boolean isRightButtonDown = ((jmodifiers & InputEvent.BUTTON3_DOWN_MASK) != 0);
+        final boolean isLeftButtonDown = ((jmodifiers & InputEvent.BUTTON1_DOWN_MASK) != 0);
+        final boolean isControlDown = ((jmodifiers & InputEvent.CTRL_DOWN_MASK) != 0);
+        return isRightButtonDown || (isControlDown && isLeftButtonDown);
+    }
+}
--- a/src/macosx/classes/sun/lwawt/macosx/event/NSEvent.java	Wed Feb 26 19:26:42 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,260 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, 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.macosx.event;
-
-import sun.lwawt.macosx.CocoaConstants;
-import java.awt.event.*;
-
-/**
- * A class representing Cocoa NSEvent class with the fields only necessary for
- * JDK functionality.
- */
-public final class NSEvent {
-    private int type;
-    private int modifierFlags;
-
-    // Mouse event information
-    private int clickCount;
-    private int buttonNumber;
-    private int x;
-    private int y;
-    private double scrollDeltaY;
-    private double scrollDeltaX;
-    private int absX;
-    private int absY;
-
-    // Key event information
-    private short keyCode;
-    private String charactersIgnoringModifiers;
-
-    public NSEvent(int type, int modifierFlags, short keyCode, String charactersIgnoringModifiers) {
-        this.type = type;
-        this.modifierFlags = modifierFlags;
-        this.keyCode = keyCode;
-        this.charactersIgnoringModifiers = charactersIgnoringModifiers;
-    }
-
-    public NSEvent(int type, int modifierFlags, int clickCount, int buttonNumber,
-                   int x, int y, int absX, int absY,
-                   double scrollDeltaY, double scrollDeltaX) {
-        this.type = type;
-        this.modifierFlags = modifierFlags;
-        this.clickCount = clickCount;
-        this.buttonNumber = buttonNumber;
-        this.x = x;
-        this.y = y;
-        this.absX = absX;
-        this.absY = absY;
-        this.scrollDeltaY = scrollDeltaY;
-        this.scrollDeltaX = scrollDeltaX;
-    }
-
-    public int getType() {
-        return type;
-    }
-
-    public int getModifierFlags() {
-        return modifierFlags;
-    }
-
-    public int getClickCount() {
-        return clickCount;
-    }
-
-    public int getButtonNumber() {
-        return buttonNumber;
-    }
-
-    public int getX() {
-        return x;
-    }
-
-    public int getY() {
-        return y;
-    }
-
-    public double getScrollDeltaY() {
-        return scrollDeltaY;
-    }
-
-    public double getScrollDeltaX() {
-        return scrollDeltaX;
-    }
-
-    public int getAbsX() {
-        return absX;
-    }
-
-    public int getAbsY() {
-        return absY;
-    }
-
-    public short getKeyCode() {
-        return keyCode;
-    }
-
-    public String getCharactersIgnoringModifiers() {
-        return charactersIgnoringModifiers;
-    }
-
-    @Override
-    public String toString() {
-        return "NSEvent[" + getType() + " ," + getModifierFlags() + " ,"
-                + getClickCount() + " ," + getButtonNumber() + " ," + getX() + " ,"
-                + getY() + " ," + getAbsX() + " ," + getAbsY()+ " ," + getKeyCode() + " ,"
-                + getCharactersIgnoringModifiers() + "]";
-    }
-
-    /*
-     * Converts an NSEvent button number to a MouseEvent constant.
-     */
-    public static int nsToJavaButton(int buttonNumber) {
-        int jbuttonNumber = buttonNumber + 1;
-        switch (buttonNumber) {
-            case CocoaConstants.kCGMouseButtonLeft:
-                jbuttonNumber = MouseEvent.BUTTON1;
-                break;
-            case CocoaConstants.kCGMouseButtonRight:
-                jbuttonNumber = MouseEvent.BUTTON3;
-                break;
-            case CocoaConstants.kCGMouseButtonCenter:
-                jbuttonNumber = MouseEvent.BUTTON2;
-                break;
-        }
-        return jbuttonNumber;
-    }
-
-    /*
-     * Converts NPCocoaEvent types to AWT event types.
-     */
-    public static int npToJavaEventType(int npEventType) {
-        int jeventType = 0;
-        switch (npEventType) {
-            case CocoaConstants.NPCocoaEventMouseDown:
-                jeventType = MouseEvent.MOUSE_PRESSED;
-                break;
-            case CocoaConstants.NPCocoaEventMouseUp:
-                jeventType = MouseEvent.MOUSE_RELEASED;
-                break;
-            case CocoaConstants.NPCocoaEventMouseMoved:
-                jeventType = MouseEvent.MOUSE_MOVED;
-                break;
-            case CocoaConstants.NPCocoaEventMouseEntered:
-                jeventType = MouseEvent.MOUSE_ENTERED;
-                break;
-            case CocoaConstants.NPCocoaEventMouseExited:
-                jeventType = MouseEvent.MOUSE_EXITED;
-                break;
-            case CocoaConstants.NPCocoaEventMouseDragged:
-                jeventType = MouseEvent.MOUSE_DRAGGED;
-                break;
-            case CocoaConstants.NPCocoaEventKeyDown:
-                jeventType = KeyEvent.KEY_PRESSED;
-                break;
-            case CocoaConstants.NPCocoaEventKeyUp:
-                jeventType = KeyEvent.KEY_RELEASED;
-                break;
-        }
-        return jeventType;
-    }
-
-    /*
-     * Converts NSEvent types to AWT event types.
-     */
-    public static int nsToJavaEventType(int nsEventType) {
-        int jeventType = 0;
-        switch (nsEventType) {
-            case CocoaConstants.NSLeftMouseDown:
-            case CocoaConstants.NSRightMouseDown:
-            case CocoaConstants.NSOtherMouseDown:
-                jeventType = MouseEvent.MOUSE_PRESSED;
-                break;
-            case CocoaConstants.NSLeftMouseUp:
-            case CocoaConstants.NSRightMouseUp:
-            case CocoaConstants.NSOtherMouseUp:
-                jeventType = MouseEvent.MOUSE_RELEASED;
-                break;
-            case CocoaConstants.NSMouseMoved:
-                jeventType = MouseEvent.MOUSE_MOVED;
-                break;
-            case CocoaConstants.NSLeftMouseDragged:
-            case CocoaConstants.NSRightMouseDragged:
-            case CocoaConstants.NSOtherMouseDragged:
-                jeventType = MouseEvent.MOUSE_DRAGGED;
-                break;
-            case CocoaConstants.NSMouseEntered:
-                jeventType = MouseEvent.MOUSE_ENTERED;
-                break;
-            case CocoaConstants.NSMouseExited:
-                jeventType = MouseEvent.MOUSE_EXITED;
-                break;
-            case CocoaConstants.NSScrollWheel:
-                jeventType = MouseEvent.MOUSE_WHEEL;
-                break;
-            case CocoaConstants.NSKeyDown:
-                jeventType = KeyEvent.KEY_PRESSED;
-                break;
-            case CocoaConstants.NSKeyUp:
-                jeventType = KeyEvent.KEY_RELEASED;
-                break;
-        }
-        return jeventType;
-    }
-
-    /*
-     * Converts NSEvent mouse modifiers to AWT mouse modifiers.
-     */
-    public static native int nsToJavaMouseModifiers(int buttonNumber,
-                                                    int modifierFlags);
-
-    /*
-     * Converts NSEvent key modifiers to AWT key modifiers.
-     */
-    public static native int nsToJavaKeyModifiers(int modifierFlags);
-
-    /*
-     * Converts NSEvent key info to AWT key info.
-     */
-    public static native boolean nsToJavaKeyInfo(int[] in, int[] out);
-
-    /*
-     * Converts NSEvent key modifiers to AWT key info.
-     */
-    public static native void nsKeyModifiersToJavaKeyInfo(int[] in, int[] out);
-
-    /*
-     * There is a small number of NS characters that need to be converted
-     * into other characters before we pass them to AWT.
-     */
-    public static native char nsToJavaChar(char nsChar, int modifierFlags);
-
-    public static boolean isPopupTrigger(int jmodifiers) {
-        final boolean isRightButtonDown = ((jmodifiers & InputEvent.BUTTON3_DOWN_MASK) != 0);
-        final boolean isLeftButtonDown = ((jmodifiers & InputEvent.BUTTON1_DOWN_MASK) != 0);
-        final boolean isControlDown = ((jmodifiers & InputEvent.CTRL_DOWN_MASK) != 0);
-        return isRightButtonDown || (isControlDown && isLeftButtonDown);
-    }
-}
--- a/src/macosx/lib/flavormap.properties	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/lib/flavormap.properties	Thu Mar 13 14:55:50 2014 -0700
@@ -79,3 +79,5 @@
 TIFF=image/x-java-image;class=java.awt.Image
 RICH_TEXT=text/rtf
 HTML=text/html;charset=utf-8;eoln="\r\n";terminators=1
+URL=application/x-java-url;class=java.net.URL
+URL=text/uri-list;eoln="\r\n";terminators=1
--- a/src/macosx/native/sun/awt/AWTEvent.m	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/native/sun/awt/AWTEvent.m	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -633,12 +633,12 @@
 }
 
 /*
- * Class:     sun_lwawt_macosx_event_NSEvent
+ * Class:     sun_lwawt_macosx_NSEvent
  * Method:    nsToJavaMouseModifiers
  * Signature: (II)I
  */
 JNIEXPORT jint JNICALL
-Java_sun_lwawt_macosx_event_NSEvent_nsToJavaMouseModifiers
+Java_sun_lwawt_macosx_NSEvent_nsToJavaMouseModifiers
 (JNIEnv *env, jclass cls, jint buttonNumber, jint modifierFlags)
 {
     jint jmodifiers = 0;
@@ -653,12 +653,12 @@
 }
 
 /*
- * Class:     sun_lwawt_macosx_event_NSEvent
+ * Class:     sun_lwawt_macosx_NSEvent
  * Method:    nsToJavaKeyModifiers
  * Signature: (I)I
  */
 JNIEXPORT jint JNICALL
-Java_sun_lwawt_macosx_event_NSEvent_nsToJavaKeyModifiers
+Java_sun_lwawt_macosx_NSEvent_nsToJavaKeyModifiers
 (JNIEnv *env, jclass cls, jint modifierFlags)
 {
     jint jmodifiers = 0;
@@ -673,12 +673,12 @@
 }
 
 /*
- * Class:     sun_lwawt_macosx_event_NSEvent
+ * Class:     sun_lwawt_macosx_NSEvent
  * Method:    nsToJavaKeyInfo
  * Signature: ([I[I)Z
  */
 JNIEXPORT jboolean JNICALL
-Java_sun_lwawt_macosx_event_NSEvent_nsToJavaKeyInfo
+Java_sun_lwawt_macosx_NSEvent_nsToJavaKeyInfo
 (JNIEnv *env, jclass cls, jintArray inData, jintArray outData)
 {
     BOOL postsTyped = NO;
@@ -715,12 +715,12 @@
 }
 
 /*
- * Class:     sun_lwawt_macosx_event_NSEvent
+ * Class:     sun_lwawt_macosx_NSEvent
  * Method:    nsKeyModifiersToJavaKeyInfo
  * Signature: ([I[I)V
  */
 JNIEXPORT void JNICALL
-Java_sun_lwawt_macosx_event_NSEvent_nsKeyModifiersToJavaKeyInfo
+Java_sun_lwawt_macosx_NSEvent_nsKeyModifiersToJavaKeyInfo
 (JNIEnv *env, jclass cls, jintArray inData, jintArray outData)
 {
 JNF_COCOA_ENTER(env);
@@ -753,12 +753,12 @@
 }
 
 /*
- * Class:     sun_lwawt_macosx_event_NSEvent
+ * Class:     sun_lwawt_macosx_NSEvent
  * Method:    nsToJavaChar
  * Signature: (CI)C
  */
 JNIEXPORT jint JNICALL
-Java_sun_lwawt_macosx_event_NSEvent_nsToJavaChar
+Java_sun_lwawt_macosx_NSEvent_nsToJavaChar
 (JNIEnv *env, jclass cls, jchar nsChar, jint modifierFlags)
 {
     jchar javaChar = 0;
--- a/src/macosx/native/sun/awt/AWTView.h	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/native/sun/awt/AWTView.h	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -29,7 +29,7 @@
 #import "CDragSource.h"
 #import "CDropTarget.h"
 
-@interface AWTView : NSView<NSTextInputClient> {
+@interface AWTView : NSView<NSTextInputClient, CDragSourceHolder, CDropTargetHolder> {
 @private
     jobject m_cPlatformView;
 
@@ -61,14 +61,8 @@
 
 - (id) initWithRect:(NSRect) rect platformView:(jobject)cPlatformView windowLayer:(CALayer*)windowLayer;
 - (void) deliverJavaMouseEvent: (NSEvent *) event;
-- (void) resetTrackingArea;
-- (void) deliverJavaKeyEventHelper: (NSEvent *) event;
 - (jobject) awtComponent:(JNIEnv *)env;
 
-- (void) setDragSource:(CDragSource *)source;
-- (void) setDropTarget:(CDropTarget *)target;
-
-
 // Input method-related events
 - (void)setInputMethod:(jobject)inputMethod;
 - (void)abandonInput;
--- a/src/macosx/native/sun/awt/AWTView.m	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/native/sun/awt/AWTView.m	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -42,6 +42,10 @@
 @interface AWTView()
 @property (retain) CDropTarget *_dropTarget;
 @property (retain) CDragSource *_dragSource;
+
+-(void) deliverResize: (NSRect) rect;
+-(void) resetTrackingArea;
+-(void) deliverJavaKeyEventHelper: (NSEvent*) event;
 @end
 
 // Uncomment this line to see fprintfs of each InputMethod API being called on this View
@@ -376,7 +380,7 @@
         clickCount = [event clickCount];
     }
 
-    static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/event/NSEvent");
+    static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent");
     static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDD)V");
     jobject jEvent = JNFNewObject(env, jctor_NSEvent,
                                   [event type],
@@ -393,7 +397,7 @@
     }
 
     static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
-    static JNF_MEMBER_CACHE(jm_deliverMouseEvent, jc_PlatformView, "deliverMouseEvent", "(Lsun/lwawt/macosx/event/NSEvent;)V");
+    static JNF_MEMBER_CACHE(jm_deliverMouseEvent, jc_PlatformView, "deliverMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V");
     JNFCallVoidMethod(env, m_cPlatformView, jm_deliverMouseEvent, jEvent);
 }
 
@@ -441,7 +445,7 @@
         characters = JNFNSToJavaString(env, [event characters]);
     }
 
-    static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/event/NSEvent");
+    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,
                                   [event type],
@@ -451,7 +455,7 @@
 
     static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
     static JNF_MEMBER_CACHE(jm_deliverKeyEvent, jc_PlatformView,
-                            "deliverKeyEvent", "(Lsun/lwawt/macosx/event/NSEvent;)V");
+                            "deliverKeyEvent", "(Lsun/lwawt/macosx/NSEvent;)V");
     JNFCallVoidMethod(env, m_cPlatformView, jm_deliverKeyEvent, jevent);
 
     if (characters != NULL) {
--- a/src/macosx/native/sun/awt/CDragSource.h	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/native/sun/awt/CDragSource.h	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -29,9 +29,15 @@
 #import <Cocoa/Cocoa.h>
 #include <jni.h>
 
+@class CDragSource;
+
+@protocol CDragSourceHolder
+- (void) setDragSource:(CDragSource *)source;
+@end
+
 @interface CDragSource : NSObject {
 @private
-    NSView*        fView;
+    NSView<CDragSourceHolder>* fView;
     jobject            fComponent;
     jobject            fDragSourceContextPeer;
 
@@ -53,8 +59,6 @@
     jint                     fDragMouseModifiers;
 }
 
-+ (CDragSource *) currentDragSource;
-
 // Common methods:
 - (id)        init:(jobject)jDragSourceContextPeer
          component:(jobject)jComponent
@@ -84,13 +88,6 @@
 - (void)draggedImage:(NSImage *)image movedTo:(NSPoint)screenPoint;
 - (BOOL)ignoreModifierKeysWhileDragging;
 
-// Updates from the destination to the source
-- (void) postDragEnter;
-- (void) postDragExit;
-
-// Utility
-- (NSPoint) mapNSScreenPointToJavaWithOffset:(NSPoint) point;
-
 @end
 
 #endif // CDragSource_h
--- a/src/macosx/native/sun/awt/CDragSource.m	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/native/sun/awt/CDragSource.m	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -75,15 +75,18 @@
 static NSDragOperation    sDragOperation;
 static NSPoint            sDraggingLocation;
 
-static CDragSource*        sCurrentDragSource;
 static BOOL                sNeedsEnter;
 
+@interface CDragSource ()
+// Updates from the destination to the source
+- (void) postDragEnter;
+- (void) postDragExit;
+// Utility
+- (NSPoint) mapNSScreenPointToJavaWithOffset:(NSPoint) point;
+@end
+
 @implementation CDragSource
 
-+ (CDragSource *) currentDragSource {
-    return sCurrentDragSource;
-}
-
 - (id)        init:(jobject)jDragSourceContextPeer
          component:(jobject)jComponent
            control:(id)control
@@ -515,8 +518,6 @@
     fDragKeyModifiers = [DnDUtilities extractJavaExtKeyModifiersFromJavaExtModifiers:fModifiers];
     fDragMouseModifiers = [DnDUtilities extractJavaExtMouseModifiersFromJavaExtModifiers:fModifiers];
 
-    // Set the current DragSource
-    sCurrentDragSource = self;
     sNeedsEnter = YES;
 
     @try {
@@ -566,8 +567,6 @@
                 JNF_MEMBER_CACHE(resetHoveringMethod, CDragSourceContextPeerClass, "resetHovering", "()V");
         JNFCallVoidMethod(env, fDragSourceContextPeer, resetHoveringMethod); // Hust reset static variable
     } @finally {
-        // Clear the current DragSource
-        sCurrentDragSource = nil;
         sNeedsEnter = NO;
     }
 
--- a/src/macosx/native/sun/awt/CDropTarget.h	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/native/sun/awt/CDropTarget.h	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -31,9 +31,15 @@
 
 @class ControlModel;
 
+@class CDropTarget;
+
+@protocol CDropTargetHolder
+- (void) setDropTarget:(CDropTarget *)target;
+@end
+
 @interface CDropTarget : NSObject {
 @private
-    NSView*        fView;
+    NSView<CDropTargetHolder>* fView;
     jobject            fComponent;
     jobject            fDropTarget;
     jobject            fDropTargetContextPeer;
--- a/src/macosx/native/sun/awt/CTrayIcon.m	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/native/sun/awt/CTrayIcon.m	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -135,7 +135,7 @@
 
     clickCount = [event clickCount];
 
-    static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/event/NSEvent");
+    static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent");
     static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDD)V");
     jobject jEvent = JNFNewObject(env, jctor_NSEvent,
                                   [event type],
@@ -152,7 +152,7 @@
     }
 
     static JNF_CLASS_CACHE(jc_TrayIcon, "sun/lwawt/macosx/CTrayIcon");
-    static JNF_MEMBER_CACHE(jm_handleMouseEvent, jc_TrayIcon, "handleMouseEvent", "(Lsun/lwawt/macosx/event/NSEvent;)V");
+    static JNF_MEMBER_CACHE(jm_handleMouseEvent, jc_TrayIcon, "handleMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V");
     JNFCallVoidMethod(env, peer, jm_handleMouseEvent, jEvent);
 }
 
--- a/src/macosx/native/sun/awt/CWrapper.h	Wed Feb 26 19:26:42 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, 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.
- */
--- a/src/macosx/native/sun/awt/CWrapper.m	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/macosx/native/sun/awt/CWrapper.m	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -23,38 +23,11 @@
  * questions.
  */
 
-#import "CWrapper.h"
-
 #import <JavaNativeFoundation/JavaNativeFoundation.h>
-
-#import "AWTWindow.h"
-#import "LWCToolkit.h"
-#import "GeomUtilities.h"
 #import "ThreadUtilities.h"
-
 #import "sun_lwawt_macosx_CWrapper_NSWindow.h"
 
 /*
- * Class:     sun_lwawt_macosx_CWrapper$NSObject
- * Method:    release
- * Signature: (J)V
- */
-JNIEXPORT void JNICALL
-Java_sun_lwawt_macosx_CWrapper_00024NSObject_release
-(JNIEnv *env, jclass cls, jlong objectPtr)
-{
-JNF_COCOA_ENTER(env);
-
-    id obj = (id)jlong_to_ptr(objectPtr);
-    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
-        CFRelease(obj);
-    }];
-
-JNF_COCOA_EXIT(env);
-}
-
-
-/*
  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
  * Method:    makeKeyAndOrderFront
  * Signature: (J)V
@@ -249,6 +222,7 @@
     dispatch_once(&pred, ^{
         LEVELS[sun_lwawt_macosx_CWrapper_NSWindow_NSNormalWindowLevel] = NSNormalWindowLevel;
         LEVELS[sun_lwawt_macosx_CWrapper_NSWindow_NSFloatingWindowLevel] = NSFloatingWindowLevel;
+        LEVELS[sun_lwawt_macosx_CWrapper_NSWindow_NSPopUpMenuWindowLevel] = NSPopUpMenuWindowLevel;
     });
 }
 
@@ -308,8 +282,8 @@
 {
 JNF_COCOA_ENTER(env);
 
-    AWTWindow *parent = (AWTWindow *)jlong_to_ptr(parentPtr);
-    AWTWindow *child = (AWTWindow *)jlong_to_ptr(childPtr);
+    NSWindow *parent = (NSWindow *)jlong_to_ptr(parentPtr);
+    NSWindow *child = (NSWindow *)jlong_to_ptr(childPtr);
     [ThreadUtilities performOnMainThread:@selector(removeChildWindow:)
                                       on:parent
                               withObject:child
@@ -320,26 +294,6 @@
 
 /*
  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
- * Method:    setFrame
- * Signature: (JIIIIZ)V
- */
-JNIEXPORT void JNICALL
-Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setFrame
-(JNIEnv *env, jclass cls, jlong windowPtr, jint x, jint y, jint w, jint h, jboolean display)
-{
-JNF_COCOA_ENTER(env);
-
-    AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr);
-    NSRect frame = NSMakeRect(x, y, w, h);
-    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
-        [window setFrame:frame display:display];
-    }];
-
-JNF_COCOA_EXIT(env);
-}
-
-/*
- * Class:     sun_lwawt_macosx_CWrapper$NSWindow
  * Method:    setAlphaValue
  * Signature: (JF)V
  */
@@ -349,7 +303,7 @@
 {
 JNF_COCOA_ENTER(env);
 
-    AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr);
+    NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
     [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [window setAlphaValue:(CGFloat)alpha];
     }];
@@ -368,7 +322,7 @@
 {
 JNF_COCOA_ENTER(env);
 
-    AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr);
+    NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
     [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [window setOpaque:(BOOL)opaque];
     }];
@@ -387,7 +341,7 @@
 {
 JNF_COCOA_ENTER(env);
 
-    AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr);
+    NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
     NSColor *color = (NSColor *)jlong_to_ptr(colorPtr);
     [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [window setBackgroundColor:color];
@@ -397,6 +351,7 @@
 }
 
 /*
+ * Class:     sun_lwawt_macosx_CWrapper$NSWindow
  * Method:    miniaturize
  * Signature: (J)V
  */
@@ -560,33 +515,6 @@
 
 /*
  * Class:     sun_lwawt_macosx_CWrapper$NSView
- * Method:    frame
- * Signature: (J)Ljava/awt/Rectangle;
- */
-JNIEXPORT jobject JNICALL
-Java_sun_lwawt_macosx_CWrapper_00024NSView_frame
-(JNIEnv *env, jclass cls, jlong viewPtr)
-{
-    jobject jRect = NULL;
-
-JNF_COCOA_ENTER(env);
-
-    __block NSRect rect = NSZeroRect;
-
-    NSView *view = (NSView *)jlong_to_ptr(viewPtr);
-    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
-        rect = [view frame];
-    }];
-
-    jRect = NSToJavaRect(env, rect);
-
-JNF_COCOA_EXIT(env);
-
-    return jRect;
-}
-
-/*
- * Class:     sun_lwawt_macosx_CWrapper$NSView
  * Method:    window
  * Signature: (J)J
  */
--- a/src/share/classes/java/awt/DefaultKeyboardFocusManager.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/share/classes/java/awt/DefaultKeyboardFocusManager.java	Thu Mar 13 14:55:50 2014 -0700
@@ -287,7 +287,7 @@
         synchronized (this) {
             KeyEvent ke = enqueuedKeyEvents.isEmpty() ? null : enqueuedKeyEvents.getFirst();
             if (ke != null && time >= ke.getWhen()) {
-                TypeAheadMarker marker = typeAheadMarkers.getFirst();
+                TypeAheadMarker marker = typeAheadMarkers.isEmpty() ? null : typeAheadMarkers.getFirst();
                 if (marker != null) {
                     Window toplevel = marker.untilFocused.getContainingWindow();
                     // Check that the component awaiting focus belongs to
--- a/src/share/classes/java/awt/SystemColor.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/share/classes/java/awt/SystemColor.java	Thu Mar 13 14:55:50 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, 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
@@ -24,6 +24,8 @@
  */
 package java.awt;
 
+import sun.awt.AWTAccessor;
+
 import java.io.ObjectStreamException;
 
 import java.lang.annotation.Native;
@@ -459,7 +461,8 @@
     };
 
     static {
-      updateSystemColors();
+        AWTAccessor.setSystemColorAccessor(SystemColor::updateSystemColors);
+        updateSystemColors();
     }
 
     /**
--- a/src/share/classes/java/awt/datatransfer/DataFlavor.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/share/classes/java/awt/datatransfer/DataFlavor.java	Thu Mar 13 14:55:50 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, 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
@@ -570,7 +570,7 @@
         if (DataTransferer.isFlavorCharsetTextType(this) &&
             (isRepresentationClassInputStream() ||
              isRepresentationClassByteBuffer() ||
-             DataTransferer.byteArrayClass.equals(representationClass)))
+             byte[].class.equals(representationClass)))
         {
             params += ";charset=" + DataTransferer.getTextCharset(this);
         }
@@ -1015,7 +1015,7 @@
                     !(isRepresentationClassReader() ||
                         String.class.equals(representationClass) ||
                         isRepresentationClassCharBuffer() ||
-                        DataTransferer.charArrayClass.equals(representationClass)))
+                        char[].class.equals(representationClass)))
                 {
                     String thisCharset =
                         DataTransferer.canonicalName(getParameter("charset"));
@@ -1100,8 +1100,7 @@
                 !(isRepresentationClassReader() ||
                   String.class.equals(representationClass) ||
                   isRepresentationClassCharBuffer() ||
-                  DataTransferer.charArrayClass.equals
-                  (representationClass)))
+                  char[].class.equals(representationClass)))
             {
                 String charset =
                     DataTransferer.canonicalName(getParameter("charset"));
--- a/src/share/classes/java/awt/dnd/DragGestureEvent.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/share/classes/java/awt/dnd/DragGestureEvent.java	Thu Mar 13 14:55:50 2014 -0700
@@ -36,6 +36,7 @@
 
 import java.awt.datatransfer.Transferable;
 
+import java.io.InvalidObjectException;
 import java.util.EventObject;
 
 import java.util.Collections;
@@ -329,22 +330,50 @@
     {
         ObjectInputStream.GetField f = s.readFields();
 
-        dragSource = (DragSource)f.get("dragSource", null);
-        component = (Component)f.get("component", null);
-        origin = (Point)f.get("origin", null);
-        action = f.get("action", 0);
+        DragSource newDragSource = (DragSource)f.get("dragSource", null);
+        if (newDragSource == null) {
+            throw new InvalidObjectException("null DragSource");
+        }
+        dragSource = newDragSource;
+
+        Component newComponent = (Component)f.get("component", null);
+        if (newComponent == null) {
+            throw new InvalidObjectException("null component");
+        }
+        component = newComponent;
+
+        Point newOrigin = (Point)f.get("origin", null);
+        if (newOrigin == null) {
+            throw new InvalidObjectException("null origin");
+        }
+        origin = newOrigin;
+
+        int newAction = f.get("action", 0);
+        if (newAction != DnDConstants.ACTION_COPY &&
+                newAction != DnDConstants.ACTION_MOVE &&
+                newAction != DnDConstants.ACTION_LINK) {
+            throw new InvalidObjectException("bad action");
+        }
+        action = newAction;
+
         // Pre-1.4 support. 'events' was previously non-transient
+        List newEvents;
         try {
-            events = (List)f.get("events", null);
+            newEvents = (List)f.get("events", null);
         } catch (IllegalArgumentException e) {
             // 1.4-compatible byte stream. 'events' was written explicitly
-            events = (List)s.readObject();
+            newEvents = (List)s.readObject();
         }
 
         // Implementation assumes 'events' is never null.
-        if (events == null) {
-            events = Collections.EMPTY_LIST;
+        if (newEvents != null && newEvents.isEmpty()) {
+            // Constructor treats empty events list as invalid value
+            // Throw exception if serialized list is empty
+            throw new InvalidObjectException("empty list of events");
+        } else if (newEvents == null) {
+            newEvents = Collections.emptyList();
         }
+        events = newEvents;
     }
 
     /*
--- a/src/share/classes/java/awt/dnd/DragGestureRecognizer.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/share/classes/java/awt/dnd/DragGestureRecognizer.java	Thu Mar 13 14:55:50 2014 -0700
@@ -29,6 +29,8 @@
 import java.awt.Component;
 import java.awt.Point;
 
+import java.io.InvalidObjectException;
+import java.util.Collections;
 import java.util.TooManyListenersException;
 import java.util.ArrayList;
 
@@ -411,10 +413,21 @@
      *
      * @since 1.4
      */
+    @SuppressWarnings("unchecked")
     private void readObject(ObjectInputStream s)
         throws ClassNotFoundException, IOException
     {
-        s.defaultReadObject();
+        ObjectInputStream.GetField f = s.readFields();
+
+        DragSource newDragSource = (DragSource)f.get("dragSource", null);
+        if (newDragSource == null) {
+            throw new InvalidObjectException("null DragSource");
+        }
+        dragSource = newDragSource;
+
+        component = (Component)f.get("component", null);
+        sourceActions = f.get("sourceActions", 0) & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);
+        events = (ArrayList<InputEvent>)f.get("events", new ArrayList<>(1));
 
         dragGestureListener = (DragGestureListener)s.readObject();
     }
--- a/src/share/classes/java/awt/dnd/DragSourceContext.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/share/classes/java/awt/dnd/DragSourceContext.java	Thu Mar 13 14:55:50 2014 -0700
@@ -37,6 +37,7 @@
 import java.awt.dnd.peer.DragSourceContextPeer;
 
 import java.io.IOException;
+import java.io.InvalidObjectException;
 import java.io.ObjectOutputStream;
 import java.io.ObjectInputStream;
 import java.io.Serializable;
@@ -562,7 +563,36 @@
     private void readObject(ObjectInputStream s)
         throws ClassNotFoundException, IOException
     {
-        s.defaultReadObject();
+        ObjectInputStream.GetField f = s.readFields();
+
+        DragGestureEvent newTrigger = (DragGestureEvent)f.get("trigger", null);
+        if (newTrigger == null) {
+            throw new InvalidObjectException("Null trigger");
+        }
+        if (newTrigger.getDragSource() == null) {
+            throw new InvalidObjectException("Null DragSource");
+        }
+        if (newTrigger.getComponent() == null) {
+            throw new InvalidObjectException("Null trigger component");
+        }
+
+        int DGRActions = newTrigger.getSourceAsDragGestureRecognizer().getSourceActions()
+                & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);
+        if (DGRActions == DnDConstants.ACTION_NONE) {
+            throw new InvalidObjectException("Invalid source actions");
+        }
+        int triggerActions = newTrigger.getDragAction();
+        if (triggerActions != DnDConstants.ACTION_COPY &&
+                triggerActions != DnDConstants.ACTION_MOVE &&
+                triggerActions != DnDConstants.ACTION_LINK) {
+            throw new InvalidObjectException("No drag action");
+        }
+        trigger = newTrigger;
+
+        cursor = (Cursor)f.get("cursor", null);
+        useCustomCursor = f.get("useCustomCursor", false);
+        sourceActions = f.get("sourceActions", 0)
+                & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);
 
         transferable = (Transferable)s.readObject();
         listener = (DragSourceListener)s.readObject();
@@ -630,5 +660,5 @@
      *
      * @serial
      */
-    private final int sourceActions;
+    private int sourceActions;
 }
--- a/src/share/classes/java/io/FileInputStream.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/share/classes/java/io/FileInputStream.java	Thu Mar 13 14:55:50 2014 -0700
@@ -51,6 +51,12 @@
     /* File Descriptor - handle to the open file */
     private final FileDescriptor fd;
 
+    /**
+     * The path of the referenced file
+     * (null if the stream is created with a file descriptor)
+     */
+    private final String path;
+
     private FileChannel channel = null;
 
     private final Object closeLock = new Object();
@@ -128,6 +134,7 @@
         }
         fd = new FileDescriptor();
         fd.attach(this);
+        path = name;
         open(name);
     }
 
@@ -164,6 +171,7 @@
             security.checkRead(fdObj);
         }
         fd = fdObj;
+        path = null;
 
         /*
          * FileDescriptor is being shared by streams.
@@ -186,7 +194,11 @@
      *             file is reached.
      * @exception  IOException  if an I/O error occurs.
      */
-    public native int read() throws IOException;
+    public int read() throws IOException {
+        return read0();
+    }
+
+    private native int read0() throws IOException;
 
     /**
      * Reads a subarray as a sequence of bytes.
@@ -345,7 +357,7 @@
     public FileChannel getChannel() {
         synchronized (this) {
             if (channel == null) {
-                channel = FileChannelImpl.open(fd, true, false, this);
+                channel = FileChannelImpl.open(fd, path, true, false, this);
             }
             return channel;
         }
--- a/src/share/classes/java/io/FileOutputStream.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/share/classes/java/io/FileOutputStream.java	Thu Mar 13 14:55:50 2014 -0700
@@ -67,6 +67,12 @@
      */
     private FileChannel channel;
 
+    /**
+     * The path of the referenced file
+     * (null if the stream is created with a file descriptor)
+     */
+    private final String path;
+
     private final Object closeLock = new Object();
     private volatile boolean closed = false;
 
@@ -202,6 +208,7 @@
         this.fd = new FileDescriptor();
         fd.attach(this);
         this.append = append;
+        this.path = name;
 
         open(name, append);
     }
@@ -239,6 +246,7 @@
         }
         this.fd = fdObj;
         this.append = false;
+        this.path = null;
 
         fd.attach(this);
     }
@@ -376,7 +384,7 @@
     public FileChannel getChannel() {
         synchronized (this) {
             if (channel == null) {
-                channel = FileChannelImpl.open(fd, false, true, append, this);
+                channel = FileChannelImpl.open(fd, path, false, true, append, this);
             }
             return channel;
         }
--- a/src/share/classes/java/io/RandomAccessFile.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/share/classes/java/io/RandomAccessFile.java	Thu Mar 13 14:55:50 2014 -0700
@@ -62,6 +62,12 @@
     private FileChannel channel = null;
     private boolean rw;
 
+    /**
+     * The path of the referenced file
+     * (null if the stream is created with a file descriptor)
+     */
+    private final String path;
+
     private Object closeLock = new Object();
     private volatile boolean closed = false;
 
@@ -233,6 +239,7 @@
         }
         fd = new FileDescriptor();
         fd.attach(this);
+        path = name;
         open(name, imode);
     }
 
@@ -272,7 +279,7 @@
     public final FileChannel getChannel() {
         synchronized (this) {
             if (channel == null) {
-                channel = FileChannelImpl.open(fd, true, rw, this);
+                channel = FileChannelImpl.open(fd, path, true, rw, this);
             }
             return channel;
         }
@@ -309,7 +316,11 @@
      * @exception  IOException  if an I/O error occurs. Not thrown if
      *                          end-of-file has been reached.
      */
-    public native int read() throws IOException;
+    public int read() throws IOException {
+        return read0();
+    }
+
+    private native int read0() throws IOException;
 
     /**
      * Reads a sub array as a sequence of bytes.
@@ -457,7 +468,11 @@
      * @param      b   the {@code byte} to be written.
      * @exception  IOException  if an I/O error occurs.
      */
-    public native void write(int b) throws IOException;
+    public void write(int b) throws IOException {
+        write0(b);
+    }
+
+    private native void write0(int b) throws IOException;
 
     /**
      * Writes a sub array as a sequence of bytes.
--- a/src/share/classes/java/lang/invoke/AbstractValidatingLambdaMetafactory.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/share/classes/java/lang/invoke/AbstractValidatingLambdaMetafactory.java	Thu Mar 13 14:55:50 2014 -0700
@@ -200,6 +200,13 @@
                                   implIsInstanceMethod ? "instance" : "static", implInfo,
                                   instantiatedArity, samArity));
         }
+        for (MethodType bridgeMT : additionalBridges) {
+            if (bridgeMT.parameterCount() != samArity) {
+                throw new LambdaConversionException(
+                        String.format("Incorrect number of parameters for bridge signature %s; incompatible with %s",
+                                      bridgeMT, samMethodType));
+            }
+        }
 
         // If instance: first captured arg (receiver) must be subtype of class where impl method is defined
         final int capturedStart;
@@ -232,7 +239,7 @@
                throw new LambdaConversionException(
                        String.format("Invalid receiver type %s; not a subtype of implementation receiver type %s",
                                      receiverClass, implReceiverClass));
-             }
+            }
         } else {
             // no receiver
             capturedStart = 0;
@@ -274,11 +281,18 @@
                     String.format("Type mismatch for lambda return: %s is not convertible to %s",
                                   actualReturnType, expectedType));
         }
-        if (!isAdaptableToAsReturn(expectedType, samReturnType)) {
+        if (!isAdaptableToAsReturnStrict(expectedType, samReturnType)) {
             throw new LambdaConversionException(
                     String.format("Type mismatch for lambda expected return: %s is not convertible to %s",
                                   expectedType, samReturnType));
         }
+        for (MethodType bridgeMT : additionalBridges) {
+            if (!isAdaptableToAsReturnStrict(expectedType, bridgeMT.returnType())) {
+                throw new LambdaConversionException(
+                        String.format("Type mismatch for lambda expected return: %s is not convertible to %s",
+                                      expectedType, bridgeMT.returnType()));
+            }
+        }
      }
 
     /**
@@ -330,6 +344,10 @@
         return toType.equals(void.class)
                || !fromType.equals(void.class) && isAdaptableTo(fromType, toType, false);
     }
+    private boolean isAdaptableToAsReturnStrict(Class<?> fromType, Class<?> toType) {
+        if (fromType.equals(void.class)) return toType.equals(void.class);
+        return isAdaptableTo(fromType, toType, true);
+    }
 
 
     /*********** Logging support -- for debugging only, uncomment as needed
--- a/src/share/classes/java/lang/invoke/TypeConvertingMethodAdapter.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/share/classes/java/lang/invoke/TypeConvertingMethodAdapter.java	Thu Mar 13 14:55:50 2014 -0700
@@ -212,7 +212,7 @@
      * @param functional
      */
     void convertType(Class<?> arg, Class<?> target, Class<?> functional) {
-        if (arg.equals(target)) {
+        if (arg.equals(target) && arg.equals(functional)) {
             return;
         }
         if (arg == Void.TYPE || target == Void.TYPE) {
--- a/src/share/classes/sun/awt/AWTAccessor.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/share/classes/sun/awt/AWTAccessor.java	Thu Mar 13 14:55:50 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -729,6 +729,13 @@
     }
 
     /*
+     * An accessor object for the SystemColor class
+     */
+    public interface SystemColorAccessor {
+        void updateSystemColors();
+    }
+
+    /*
      * Accessor instances are initialized in the static initializers of
      * corresponding AWT classes by using setters defined below.
      */
@@ -757,6 +764,7 @@
     private static SequencedEventAccessor sequencedEventAccessor;
     private static ToolkitAccessor toolkitAccessor;
     private static InvocationEventAccessor invocationEventAccessor;
+    private static SystemColorAccessor systemColorAccessor;
 
     /*
      * Set an accessor object for the java.awt.Component class.
@@ -1182,4 +1190,22 @@
     public static InvocationEventAccessor getInvocationEventAccessor() {
         return invocationEventAccessor;
     }
+
+    /*
+     * Get the accessor object for the java.awt.SystemColor class.
+     */
+    public static SystemColorAccessor getSystemColorAccessor() {
+        if (systemColorAccessor == null) {
+            unsafe.ensureClassInitialized(SystemColor.class);
+        }
+
+        return systemColorAccessor;
+    }
+
+     /*
+     * Set the accessor object for the java.awt.SystemColor class.
+     */
+     public static void setSystemColorAccessor(SystemColorAccessor systemColorAccessor) {
+         AWTAccessor.systemColorAccessor = systemColorAccessor;
+     }
 }
--- a/src/share/classes/sun/awt/HToolkit.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/share/classes/sun/awt/HToolkit.java	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -25,6 +25,8 @@
 
 package sun.awt;
 
+import sun.awt.datatransfer.DataTransferer;
+
 import java.awt.*;
 import java.awt.dnd.*;
 import java.awt.dnd.peer.DragSourceContextPeer;
@@ -184,6 +186,11 @@
         return false;
     }
 
+    @Override
+    public DataTransferer getDataTransferer() {
+        return null;
+    }
+
     public GlobalCursorManager getGlobalCursorManager()
         throws HeadlessException {
         throw new HeadlessException();
--- a/src/share/classes/sun/awt/SunToolkit.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/share/classes/sun/awt/SunToolkit.java	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -46,6 +46,7 @@
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
+import sun.awt.datatransfer.DataTransferer;
 import sun.security.util.SecurityConstants;
 import sun.util.logging.PlatformLogger;
 import sun.misc.SoftCache;
@@ -203,6 +204,8 @@
 
     public abstract boolean isTraySupported();
 
+    public abstract DataTransferer getDataTransferer();
+
     @SuppressWarnings("deprecation")
     public abstract FontPeer getFontPeer(String name, int style);
 
@@ -1191,19 +1194,6 @@
         return getStartupLocale();
     }
 
-    private static String dataTransfererClassName = null;
-
-    protected static void setDataTransfererClassName(String className) {
-        dataTransfererClassName = className;
-    }
-
-    public static String getDataTransfererClassName() {
-        if (dataTransfererClassName == null) {
-            Toolkit.getDefaultToolkit(); // transferer set during toolkit init
-        }
-        return dataTransfererClassName;
-    }
-
     // Support for window closing event notifications
     private transient WindowClosingListener windowClosingListener = null;
     /**
--- a/src/share/classes/sun/awt/datatransfer/DataTransferer.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/share/classes/sun/awt/datatransfer/DataTransferer.java	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -25,10 +25,10 @@
 
 package sun.awt.datatransfer;
 
-import java.awt.AWTError;
 import java.awt.EventQueue;
+import java.awt.Graphics;
 import java.awt.Image;
-import java.awt.Graphics;
+import java.awt.Toolkit;
 
 import java.awt.datatransfer.DataFlavor;
 import java.awt.datatransfer.FlavorMap;
@@ -138,16 +138,6 @@
 public abstract class DataTransferer {
 
     /**
-     * Cached value of Class.forName("[C");
-     */
-    public static final Class charArrayClass;
-
-    /**
-     * Cached value of Class.forName("[B");
-     */
-    public static final Class byteArrayClass;
-
-    /**
      * The <code>DataFlavor</code> representing plain text with Unicode
      * encoding, where:
      * <pre>
@@ -241,15 +231,6 @@
     private static final PlatformLogger dtLog = PlatformLogger.getLogger("sun.awt.datatransfer.DataTransfer");
 
     static {
-        Class tCharArrayClass = null, tByteArrayClass = null;
-        try {
-            tCharArrayClass = Class.forName("[C");
-            tByteArrayClass = Class.forName("[B");
-        } catch (ClassNotFoundException cannotHappen) {
-        }
-        charArrayClass = tCharArrayClass;
-        byteArrayClass = tByteArrayClass;
-
         DataFlavor tPlainTextStringFlavor = null;
         try {
             tPlainTextStringFlavor = new DataFlavor
@@ -290,63 +271,8 @@
      * that in a headless environment, there may be no DataTransferer instance;
      * instead, null will be returned.
      */
-    public static DataTransferer getInstance() {
-        synchronized (DataTransferer.class) {
-            if (transferer == null) {
-                final String name = SunToolkit.getDataTransfererClassName();
-                if (name != null) {
-                    PrivilegedAction<DataTransferer> action = new PrivilegedAction<DataTransferer>()
-                    {
-                      public DataTransferer run() {
-                          Class cls = null;
-                          Method method = null;
-                          DataTransferer ret = null;
-
-                          try {
-                              cls = Class.forName(name);
-                          } catch (ClassNotFoundException e) {
-                              ClassLoader cl = ClassLoader.
-                                  getSystemClassLoader();
-                              if (cl != null) {
-                                  try {
-                                      cls = cl.loadClass(name);
-                                  } catch (ClassNotFoundException ee) {
-                                      ee.printStackTrace();
-                                      throw new AWTError("DataTransferer not found: " + name);
-                                  }
-                              }
-                          }
-                          if (cls != null) {
-                              try {
-                                  method = cls.getDeclaredMethod("getInstanceImpl");
-                                  method.setAccessible(true);
-                              } catch (NoSuchMethodException e) {
-                                  e.printStackTrace();
-                                  throw new AWTError("Cannot instantiate DataTransferer: " + name);
-                              } catch (SecurityException e) {
-                                  e.printStackTrace();
-                                  throw new AWTError("Access is denied for DataTransferer: " + name);
-                              }
-                          }
-                          if (method != null) {
-                              try {
-                                  ret = (DataTransferer) method.invoke(null);
-                              } catch (InvocationTargetException e) {
-                                  e.printStackTrace();
-                                  throw new AWTError("Cannot instantiate DataTransferer: " + name);
-                              } catch (IllegalAccessException e) {
-                                  e.printStackTrace();
-                                  throw new AWTError("Cannot access DataTransferer: " + name);
-                              }
-                          }
-                          return ret;
-                      }
-                    };
-                    transferer = AccessController.doPrivileged(action);
-                }
-            }
-        }
-        return transferer;
+    public static synchronized DataTransferer getInstance() {
+        return ((SunToolkit) Toolkit.getDefaultToolkit()).getDataTransferer();
     }
 
     /**
@@ -459,14 +385,14 @@
         if (flavor.isRepresentationClassReader() ||
             String.class.equals(rep_class) ||
             flavor.isRepresentationClassCharBuffer() ||
-            DataTransferer.charArrayClass.equals(rep_class))
+            char[].class.equals(rep_class))
         {
             return true;
         }
 
         if (!(flavor.isRepresentationClassInputStream() ||
               flavor.isRepresentationClassByteBuffer() ||
-              DataTransferer.byteArrayClass.equals(rep_class))) {
+              byte[].class.equals(rep_class))) {
             return false;
         }
 
@@ -490,8 +416,7 @@
 
         return (flavor.isRepresentationClassInputStream() ||
                 flavor.isRepresentationClassByteBuffer() ||
-                DataTransferer.byteArrayClass.
-                    equals(flavor.getRepresentationClass()));
+                byte[].class.equals(flavor.getRepresentationClass()));
     }
 
     /**
@@ -1243,7 +1168,7 @@
                 format);
 
         // Source data is a char array. Convert to a String and recur.
-        } else if (charArrayClass.equals(flavor.getRepresentationClass())) {
+        } else if (char[].class.equals(flavor.getRepresentationClass())) {
             if (!(isFlavorCharsetTextType(flavor) && isTextFormat(format))) {
                 throw new IOException
                     ("cannot transfer non-text data as char array");
@@ -1274,7 +1199,7 @@
         // Source data is a byte array. For arbitrary flavors, simply return
         // the array. For text flavors, decode back to a String and recur to
         // reencode according to the requested format.
-        } else if (byteArrayClass.equals(flavor.getRepresentationClass())) {
+        } else if (byte[].class.equals(flavor.getRepresentationClass())) {
             byte[] bytes = (byte[])obj;
 
             if (isFlavorCharsetTextType(flavor) && isTextFormat(format)) {
@@ -1651,7 +1576,7 @@
 
             // Target data is a char array. Recur to obtain String and convert to
             // char array.
-        } else if (charArrayClass.equals(flavor.getRepresentationClass())) {
+        } else if (char[].class.equals(flavor.getRepresentationClass())) {
             if (!(isFlavorCharsetTextType(flavor) && isTextFormat(format))) {
                 throw new IOException
                           ("cannot transfer non-text data as char array");
@@ -1679,7 +1604,7 @@
             // the raw bytes. For text flavors, convert to a String to strip
             // terminators and search-and-replace EOLN, then reencode according to
             // the requested flavor.
-        } else if (byteArrayClass.equals(flavor.getRepresentationClass())) {
+        } else if (byte[].class.equals(flavor.getRepresentationClass())) {
             if (isFlavorCharsetTextType(flavor) && isTextFormat(format)) {
                 theObject = translateBytesToString(
                     bytes, format, localeTransferable
@@ -1807,7 +1732,7 @@
 
             theObject = constructFlavoredObject(reader, flavor, Reader.class);
             // Target data is a byte array
-        } else if (byteArrayClass.equals(flavor.getRepresentationClass())) {
+        } else if (byte[].class.equals(flavor.getRepresentationClass())) {
             if(isFlavorCharsetTextType(flavor) && isTextFormat(format)) {
                 theObject = translateBytesToString(inputStreamToByteArray(str), format, localeTransferable)
                         .getBytes(DataTransferer.getTextCharset(flavor));
@@ -2857,7 +2782,7 @@
                 HashMap decodedTextRepresentationsMap = new HashMap(4, 1.0f);
 
                 decodedTextRepresentationsMap.put
-                    (DataTransferer.charArrayClass, Integer.valueOf(0));
+                    (char[].class, Integer.valueOf(0));
                 decodedTextRepresentationsMap.put
                     (java.nio.CharBuffer.class, Integer.valueOf(1));
                 decodedTextRepresentationsMap.put
@@ -2873,7 +2798,7 @@
                 HashMap encodedTextRepresentationsMap = new HashMap(3, 1.0f);
 
                 encodedTextRepresentationsMap.put
-                    (DataTransferer.byteArrayClass, Integer.valueOf(0));
+                    (byte[].class, Integer.valueOf(0));
                 encodedTextRepresentationsMap.put
                     (java.nio.ByteBuffer.class, Integer.valueOf(1));
                 encodedTextRepresentationsMap.put
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/awt/image/MultiResolutionBufferedImage.java	Thu Mar 13 14:55:50 2014 -0700
@@ -0,0 +1,71 @@
+/*
+ * 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.Image;
+import java.awt.Graphics;
+import java.awt.image.BufferedImage;
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Function;
+
+public class MultiResolutionBufferedImage extends BufferedImage
+        implements MultiResolutionImage {
+
+    Image[] resolutionVariants;
+    int baseIndex;
+
+    public MultiResolutionBufferedImage(int imageType, int baseIndex, Image... images) {
+        super(images[baseIndex].getWidth(null), images[baseIndex].getHeight(null),
+                imageType);
+        this.baseIndex = baseIndex;
+        this.resolutionVariants = images;
+        Graphics g = getGraphics();
+        g.drawImage(images[baseIndex], 0, 0, null);
+        g.dispose();
+        images[baseIndex] = this;
+    }
+
+    @Override
+    public Image getResolutionVariant(int width, int height) {
+        for (Image image : resolutionVariants) {
+            if (width <= image.getWidth(null) && height <= image.getHeight(null)) {
+                return image;
+            }
+        }
+        return this;
+    }
+
+    @Override
+    public List<Image> getResolutionVariants() {
+        return Arrays.asList(resolutionVariants);
+    }
+
+    public MultiResolutionBufferedImage map(Function<Image, Image> mapper) {
+        return new MultiResolutionBufferedImage(getType(), baseIndex,
+                Arrays.stream(resolutionVariants).map(mapper)
+                        .toArray(length -> new Image[length]));
+    }
+}
--- a/src/share/classes/sun/nio/ch/FileChannelImpl.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/share/classes/sun/nio/ch/FileChannelImpl.java	Thu Mar 13 14:55:50 2014 -0700
@@ -29,10 +29,20 @@
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.MappedByteBuffer;
-import java.nio.channels.*;
+import java.nio.channels.ClosedByInterruptException;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileLock;
+import java.nio.channels.FileLockInterruptionException;
+import java.nio.channels.NonReadableChannelException;
+import java.nio.channels.NonWritableChannelException;
+import java.nio.channels.OverlappingFileLockException;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.WritableByteChannel;
+import java.security.AccessController;
 import java.util.ArrayList;
 import java.util.List;
-import java.security.AccessController;
+
 import sun.misc.Cleaner;
 import sun.security.action.GetPropertyAction;
 
@@ -56,13 +66,17 @@
     // Required to prevent finalization of creating stream (immutable)
     private final Object parent;
 
+    // The path of the referenced file
+    // (null if the parent stream is created with a file descriptor)
+    private final String path;
+
     // Thread-safe set of IDs of native threads, for signalling
     private final NativeThreadSet threads = new NativeThreadSet(2);
 
     // Lock for operations involving position and size
     private final Object positionLock = new Object();
 
-    private FileChannelImpl(FileDescriptor fd, boolean readable,
+    private FileChannelImpl(FileDescriptor fd, String path, boolean readable,
                             boolean writable, boolean append, Object parent)
     {
         this.fd = fd;
@@ -70,23 +84,24 @@
         this.writable = writable;
         this.append = append;
         this.parent = parent;
+        this.path = path;
         this.nd = new FileDispatcherImpl(append);
     }
 
     // Used by FileInputStream.getChannel() and RandomAccessFile.getChannel()
-    public static FileChannel open(FileDescriptor fd,
+    public static FileChannel open(FileDescriptor fd, String path,
                                    boolean readable, boolean writable,
                                    Object parent)
     {
-        return new FileChannelImpl(fd, readable, writable, false, parent);
+        return new FileChannelImpl(fd, path, readable, writable, false, parent);
     }
 
     // Used by FileOutputStream.getChannel
-    public static FileChannel open(FileDescriptor fd,
+    public static FileChannel open(FileDescriptor fd, String path,
                                    boolean readable, boolean writable,
                                    boolean append, Object parent)
     {
-        return new FileChannelImpl(fd, readable, writable, append, parent);
+        return new FileChannelImpl(fd, path, readable, writable, append, parent);
     }
 
     private void ensureOpen() throws IOException {
--- a/src/share/native/common/jni_util.h	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/share/native/common/jni_util.h	Thu Mar 13 14:55:50 2014 -0700
@@ -297,6 +297,21 @@
         }                                       \
     } while (0)                                 \
 
+#ifdef __cplusplus
+#define JNU_CHECK_EXCEPTION(env)                \
+    do {                                        \
+        if ((env)->ExceptionCheck()) {          \
+            return;                             \
+        }                                       \
+    } while (0)                                 \
+
+#define JNU_CHECK_EXCEPTION_RETURN(env, y)      \
+    do {                                        \
+        if ((env)->ExceptionCheck()) {          \
+            return (y);                         \
+        }                                       \
+    } while (0)
+#else
 #define JNU_CHECK_EXCEPTION(env)                \
     do {                                        \
         if ((*env)->ExceptionCheck(env)) {      \
@@ -310,7 +325,7 @@
             return (y);                         \
         }                                       \
     } while (0)
-
+#endif /* __cplusplus */
 /************************************************************************
  * Debugging utilities
  */
--- a/src/share/native/java/io/FileInputStream.c	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/share/native/java/io/FileInputStream.c	Thu Mar 13 14:55:50 2014 -0700
@@ -62,7 +62,7 @@
 }
 
 JNIEXPORT jint JNICALL
-Java_java_io_FileInputStream_read(JNIEnv *env, jobject this) {
+Java_java_io_FileInputStream_read0(JNIEnv *env, jobject this) {
     return readSingle(env, this, fis_fd);
 }
 
--- a/src/share/native/java/io/RandomAccessFile.c	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/share/native/java/io/RandomAccessFile.c	Thu Mar 13 14:55:50 2014 -0700
@@ -64,7 +64,7 @@
 }
 
 JNIEXPORT jint JNICALL
-Java_java_io_RandomAccessFile_read(JNIEnv *env, jobject this) {
+Java_java_io_RandomAccessFile_read0(JNIEnv *env, jobject this) {
     return readSingle(env, this, raf_fd);
 }
 
@@ -75,7 +75,7 @@
 }
 
 JNIEXPORT void JNICALL
-Java_java_io_RandomAccessFile_write(JNIEnv *env, jobject this, jint byte) {
+Java_java_io_RandomAccessFile_write0(JNIEnv *env, jobject this, jint byte) {
     writeSingle(env, this, byte, JNI_FALSE, raf_fd);
 }
 
--- a/src/solaris/classes/sun/awt/X11/XDataTransferer.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/solaris/classes/sun/awt/X11/XDataTransferer.java	Thu Mar 13 14:55:50 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -77,11 +77,9 @@
 
     private static XDataTransferer transferer;
 
-    static XDataTransferer getInstanceImpl() {
-        synchronized (XDataTransferer.class) {
-            if (transferer == null) {
-                transferer = new XDataTransferer();
-            }
+    static synchronized XDataTransferer getInstanceImpl() {
+        if (transferer == null) {
+            transferer = new XDataTransferer();
         }
         return transferer;
     }
@@ -411,7 +409,7 @@
         if (df.getRepresentationClass() != null &&
             (df.isRepresentationClassInputStream() ||
              df.isRepresentationClassByteBuffer() ||
-             byteArrayClass.equals(df.getRepresentationClass()))) {
+             byte[].class.equals(df.getRepresentationClass()))) {
             natives.add(mimeType);
         }
 
--- a/src/solaris/classes/sun/awt/X11/XToolkit.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/solaris/classes/sun/awt/X11/XToolkit.java	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -47,6 +47,7 @@
 import javax.swing.LookAndFeel;
 import javax.swing.UIDefaults;
 import sun.awt.*;
+import sun.awt.datatransfer.DataTransferer;
 import sun.font.FontConfigManager;
 import sun.java2d.SunGraphicsEnvironment;
 import sun.misc.PerformanceLogger;
@@ -300,8 +301,6 @@
         return awtAppClassName;
     }
 
-    static final String DATA_TRANSFERER_CLASS_NAME = "sun.awt.X11.XDataTransferer";
-
     public XToolkit() {
         super();
         if (PerformanceLogger.loggingEnabled()) {
@@ -323,7 +322,6 @@
 
             init();
             XWM.init();
-            SunToolkit.setDataTransfererClassName(DATA_TRANSFERER_CLASS_NAME);
 
             PrivilegedAction<Thread> action = new PrivilegedAction() {
                 public Thread run() {
@@ -1125,6 +1123,11 @@
         return false;
     }
 
+    @Override
+    public DataTransferer getDataTransferer() {
+        return XDataTransferer.getInstanceImpl();
+    }
+
     /**
      * Returns the supported cursor size
      */
--- a/src/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java	Thu Mar 13 14:55:50 2014 -0700
@@ -149,7 +149,7 @@
                 int afd = openat(fd, nameAsBytes(file,name), (O_RDONLY|O_XATTR), 0);
 
                 // wrap with channel
-                FileChannel fc = UnixChannelFactory.newFileChannel(afd, true, false);
+                FileChannel fc = UnixChannelFactory.newFileChannel(afd, file.toString(), true, false);
 
                 // read to EOF (nothing we can do if I/O error occurs)
                 try {
@@ -190,7 +190,7 @@
                                  UnixFileModeAttribute.ALL_PERMISSIONS);
 
                 // wrap with channel
-                FileChannel fc = UnixChannelFactory.newFileChannel(afd, false, true);
+                FileChannel fc = UnixChannelFactory.newFileChannel(afd, file.toString(), false, true);
 
                 // write value (nothing we can do if I/O error occurs)
                 try {
--- a/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java	Thu Mar 13 14:55:50 2014 -0700
@@ -100,10 +100,10 @@
     /**
      * Constructs a file channel from an existing (open) file descriptor
      */
-    static FileChannel newFileChannel(int fd, boolean reading, boolean writing) {
+    static FileChannel newFileChannel(int fd, String path, boolean reading, boolean writing) {
         FileDescriptor fdObj = new FileDescriptor();
         fdAccess.set(fdObj, fd);
-        return FileChannelImpl.open(fdObj, reading, writing, null);
+        return FileChannelImpl.open(fdObj, path, reading, writing, null);
     }
 
     /**
@@ -134,7 +134,7 @@
             throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed");
 
         FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode);
-        return FileChannelImpl.open(fdObj, flags.read, flags.write, flags.append, null);
+        return FileChannelImpl.open(fdObj, path.toString(), flags.read, flags.write, flags.append, null);
     }
 
     /**
--- a/src/solaris/native/java/net/PlainDatagramSocketImpl.c	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/solaris/native/java/net/PlainDatagramSocketImpl.c	Thu Mar 13 14:55:50 2014 -0700
@@ -517,6 +517,8 @@
         } else if (ret == JVM_IO_ERR) {
             if (errno == EBADF) {
                  JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
+            } else if (errno == ENOMEM) {
+                 JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
             } else {
                  NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Peek failed");
             }
@@ -617,15 +619,18 @@
                             "Receive timed out");
             return -1;
         } else if (ret == JVM_IO_ERR) {
+            if (errno == ENOMEM) {
+                JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
 #ifdef __linux__
-            if (errno == EBADF) {
+            } else if (errno == EBADF) {
                 JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
             } else {
                 NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed");
+#else
+            } else {
+                JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
+#endif
             }
-#else
-            JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
-#endif
             return -1;
         } else if (ret == JVM_IO_INTR) {
             JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
@@ -835,15 +840,18 @@
                     JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                                     "Receive timed out");
                 } else if (ret == JVM_IO_ERR) {
+                     if (errno == ENOMEM) {
+                        JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
 #ifdef __linux__
-                    if (errno == EBADF) {
+                     } else if (errno == EBADF) {
                          JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
                      } else {
                          NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed");
+#else
+                     } else {
+                         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
+#endif
                      }
-#else
-                     JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
-#endif
                 } else if (ret == JVM_IO_INTR) {
                     JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
                                     "operation interrupted");
--- a/src/solaris/native/java/net/PlainSocketImpl.c	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/solaris/native/java/net/PlainSocketImpl.c	Thu Mar 13 14:55:50 2014 -0700
@@ -708,7 +708,6 @@
         } else {
             ret = NET_Timeout(fd, timeout);
         }
-
         if (ret == 0) {
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                             "Accept timed out");
@@ -716,6 +715,8 @@
         } else if (ret == JVM_IO_ERR) {
             if (errno == EBADF) {
                JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
+            } else if (errno == ENOMEM) {
+               JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
             } else {
                NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Accept failed");
             }
--- a/src/solaris/native/java/net/SocketInputStream.c	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/solaris/native/java/net/SocketInputStream.c	Thu Mar 13 14:55:50 2014 -0700
@@ -108,6 +108,8 @@
             } else if (nread == JVM_IO_ERR) {
                 if (errno == EBADF) {
                      JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
+                 } else if (errno == ENOMEM) {
+                     JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
                  } else {
                      NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
                                                   "select/poll failed");
--- a/src/solaris/native/java/net/bsd_close.c	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/solaris/native/java/net/bsd_close.c	Thu Mar 13 14:55:50 2014 -0700
@@ -25,6 +25,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <sys/param.h>
 #include <signal.h>
 #include <pthread.h>
 #include <sys/types.h>
@@ -35,7 +36,6 @@
 #include <sys/uio.h>
 #include <unistd.h>
 #include <errno.h>
-
 #include <sys/poll.h>
 
 /*
@@ -347,6 +347,10 @@
 int NET_Timeout(int s, long timeout) {
     long prevtime = 0, newtime;
     struct timeval t, *tp = &t;
+    fd_set fds;
+    fd_set* fdsp = NULL;
+    int allocated = 0;
+    threadEntry_t self;
     fdEntry_t *fdEntry = getFdEntry(s);
 
     /*
@@ -376,20 +380,29 @@
         t.tv_usec = 0;
     }
 
+    if (s < FD_SETSIZE) {
+        fdsp = &fds;
+        FD_ZERO(fdsp);
+    } else {
+        int length = (howmany(s+1, NFDBITS)) * sizeof(int);
+        fdsp = (fd_set *) calloc(1, length);
+        if (fdsp == NULL) {
+            return -1;   // errno will be set to ENOMEM
+        }
+        allocated = 1;
+    }
+    FD_SET(s, fdsp);
+
     for(;;) {
-        fd_set rfds;
         int rv;
-        threadEntry_t self;
 
         /*
          * call select on the fd. If interrupted by our wakeup signal
          * errno will be set to EBADF.
          */
-        FD_ZERO(&rfds);
-        FD_SET(s, &rfds);
 
         startOp(fdEntry, &self);
-        rv = select(s+1, &rfds, 0, 0, tp);
+        rv = select(s+1, fdsp, 0, 0, tp);
         endOp(fdEntry, &self);
 
         /*
@@ -403,6 +416,8 @@
                 newtime = now.tv_sec * 1000  +  now.tv_usec / 1000;
                 timeout -= newtime - prevtime;
                 if (timeout <= 0) {
+                    if (allocated != 0)
+                        free(fdsp);
                     return 0;
                 }
                 prevtime = newtime;
@@ -410,6 +425,8 @@
                 t.tv_usec = (timeout % 1000) * 1000;
             }
         } else {
+            if (allocated != 0)
+                free(fdsp);
             return rv;
         }
 
--- a/src/solaris/native/java/net/linux_close.c	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/solaris/native/java/net/linux_close.c	Thu Mar 13 14:55:50 2014 -0700
@@ -34,7 +34,6 @@
 #include <sys/uio.h>
 #include <unistd.h>
 #include <errno.h>
-
 #include <sys/poll.h>
 
 /*
--- a/src/windows/classes/sun/awt/windows/WDataTransferer.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/windows/classes/sun/awt/windows/WDataTransferer.java	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -159,13 +159,9 @@
 
     private static WDataTransferer transferer;
 
-    public static WDataTransferer getInstanceImpl() {
+    static synchronized WDataTransferer getInstanceImpl() {
         if (transferer == null) {
-            synchronized (WDataTransferer.class) {
-                if (transferer == null) {
-                    transferer = new WDataTransferer();
-                }
-            }
+            transferer = new WDataTransferer();
         }
         return transferer;
     }
--- a/src/windows/classes/sun/awt/windows/WToolkit.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/windows/classes/sun/awt/windows/WToolkit.java	Thu Mar 13 14:55:50 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, 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
@@ -41,6 +41,7 @@
 import sun.awt.SunToolkit;
 import sun.awt.Win32GraphicsDevice;
 import sun.awt.Win32GraphicsEnvironment;
+import sun.awt.datatransfer.DataTransferer;
 import sun.java2d.d3d.D3DRenderQueue;
 import sun.java2d.opengl.OGLRenderQueue;
 
@@ -210,8 +211,6 @@
      */
     public native void embeddedEventLoopIdleProcessing();
 
-    public static final String DATA_TRANSFERER_CLASS_NAME = "sun.awt.windows.WDataTransferer";
-
     static class ToolkitDisposer implements sun.java2d.DisposerRecord {
         public void dispose() {
             WToolkit.postDispose();
@@ -255,8 +254,6 @@
             // swallow the exception
         }
 
-        SunToolkit.setDataTransfererClassName(DATA_TRANSFERER_CLASS_NAME);
-
         // Enabled "live resizing" by default.  It remains controlled
         // by the native system though.
         setDynamicLayout(true);
@@ -514,6 +511,11 @@
         return true;
     }
 
+    @Override
+    public DataTransferer getDataTransferer() {
+        return WDataTransferer.getInstanceImpl();
+    }
+
     public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer()
       throws HeadlessException
     {
--- a/src/windows/classes/sun/nio/fs/WindowsChannelFactory.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/windows/classes/sun/nio/fs/WindowsChannelFactory.java	Thu Mar 13 14:55:50 2014 -0700
@@ -25,19 +25,22 @@
 
 package sun.nio.fs;
 
-import java.nio.file.*;
-import java.nio.channels.*;
 import java.io.FileDescriptor;
 import java.io.IOException;
-import java.util.*;
+import java.nio.channels.AsynchronousFileChannel;
+import java.nio.channels.FileChannel;
+import java.nio.file.LinkOption;
+import java.nio.file.OpenOption;
+import java.nio.file.StandardOpenOption;
+import java.util.Set;
 
 import com.sun.nio.file.ExtendedOpenOption;
 
+import sun.misc.JavaIOFileDescriptorAccess;
+import sun.misc.SharedSecrets;
 import sun.nio.ch.FileChannelImpl;
 import sun.nio.ch.ThreadPool;
 import sun.nio.ch.WindowsAsynchronousFileChannelImpl;
-import sun.misc.SharedSecrets;
-import sun.misc.JavaIOFileDescriptorAccess;
 
 import static sun.nio.fs.WindowsNativeDispatcher.*;
 import static sun.nio.fs.WindowsConstants.*;
@@ -157,7 +160,7 @@
             throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed");
 
         FileDescriptor fdObj = open(pathForWindows, pathToCheck, flags, pSecurityDescriptor);
-        return FileChannelImpl.open(fdObj, flags.read, flags.write, flags.append, null);
+        return FileChannelImpl.open(fdObj, pathForWindows, flags.read, flags.write, flags.append, null);
     }
 
     /**
--- a/src/windows/native/sun/windows/ShellFolder2.cpp	Wed Feb 26 19:26:42 2014 +0100
+++ b/src/windows/native/sun/windows/ShellFolder2.cpp	Thu Mar 13 14:55:50 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -219,10 +219,15 @@
         return;
     }
     MID_pIShellFolder = env->GetMethodID(cls, "setIShellFolder", "(J)V");
+    CHECK_NULL(MID_pIShellFolder);
     FID_pIShellIcon = env->GetFieldID(cls, "pIShellIcon", "J");
+    CHECK_NULL(FID_pIShellIcon);
     MID_relativePIDL = env->GetMethodID(cls, "setRelativePIDL", "(J)V");
+    CHECK_NULL(MID_relativePIDL);
     FID_displayName = env->GetFieldID(cls, "displayName", "Ljava/lang/String;");
+    CHECK_NULL(FID_displayName);
     FID_folderType = env->GetFieldID(cls, "folderType", "Ljava/lang/String;");
+    CHECK_NULL(FID_folderType);
 }
 
 
@@ -719,8 +724,9 @@
     // Get relative PIDL for name
     LPITEMIDLIST pIDL;
     int nLength = env->GetStringLength(jname);
+    const jchar* strPath = env->GetStringChars(jname, NULL);
+    JNU_CHECK_EXCEPTION_RETURN(env, 0);
     jchar* wszPath = new jchar[nLength + 1];
-    const jchar* strPath = env->GetStringChars(jname, NULL);
     wcsncpy(reinterpret_cast<LPWSTR>(wszPath), reinterpret_cast<LPCWSTR>(strPath), nLength);
     wszPath[nLength] = 0;
     HRESULT res = pIShellFolder->ParseDisplayName(NULL, NULL,
@@ -811,6 +817,7 @@
     HICON hIcon = NULL;
     SHFILEINFO fileInfo;
     LPCTSTR pathStr = JNU_GetStringPlatformChars(env, absolutePath, NULL);
+    JNU_CHECK_EXCEPTION_RETURN(env, 0);
     if (fn_SHGetFileInfo(pathStr, 0L, &fileInfo, sizeof(fileInfo),
                          SHGFI_ICON | (getLargeIcon ? 0 : SHGFI_SMALLICON)) != 0) {
         hIcon = fileInfo.hIcon;
@@ -954,9 +961,11 @@
             ReleaseDC(NULL, dc);
             // Create java array
             iconBits = env->NewIntArray(nBits);
+            if (!(env->ExceptionCheck())) {
             // Copy values to java array
             env->SetIntArrayRegion(iconBits, 0, nBits, colorBits);
         }
+        }
         // Fix 4745575 GDI Resource Leak
         // MSDN
         // GetIconInfo creates bitmaps for the hbmMask and hbmColor members of ICONINFO.
@@ -1028,6 +1037,7 @@
      jint cxDesired, jint cyDesired, jboolean useVGAColors)
 {
     const char *pLibName = env->GetStringUTFChars(libName, NULL);
+    JNU_CHECK_EXCEPTION_RETURN(env, 0);
     HINSTANCE libHandle = (HINSTANCE)JDK_LoadSystemLibrary(pLibName);
     if (libHandle != NULL) {
         UINT fuLoad = (useVGAColors && !IS_WINXP) ? LR_VGACOLOR : 0;
@@ -1046,8 +1056,11 @@
                                 jclass *pClass, jmethodID *pConstructor,
                                 SHELLDETAILS *psd, ULONG visible)
 {
+    jstring str = jstringFromSTRRET(pEnv, NULL, &(psd->str));
+    JNU_CHECK_EXCEPTION_RETURN(pEnv, NULL);
+
     return pEnv->NewObject(*pClass, *pConstructor,
-                    jstringFromSTRRET(pEnv, NULL, &(psd->str)),
+                    str,
                     (jint)(psd->cxChar * 6), // TODO: is 6 OK for converting chars to pixels?
                     (jint)psd->fmt, (jboolean) visible);
 }
@@ -1115,6 +1128,10 @@
                         jobject column = CreateColumnInfo(env,
                                             &columnClass, &columnConstructor,
                                             &sd, csFlags & SHCOLSTATE_ONBYDEFAULT);
+                        if(!column){
+                            pIShellFolder2->Release();
+                            return NULL;
+                        }
                         env->SetObjectArrayElement(columns, (jsize) colNum, column);
                     }
                 }
@@ -1155,6 +1172,10 @@
                 jobject column = CreateColumnInfo(env,
                                     &columnClass, &columnConstructor,
                                     &sd, 1);
+                if(!column){
+                    pIShellDetails->Release();
+                    return NULL;
+                }
                 env->SetObjectArrayElement(columns, (jsize) colNum++, column);
             }
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Choice/ChoiceLocationTest/ChoiceLocationTest.java	Thu Mar 13 14:55:50 2014 -0700
@@ -0,0 +1,96 @@
+/*
+ * 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 7159566
+  @summary The choice positioned in the top of applet when clicking the choice.
+  @author Petr Pchelko
+  @library ../../regtesthelpers
+  @build Util
+  @run main ChoiceLocationTest
+ */
+
+import java.awt.*;
+import javax.swing.*;
+import java.awt.event.InputEvent;
+import java.util.stream.Stream;
+
+import test.java.awt.regtesthelpers.Util;
+
+public class ChoiceLocationTest {
+
+    private static final int FRAME_LOCATION = 100;
+    private static final int FRAME_SIZE = 400;
+    private static final int CLICK_STEP = 5;
+
+    private static String[] choiceItems = new String[] {
+            "test item 1",
+            "test item 2",
+            "test item 3"
+    };
+
+    private static volatile Frame frame;
+    private static volatile Choice choice;
+
+    public static void main(String[] args) throws Exception {
+        try {
+            SwingUtilities.invokeAndWait(ChoiceLocationTest::initAndShowUI);
+            Robot r = new Robot();
+            r.waitForIdle();
+            r.delay(100);
+
+            Util.clickOnComp(choice, r);
+
+            choice.addItemListener(event -> {throw new RuntimeException("Failed: the choice popup is in the wrong place");});
+
+            // Test: click in several places on the top of the frame an ensure there' no choice there
+            Point locOnScreen = frame.getLocationOnScreen();
+            int x = locOnScreen.x + FRAME_SIZE / 2;
+            for (int y = locOnScreen.y + frame.getInsets().top + 10; y < locOnScreen.y + FRAME_SIZE / 3 ; y += CLICK_STEP) {
+                r.mouseMove(x, y);
+                r.waitForIdle();
+                r.mousePress(InputEvent.BUTTON1_MASK);
+                r.mouseRelease(InputEvent.BUTTON1_MASK);
+                r.waitForIdle();
+                r.delay(100);
+            }
+        } finally {
+            if (frame != null) {
+                frame.dispose();
+            }
+        }
+
+    }
+
+    private static void initAndShowUI() {
+        frame = new Frame("Test frame");
+        choice = new Choice();
+        Stream.of(choiceItems).forEach(choice::add);
+        frame.add(choice);
+        frame.setBounds(FRAME_LOCATION, FRAME_LOCATION, FRAME_SIZE, FRAME_SIZE);
+        frame.setVisible(true);
+    }
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/FileDialog/FileDialogForPackages/FileDialogForPackages.html	Thu Mar 13 14:55:50 2014 -0700
@@ -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 8026869
+  @summary Support apple.awt.use-file-dialog-packages property.
+  @author Petr Pchelko area=awt.filedialog
+  @library ../../regtesthelpers
+  @build Sysout
+  @run applet/manual=yesno FileDialogForPackages.html
+  -->
+<head>
+    <title> FileDialogForPackages </title>
+</head>
+<body>
+
+<h1>FileDialogForPackages<br>Bug ID: 8026869</h1>
+
+<p> See the dialog box (usually in upper left corner) for instructions</p>
+
+<APPLET CODE="FileDialogForPackages.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/FileDialog/FileDialogForPackages/FileDialogForPackages.java	Thu Mar 13 14:55:50 2014 -0700
@@ -0,0 +1,84 @@
+/*
+ * 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 sun.awt.OSInfo;
+import test.java.awt.regtesthelpers.Sysout;
+
+import java.applet.Applet;
+import java.awt.Button;
+import java.awt.FileDialog;
+import java.awt.Frame;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+public class FileDialogForPackages extends Applet implements ActionListener {
+    private static final String APPLICATIONS_FOLDER = "/Applications";
+
+    private volatile Button showBtn;
+    private volatile FileDialog fd;
+
+    @Override
+    public void init() {
+        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
+            Sysout.createDialogWithInstructions(new String[]{
+                    "Press PASS, this test is for MacOS X only."});
+            return;
+        }
+
+        System.setProperty("apple.awt.use-file-dialog-packages", "true");
+
+        setLayout(new GridLayout(1, 1));
+
+        fd = new FileDialog(new Frame(), "Open");
+        fd.setDirectory(APPLICATIONS_FOLDER);
+
+        showBtn = new Button("Show File Dialog");
+        showBtn.addActionListener(this);
+        add(showBtn);
+        String[] instructions = {
+                "1) Click on 'Show File Dialog' button. A file dialog will come up.",
+                "2) Navigate to the Applications folder if not already there",
+                "3) Check that the application bundles can be selected and can not be navigated",
+                "4) If it's true then the test passed, otherwise it failed."};
+        Sysout.createDialogWithInstructions(instructions);
+    }
+
+    @Override
+    public void start() {
+        setSize(200, 200);
+        show();
+    }
+
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        if (e.getSource() == showBtn) {
+            fd.setVisible(true);
+            String output = fd.getFile();
+            if (output != null) {
+                Sysout.println(output + " is selected");
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Mouse/MouseComboBoxTest/MouseComboBoxTest.java	Thu Mar 13 14:55:50 2014 -0700
@@ -0,0 +1,138 @@
+/*
+ * 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 8032872
+ * @summary Tests JComboBox selection via the mouse
+ * @author Dmitry Markov
+ */
+import sun.awt.SunToolkit;
+
+import javax.swing.*;
+import javax.swing.plaf.basic.BasicComboPopup;
+import javax.swing.plaf.basic.ComboPopup;
+import javax.swing.plaf.metal.MetalComboBoxUI;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+import java.awt.*;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+
+public class MouseComboBoxTest {
+    private static final String[] items = {"One", "Two", "Three", "Four", "Five"};
+
+    private static SunToolkit toolkit = null;
+    private static Robot robot = null;
+    private static JFrame frame = null;
+    private static JComboBox comboBox = null;
+    private static MyComboBoxUI comboBoxUI = null;
+
+    public static void main(String[] args) throws Exception {
+        toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        robot = new Robot();
+        robot.setAutoDelay(50);
+
+        UIManager.setLookAndFeel(new MetalLookAndFeel());
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                createAndShowGUI();
+            }
+        });
+        toolkit.realSync();
+
+        for (int i = 0; i < items.length; i++) {
+            // Open popup
+            robot.keyPress(KeyEvent.VK_DOWN);
+            robot.keyRelease(KeyEvent.VK_DOWN);
+            toolkit.realSync();
+
+            Point point = getItemPointToClick(i);
+            robot.mouseMove(point.x, point.y);
+            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+            toolkit.realSync();
+
+            if (i != getSelectedIndex()) {
+                throw new RuntimeException("Test Failed! Incorrect value of selected index = " + getSelectedIndex() +
+                        ", expected value = " + i);
+            }
+        }
+    }
+
+    private static Point getItemPointToClick(final int item) throws Exception {
+        final Point[] result = new Point[1];
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                BasicComboPopup popup = (BasicComboPopup)comboBoxUI.getComboPopup();
+                Point point = popup.getLocationOnScreen();
+                Dimension size = popup.getSize();
+
+                int step = size.height / items.length;
+                point.x += size.width / 2;
+                point.y += step / 2 + step * item;
+                result[0] = point;
+            }
+        });
+        return result[0];
+    }
+
+    private static int getSelectedIndex() throws Exception {
+        final int[] result = new int[1];
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                result[0] = comboBox.getSelectedIndex();
+            }
+        });
+        return result[0];
+    }
+
+    private static void createAndShowGUI() {
+        frame = new JFrame("MouseComboBoxTest");
+
+        comboBox = new JComboBox(items);
+        comboBox.setEditable(true);
+        comboBoxUI = new MyComboBoxUI();
+        comboBox.setUI(comboBoxUI);
+
+        frame.pack();
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.setVisible(true);
+
+        JWindow window = new JWindow(frame);
+        window.add(comboBox);
+        window.pack();
+        window.setVisible(true);
+    }
+
+    private static class MyComboBoxUI extends MetalComboBoxUI {
+        public ComboPopup getComboPopup() {
+            return popup;
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/TrayIcon/AddPopupAfterShowTest/AddPopupAfterShowTest.html	Thu Mar 13 14:55:50 2014 -0700
@@ -0,0 +1,45 @@
+<!--
+ Copyright (c) 2013, 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 8007220
+  @summary The popup menu is not added to the tray icon after it was added to tray
+  @author Petr Pchelko
+  @library ../../regtesthelpers
+  @build Sysout
+  @run applet/manual=yesno AddPopupAfterShowTest.html
+  -->
+<head>
+    <title> AddPopupAfterShowTest </title>
+</head>
+<body>
+
+<h1>AddPopupAfterShowTest<br>Bug ID: 8007220</h1>
+
+<p> See the dialog box (usually in upper left corner) for instructions</p>
+
+<APPLET CODE="AddPopupAfterShowTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/TrayIcon/AddPopupAfterShowTest/AddPopupAfterShowTest.java	Thu Mar 13 14:55:50 2014 -0700
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013, 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.Sysout;
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+
+public class AddPopupAfterShowTest extends Applet {
+    @Override
+    public void init() {
+        if (!SystemTray.isSupported()) {
+            Sysout.createDialogWithInstructions(new String[]{
+                    "Press PASS, the System Tray is not supported"});
+            return;
+        }
+
+
+        String[] instructions = {
+                "1) The red circle icon was added to the system tray.",
+                "2) Check that a popup menu is opened when the icon is clicked.",
+                "3) If true the test is passed, otherwise failed."};
+        Sysout.createDialogWithInstructions(instructions);
+    }
+
+    @Override
+    public void start() {
+        setSize(200, 200);
+        show();
+
+        createSystemTrayIcon();
+    }
+
+    private static void createSystemTrayIcon() {
+        final TrayIcon trayIcon = new TrayIcon(createTrayIconImage());
+        trayIcon.setImageAutoSize(true);
+
+        try {
+            // Add tray icon to system tray *before* adding popup menu to demonstrate buggy behaviour
+            SystemTray.getSystemTray().add(trayIcon);
+            trayIcon.setPopupMenu(createTrayIconPopupMenu());
+        } catch (final AWTException awte) {
+            awte.printStackTrace();
+        }
+    }
+
+    private static Image createTrayIconImage() {
+        /**
+         * Create a small image of a red circle to use as the icon for the tray icon
+         */
+        int trayIconImageSize = 32;
+        final BufferedImage trayImage = new BufferedImage(trayIconImageSize, trayIconImageSize, BufferedImage.TYPE_INT_ARGB);
+        final Graphics2D trayImageGraphics = (Graphics2D) trayImage.getGraphics();
+
+        trayImageGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+
+        trayImageGraphics.setColor(new Color(255, 255, 255, 0));
+        trayImageGraphics.fillRect(0, 0, trayImage.getWidth(), trayImage.getHeight());
+
+        trayImageGraphics.setColor(Color.red);
+
+        int trayIconImageInset = 4;
+        trayImageGraphics.fillOval(trayIconImageInset,
+                trayIconImageInset,
+                trayImage.getWidth() - 2 * trayIconImageInset,
+                trayImage.getHeight() - 2 * trayIconImageInset);
+
+        trayImageGraphics.setColor(Color.darkGray);
+
+        trayImageGraphics.drawOval(trayIconImageInset,
+                trayIconImageInset,
+                trayImage.getWidth() - 2 * trayIconImageInset,
+                trayImage.getHeight() - 2 * trayIconImageInset);
+
+        return trayImage;
+    }
+
+    private static PopupMenu createTrayIconPopupMenu() {
+        final PopupMenu trayIconPopupMenu = new PopupMenu();
+        final MenuItem popupMenuItem = new MenuItem("TEST PASSED!");
+        trayIconPopupMenu.add(popupMenuItem);
+        return trayIconPopupMenu;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/TrayIcon/PopupMenuLeakTest/PopupMenuLeakTest.java	Thu Mar 13 14:55:50 2014 -0700
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2013, 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 8007220
+  @summary Reference to the popup leaks after the TrayIcon is removed
+  @author Petr Pchelko
+  @run main/othervm -Xmx50m PopupMenuLeakTest
+ */
+
+import java.awt.*;
+import javax.swing.SwingUtilities;
+import sun.awt.SunToolkit;
+
+import java.awt.image.BufferedImage;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class PopupMenuLeakTest {
+
+    static final AtomicReference<WeakReference<TrayIcon>> iconWeakReference = new AtomicReference<>();
+    static final AtomicReference<WeakReference<PopupMenu>> popupWeakReference = new AtomicReference<>();
+
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(PopupMenuLeakTest::createSystemTrayIcon);
+        sleep();
+        // To make the test automatic we explicitly call addNotify on a popup to create the peer
+        SwingUtilities.invokeAndWait(PopupMenuLeakTest::addNotifyPopup);
+        sleep();
+        SwingUtilities.invokeAndWait(PopupMenuLeakTest::removeIcon);
+        sleep();
+        assertCollected(popupWeakReference.get(), "Failed, reference to popup not collected");
+        assertCollected(iconWeakReference.get(), "Failed, reference to tray icon not collected");
+    }
+
+    private static void addNotifyPopup() {
+        PopupMenu menu = popupWeakReference.get().get();
+        if (menu == null) {
+            throw new RuntimeException("Failed: popup collected too early");
+        }
+        menu.addNotify();
+    }
+
+    private static void removeIcon() {
+        TrayIcon icon = iconWeakReference.get().get();
+        if (icon == null) {
+            throw new RuntimeException("Failed: TrayIcon collected too early");
+        }
+        SystemTray.getSystemTray().remove(icon);
+    }
+
+    private static void assertCollected(WeakReference<?> reference, String message) {
+        java.util.List<byte[]> bytes = new ArrayList<>();
+        for (int i = 0; i < 5; i ++) {
+            try {
+                while (true) {
+                    bytes.add(new byte[1024]);
+                }
+            } catch (OutOfMemoryError err) {
+                bytes = new ArrayList<>();
+            }
+        }
+        if (reference.get() != null) {
+            throw new RuntimeException(message);
+        }
+    }
+
+    private static void createSystemTrayIcon() {
+        final TrayIcon trayIcon = new TrayIcon(createTrayIconImage());
+        trayIcon.setImageAutoSize(true);
+
+        try {
+            // Add tray icon to system tray *before* adding popup menu to demonstrate buggy behaviour
+            trayIcon.setPopupMenu(createTrayIconPopupMenu());
+            SystemTray.getSystemTray().add(trayIcon);
+            iconWeakReference.set(new WeakReference<>(trayIcon));
+            popupWeakReference.set(new WeakReference<>(trayIcon.getPopupMenu()));
+        } catch (final AWTException awte) {
+            awte.printStackTrace();
+        }
+    }
+
+    private static Image createTrayIconImage() {
+        /**
+         * Create a small image of a red circle to use as the icon for the tray icon
+         */
+        int trayIconImageSize = 32;
+        final BufferedImage trayImage = new BufferedImage(trayIconImageSize, trayIconImageSize, BufferedImage.TYPE_INT_ARGB);
+        final Graphics2D trayImageGraphics = (Graphics2D) trayImage.getGraphics();
+
+        trayImageGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+
+        trayImageGraphics.setColor(new Color(255, 255, 255, 0));
+        trayImageGraphics.fillRect(0, 0, trayImage.getWidth(), trayImage.getHeight());
+
+        trayImageGraphics.setColor(Color.red);
+
+        int trayIconImageInset = 4;
+        trayImageGraphics.fillOval(trayIconImageInset,
+                trayIconImageInset,
+                trayImage.getWidth() - 2 * trayIconImageInset,
+                trayImage.getHeight() - 2 * trayIconImageInset);
+
+        trayImageGraphics.setColor(Color.darkGray);
+
+        trayImageGraphics.drawOval(trayIconImageInset,
+                trayIconImageInset,
+                trayImage.getWidth() - 2 * trayIconImageInset,
+                trayImage.getHeight() - 2 * trayIconImageInset);
+
+        return trayImage;
+    }
+
+    private static PopupMenu createTrayIconPopupMenu() {
+        final PopupMenu trayIconPopupMenu = new PopupMenu();
+        final MenuItem popupMenuItem = new MenuItem("TEST!");
+        trayIconPopupMenu.add(popupMenuItem);
+        return trayIconPopupMenu;
+    }
+
+    private static void sleep() {
+        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        try {
+            Thread.sleep(100);
+        } catch (InterruptedException ignored) { }
+    }
+}
--- a/test/java/awt/Window/Grab/GrabTest.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/test/java/awt/Window/Grab/GrabTest.java	Thu Mar 13 14:55:50 2014 -0700
@@ -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
@@ -38,7 +38,10 @@
 public class GrabTest {
     private static Frame f;
     private static Frame f1;
+    private static Frame frame;
     private static Window w;
+    private static Window window1;
+    private static Window window2;
     private static Button b;
 
     private static Robot robot;
@@ -96,6 +99,15 @@
         f.setVisible(true);
         w.setVisible(true);
 
+        frame = new Frame();
+        window1 = new Window(frame);
+        window1.setBounds(0, 0, 100, 100);
+        window1.setBackground(Color.blue);
+
+        window2 = new Window(window1);
+        window2.setBounds(0, 0, 50, 50);
+        window2.setBackground(Color.green);
+
         tk = (sun.awt.SunToolkit)Toolkit.getDefaultToolkit();
 
         try {
@@ -194,6 +206,24 @@
             passed = false;
             System.err.println("Failure: [7] Window disposal didn't cause ungrab");
         }
+        ungrabbed = false;
+
+
+        // 8. Check that mouse click on subwindow does not cause ungrab
+        frame.setVisible(true);
+        window1.setVisible(true);
+        window2.setVisible(true);
+        Util.waitForIdle(robot);
+
+        tk.grab(window1);
+
+        Util.clickOnComp(window2, robot);
+        Util.waitForIdle(robot);
+
+        if (ungrabbed) {
+            passed = false;
+            System.err.println("Failure: [8] Press on the subwindow caused ungrab");
+        }
 
         if (passed) {
             System.out.println("Test passed.");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/dnd/BadSerializaionTest/BadSerializationTest.java	Thu Mar 13 14:55:50 2014 -0700
@@ -0,0 +1,75 @@
+/*
+ * 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 8030050
+ * @summary Validate fields on DnD class deserialization
+ * @author petr.pchelko@oracle.com
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+import java.util.stream.Stream;
+
+public class BadSerializationTest {
+
+    private static final String[] badSerialized = new String[] {
+            "badAction",
+            "noEvents",
+            "nullComponent",
+            "nullDragSource",
+            "nullOrigin"
+    };
+
+    private static final String goodSerialized = "good";
+
+    public static void main(String[] args) throws Exception {
+        String testSrc = System.getProperty("test.src") + File.separator;
+        testReadObject(testSrc + goodSerialized, false);
+        Stream.of(badSerialized).forEach(file -> testReadObject(testSrc + file, true));
+    }
+
+    private static void testReadObject(String filename, boolean expectException) {
+        Exception exceptionCaught = null;
+        try (FileInputStream fileInputStream = new FileInputStream(filename);
+             ObjectInputStream ois = new ObjectInputStream(fileInputStream)) {
+            ois.readObject();
+        } catch (InvalidObjectException e) {
+            exceptionCaught = e;
+        } catch (IOException e) {
+            throw new RuntimeException("FAILED: IOException", e);
+        } catch (ClassNotFoundException e) {
+            throw new RuntimeException("FAILED: ClassNotFoundException", e);
+        }
+        if (exceptionCaught != null && !expectException) {
+            throw new RuntimeException("FAILED: UnexpectedException", exceptionCaught);
+        }
+        if (exceptionCaught == null && expectException) {
+            throw new RuntimeException("FAILED: Invalid object was created with no exception");
+        }
+    }
+}
Binary file test/java/awt/dnd/BadSerializaionTest/badAction has changed
Binary file test/java/awt/dnd/BadSerializaionTest/good has changed
Binary file test/java/awt/dnd/BadSerializaionTest/noEvents has changed
Binary file test/java/awt/dnd/BadSerializaionTest/nullComponent has changed
Binary file test/java/awt/dnd/BadSerializaionTest/nullDragSource has changed
Binary file test/java/awt/dnd/BadSerializaionTest/nullOrigin has changed
--- a/test/java/awt/dnd/Button2DragTest/Button2DragTest.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/test/java/awt/dnd/Button2DragTest/Button2DragTest.java	Thu Mar 13 14:55:50 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -112,6 +112,7 @@
         Util.drag(robot, startPoint, endPoint, InputEvent.BUTTON2_MASK);
 
         Util.waitForIdle(robot);
+        robot.delay(500);
 
         if (dropSuccess) {
             System.err.println("test passed");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/dnd/URLDragTest/URLDragTest.html	Thu Mar 13 14:55:50 2014 -0700
@@ -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 8031964
+  @summary Dragging images from the browser does not work
+  @author Petr Pchelko : area=dnd
+  @library ../../regtesthelpers
+  @build Sysout
+  @run applet/manual=yesno URLDragTest.html
+-->
+<head>
+<title> DnD of URL across JVM </title>
+</head>
+<body>
+
+<h1>URLDragTest<br>Bug ID: 8031964</h1>
+
+<p> This is an AUTOMATIC test, simply wait for completion </p>
+
+<APPLET CODE="URLDragTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/dnd/URLDragTest/URLDragTest.java	Thu Mar 13 14:55:50 2014 -0700
@@ -0,0 +1,88 @@
+/*
+ * 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 8031964
+  @summary Dragging images from the browser does not work
+  @author Petr Pchelko : area=dnd
+  @library ../../regtesthelpers
+  @build Sysout
+  @run applet/manual=yesno URLDragTest.html
+*/
+
+import test.java.awt.regtesthelpers.Sysout;
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.DropTargetAdapter;
+import java.awt.dnd.DropTargetDragEvent;
+import java.awt.dnd.DropTargetDropEvent;
+
+public class URLDragTest extends Applet {
+
+
+    @Override
+    public void init() {
+        setBackground(Color.red);
+        setDropTarget(new DropTarget(this,
+                DnDConstants.ACTION_COPY,
+                new DropTargetAdapter() {
+                    @Override
+                    public void dragEnter(DropTargetDragEvent dtde) {
+                        dtde.acceptDrag(DnDConstants.ACTION_COPY);
+                    }
+
+                    @Override
+                    public void dragOver(DropTargetDragEvent dtde) {
+                        dtde.acceptDrag(DnDConstants.ACTION_COPY);
+                    }
+
+                    @Override
+                    public void drop(DropTargetDropEvent dtde) {
+                        dtde.acceptDrop(DnDConstants.ACTION_COPY);
+                        dtde.getCurrentDataFlavorsAsList()
+                                .stream()
+                                .map(DataFlavor::toString)
+                                .forEach(Sysout::println);
+                    }
+                }));
+
+        String[] instructions = {
+                "1) Open the browser.",
+                "2) Drag any image from the browser page to the red square",
+                "3) When the image is dropped you should se the list of available DataFlavors",
+                "4) If you see application/x-java-url and text/uri-list flavors - test PASSED",
+                "5) Otherwise the test is FAILED"};
+        Sysout.createDialogWithInstructions(instructions);
+    }
+
+    @Override
+    public void start() {
+        setSize(200, 200);
+        setVisible(true);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/invoke/lambda/LambdaReceiver.java	Thu Mar 13 14:55:50 2014 -0700
@@ -0,0 +1,70 @@
+/*
+ * 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 8035776
+ * @summary Consistent Lambda construction
+ */
+
+import java.lang.invoke.CallSite;
+import java.lang.invoke.LambdaMetafactory;
+import java.lang.invoke.LambdaConversionException;
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import java.util.ArrayList;
+import java.util.List;
+
+import LambdaReceiver_anotherpkg.LambdaReceiver_A;
+
+public class LambdaReceiver extends LambdaReceiver_A {
+
+    interface IA {
+        int m(LambdaReceiver_A x);
+    }
+
+    static MethodHandles.Lookup l;
+    static MethodHandle h;
+    private static MethodType mt(Class<?> k) { return MethodType.methodType(k); }
+    private static MethodType mt(Class<?> k, Class<?> k2) { return MethodType.methodType(k, k2); }
+    private static void mf(List<String> errs, MethodType mts, MethodType mtf, boolean shouldWork) {
+    }
+
+    public static void main(String[] args) throws Throwable {
+        l = MethodHandles.lookup();
+        h = l.findVirtual(LambdaReceiver_A.class, "f", mt(int.class));
+        MethodType X = mt(int.class, LambdaReceiver.class);
+        MethodType A = mt(int.class, LambdaReceiver_A.class);
+        MethodType mti = mt(IA.class);
+        CallSite cs = LambdaMetafactory.metafactory(l, "m", mti,A,h,X);
+        IA p = (IA)cs.dynamicInvoker().invoke();
+        LambdaReceiver_A lra = new LambdaReceiver_A();
+        try {
+            p.m(lra);
+        } catch (ClassCastException cce) {
+            return;
+        }
+        throw new AssertionError("CCE expected");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/invoke/lambda/LambdaReceiverBridge.java	Thu Mar 13 14:55:50 2014 -0700
@@ -0,0 +1,71 @@
+/*
+ * 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 8035776
+ * @summary Consistent Lambda construction
+ */
+
+import java.lang.invoke.CallSite;
+import java.lang.invoke.LambdaMetafactory;
+import java.lang.invoke.LambdaConversionException;
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import java.util.ArrayList;
+import java.util.List;
+
+import LambdaReceiver_anotherpkg.LambdaReceiver_A;
+
+public class LambdaReceiverBridge extends LambdaReceiver_A {
+
+    interface IA {
+        int m(LambdaReceiver_A x);
+    }
+
+    static MethodHandles.Lookup l;
+    static MethodHandle h;
+    private static MethodType mt(Class<?> k) { return MethodType.methodType(k); }
+    private static MethodType mt(Class<?> k, Class<?> k2) { return MethodType.methodType(k, k2); }
+    private static void mf(List<String> errs, MethodType mts, MethodType mtf, boolean shouldWork) {
+    }
+
+    public static void main(String[] args) throws Throwable {
+        l = MethodHandles.lookup();
+        h = l.findVirtual(LambdaReceiver_A.class, "f", mt(int.class));
+        MethodType X = mt(int.class, LambdaReceiverBridge.class);
+        MethodType A = mt(int.class, LambdaReceiver_A.class);
+        MethodType mti = mt(IA.class);
+        CallSite cs = LambdaMetafactory.altMetafactory(l, "m", mti,X,h,X,
+                                          LambdaMetafactory.FLAG_BRIDGES, 1, A);
+        IA p = (IA)cs.dynamicInvoker().invoke();
+        LambdaReceiver_A lra = new LambdaReceiver_A();
+        try {
+            p.m(lra);
+        } catch (ClassCastException cce) {
+            return;
+        }
+        throw new AssertionError("CCE expected");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/invoke/lambda/LambdaReceiver_anotherpkg/LambdaReceiver_A.java	Thu Mar 13 14:55:50 2014 -0700
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+package LambdaReceiver_anotherpkg;
+
+public class LambdaReceiver_A {
+  protected final int f() { return 2; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/invoke/lambda/LambdaReturn.java	Thu Mar 13 14:55:50 2014 -0700
@@ -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.
+ */
+
+/*
+ * @test
+ * @bug 8035776
+ * @summary Consistent Lambda construction
+ */
+
+import java.lang.invoke.LambdaMetafactory;
+import java.lang.invoke.LambdaConversionException;
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import java.util.ArrayList;
+import java.util.List;
+
+public class LambdaReturn {
+
+    interface I {
+        void m();
+    }
+
+    static void hereV() {}
+    static String hereS() { return "hi"; }
+    static MethodHandles.Lookup l;
+    private static MethodType mt(Class<?> k) { return MethodType.methodType(k); }
+    private static MethodType mt(Class<?> k, Class<?> k2) { return MethodType.methodType(k, k2); }
+    private static void amf(List<String> errs, MethodHandle h, MethodType mts, MethodType mtf, MethodType mtb, boolean shouldWork) {
+        MethodType mti = mt(I.class);
+        try {
+            LambdaMetafactory.altMetafactory(l, "m", mti, mts,h,mtf,
+                                          LambdaMetafactory.FLAG_BRIDGES, 1, mtb);
+        } catch(LambdaConversionException e) {
+            if (shouldWork)  errs.add("Error: Should work h=" + h + " s=" + mts + " -- f=" + mtf + " / b=" + mtb + " got: " + e);
+            return;
+        }
+        if (!shouldWork)  errs.add("Error: Should fail h=" + h + " s=" + mts + " -- f=" + mtf + " / b=" + mtb);
+    }
+
+    public static void main(String[] args) throws Throwable {
+        l = MethodHandles.lookup();
+        MethodHandle hV = l.findStatic(LambdaReturn.class, "hereV", mt(void.class));
+        MethodHandle hS = l.findStatic(LambdaReturn.class, "hereS", mt(String.class));
+        List<String> errs = new ArrayList<>();
+        MethodType V = mt(void.class);
+        MethodType S = mt(String.class);
+        MethodType O = mt(Object.class);
+        MethodType I = mt(int.class);
+        amf(errs, hS, S, S, O, true);
+        amf(errs, hS, S, S, V, false);
+        amf(errs, hS, S, S, I, false);
+        amf(errs, hS, O, S, S, true);
+        amf(errs, hS, V, S, S, false);
+        amf(errs, hS, I, S, S, false);
+        amf(errs, hS, O, O, S, false);
+        amf(errs, hS, S, O, O, false);
+        amf(errs, hV, V, V, O, false);
+        amf(errs, hV, V, V, I, false);
+        amf(errs, hV, V, V, S, false);
+        amf(errs, hV, O, V, V, false);
+        amf(errs, hV, I, V, V, false);
+        amf(errs, hV, S, V, V, false);
+
+        if (errs.size() > 0) {
+            for (String err : errs) {
+                System.err.println(err);
+            }
+            throw new AssertionError("Errors: " + errs.size());
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/invoke/lambda/MetafactoryArityTest.java	Thu Mar 13 14:55:50 2014 -0700
@@ -0,0 +1,169 @@
+/*
+ * 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 8035776
+ * @summary metafactory should fail if arities are mismatched
+ */
+import java.lang.invoke.*;
+import java.util.Arrays;
+import static java.lang.invoke.MethodType.methodType;
+
+public class MetafactoryArityTest {
+
+    public interface I {}
+    public static class C { public static String m(int arg) { return ""; } }
+
+    static final MethodHandles.Lookup lookup = MethodHandles.lookup();
+    static final Class<?>[] capInt = { int.class };
+    static final MethodHandle C_m;
+    static {
+        try { C_m = lookup.findStatic(C.class, "m", methodType(String.class, int.class)); }
+        catch (NoSuchMethodException | IllegalAccessException e) { throw new RuntimeException(e); }
+    }
+
+    public static void main(String... args) {
+        MethodType unary = methodType(String.class, int.class);
+        MethodType nullary = methodType(String.class);
+        MethodType binary = methodType(String.class, int.class, int.class);
+        MethodType unaryCS = methodType(CharSequence.class, int.class);
+        MethodType nullaryCS = methodType(CharSequence.class);
+        MethodType binaryCS = methodType(CharSequence.class, int.class, int.class);
+        MethodType unaryObj = methodType(Object.class, int.class);
+        MethodType nullaryObj = methodType(Object.class);
+        MethodType binaryObj = methodType(Object.class, int.class, int.class);
+
+        test(true, C_m, unary, unary);
+        test(false, C_m, unary, nullary);
+        test(false, C_m, nullary, unary);
+        test(false, C_m, unary, binary);
+        test(false, C_m, binary, unary);
+
+        testBridge(true, C_m, unary, unary, unaryCS);
+        testBridge(false, C_m, unary, unary, nullaryCS);
+        testBridge(false, C_m, unary, unary, binaryCS);
+
+        testBridge(true, C_m, unary, unary, unaryCS, unaryObj);
+        testBridge(false, C_m, unary, unary, unaryCS, nullaryObj);
+        testBridge(false, C_m, unary, unary, unaryCS, binaryObj);
+
+        testCapture(true, C_m, capInt, nullary, nullary);
+        testCapture(false, C_m, capInt, binary, binary);
+        testCapture(false, C_m, capInt, nullary, unary);
+        testCapture(false, C_m, capInt, nullary, binary);
+        testCapture(false, C_m, capInt, unary, nullary);
+        testCapture(false, C_m, capInt, unary, binary);
+
+        testCaptureBridge(true, C_m, capInt, nullary, nullary, nullaryCS);
+        testCaptureBridge(false, C_m, capInt, unary, unary, unaryCS);
+        testCaptureBridge(false, C_m, capInt, nullary, nullary, unaryCS);
+        testCaptureBridge(false, C_m, capInt, nullary, nullary, binaryCS);
+
+        testCaptureBridge(true, C_m, capInt, nullary, nullary, nullaryCS, nullaryObj);
+        testCaptureBridge(false, C_m, capInt, unary, unary, unaryCS, unaryObj);
+        testCaptureBridge(false, C_m, capInt, nullary, nullary, nullaryCS, unaryObj);
+        testCaptureBridge(false, C_m, capInt, nullary, nullary, nullaryCS, binaryObj);
+    }
+
+    static void test(boolean correct, MethodHandle mh, MethodType instMT, MethodType samMT) {
+        tryMetafactory(correct, mh, new Class<?>[]{}, instMT, samMT);
+        tryAltMetafactory(correct, mh, new Class<?>[]{}, instMT, samMT);
+    }
+
+    static void testBridge(boolean correct, MethodHandle mh, MethodType instMT, MethodType samMT, MethodType... bridgeMTs) {
+        tryAltMetafactory(correct, mh, new Class<?>[]{}, instMT, samMT, bridgeMTs);
+    }
+
+    static void testCapture(boolean correct, MethodHandle mh, Class<?>[] captured, MethodType instMT, MethodType samMT) {
+        tryMetafactory(correct, mh, captured, instMT, samMT);
+        tryAltMetafactory(correct, mh, captured, instMT, samMT);
+    }
+
+    static void testCaptureBridge(boolean correct, MethodHandle mh, Class<?>[] captured,
+                                  MethodType instMT, MethodType samMT, MethodType... bridgeMTs) {
+        tryAltMetafactory(correct, mh, captured, instMT, samMT, bridgeMTs);
+    }
+
+    static void tryMetafactory(boolean correct, MethodHandle mh, Class<?>[] captured,
+                               MethodType instMT, MethodType samMT) {
+        try {
+            LambdaMetafactory.metafactory(lookup, "run", methodType(I.class, captured),
+                                          samMT, mh, instMT);
+            if (!correct) {
+                throw new AssertionError("Uncaught linkage error:" +
+                                         " impl=" + mh +
+                                         ", captured=" + Arrays.toString(captured) +
+                                         ", inst=" + instMT +
+                                         ", sam=" + samMT);
+            }
+        }
+        catch (LambdaConversionException e) {
+            if (correct) {
+                throw new AssertionError("Unexpected linkage error:" +
+                                         " e=" + e +
+                                         ", impl=" + mh +
+                                         ", captured=" + Arrays.toString(captured) +
+                                         ", inst=" + instMT +
+                                         ", sam=" + samMT);
+            }
+        }
+    }
+
+    static void tryAltMetafactory(boolean correct, MethodHandle mh, Class<?>[] captured,
+                                  MethodType instMT, MethodType samMT, MethodType... bridgeMTs) {
+        boolean bridge = bridgeMTs.length > 0;
+        Object[] args = new Object[bridge ? 5+bridgeMTs.length : 4];
+        args[0] = samMT;
+        args[1] = mh;
+        args[2] = instMT;
+        args[3] = bridge ? LambdaMetafactory.FLAG_BRIDGES : 0;
+        if (bridge) {
+            args[4] = bridgeMTs.length;
+            for (int i = 0; i < bridgeMTs.length; i++) args[5+i] = bridgeMTs[i];
+        }
+        try {
+            LambdaMetafactory.altMetafactory(lookup, "run", methodType(I.class, captured), args);
+            if (!correct) {
+                throw new AssertionError("Uncaught linkage error:" +
+                                         " impl=" + mh +
+                                         ", captured=" + Arrays.toString(captured) +
+                                         ", inst=" + instMT +
+                                         ", sam=" + samMT +
+                                         ", bridges=" + Arrays.toString(bridgeMTs));
+            }
+        }
+        catch (LambdaConversionException e) {
+            if (correct) {
+                throw new AssertionError("Unexpected linkage error:" +
+                                         " e=" + e +
+                                         ", impl=" + mh +
+                                         ", captured=" + Arrays.toString(captured) +
+                                         ", inst=" + instMT +
+                                         ", sam=" + samMT +
+                                         ", bridges=" + Arrays.toString(bridgeMTs));
+            }
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/invoke/lambda/MetafactoryParameterCastTest.java	Thu Mar 13 14:55:50 2014 -0700
@@ -0,0 +1,211 @@
+/*
+ * 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 8035776
+ * @summary Ensure that invocation parameters are always cast to the instantiatedMethodType
+ */
+import java.lang.invoke.*;
+import java.util.Arrays;
+import static java.lang.invoke.MethodType.methodType;
+
+public class MetafactoryParameterCastTest {
+
+    static final MethodHandles.Lookup lookup = MethodHandles.lookup();
+
+    public static class A {
+    }
+
+    public static class B extends A {
+        void instance0() {}
+        void instance1(B arg) {}
+        static void static1(B arg) {}
+        static void static2(B arg1, B arg2) {}
+    }
+
+    public static class C extends B {}
+    public static class NotC extends B {}
+
+    public interface ASink { void take(A arg); }
+    public interface BSink { void take(B arg); }
+
+    public static void main(String... args) throws Throwable {
+        new MetafactoryParameterCastTest().test();
+    }
+
+    void test() throws Throwable {
+        MethodType takeA = methodType(void.class, A.class);
+        MethodType takeB = methodType(void.class, B.class);
+        MethodType takeC = methodType(void.class, C.class);
+
+        Class<?>[] noCapture = {};
+        Class<?>[] captureB = { B.class };
+
+        MethodHandle[] oneBParam = { lookup.findVirtual(B.class, "instance0", methodType(void.class)),
+                                     lookup.findStatic(B.class, "static1", methodType(void.class, B.class)) };
+        MethodHandle[] twoBParams = { lookup.findVirtual(B.class, "instance1", methodType(void.class, B.class)),
+                                      lookup.findStatic(B.class, "static2", methodType(void.class, B.class, B.class)) };
+
+        for (MethodHandle mh : oneBParam) {
+            // sam
+            tryASink(invokeMetafactory(mh, ASink.class, "take", noCapture, takeC, takeA));
+            tryBSink(invokeMetafactory(mh, BSink.class, "take", noCapture, takeC, takeB));
+            tryASink(invokeAltMetafactory(mh, ASink.class, "take", noCapture, takeC, takeA));
+            tryBSink(invokeAltMetafactory(mh, BSink.class, "take", noCapture, takeC, takeB));
+
+            // bridge
+            tryASink(invokeAltMetafactory(mh, ASink.class, "take", noCapture, takeC, takeC, takeA));
+            tryBSink(invokeAltMetafactory(mh, BSink.class, "take", noCapture, takeC, takeC, takeB));
+        }
+
+        for (MethodHandle mh : twoBParams) {
+            // sam
+            tryCapASink(invokeMetafactory(mh, ASink.class, "take", captureB, takeC, takeA));
+            tryCapBSink(invokeMetafactory(mh, BSink.class, "take", captureB, takeC, takeB));
+            tryCapASink(invokeAltMetafactory(mh, ASink.class, "take", captureB, takeC, takeA));
+            tryCapBSink(invokeAltMetafactory(mh, BSink.class, "take", captureB, takeC, takeB));
+
+            // bridge
+            tryCapASink(invokeAltMetafactory(mh, ASink.class, "take", captureB, takeC, takeC, takeA));
+            tryCapBSink(invokeAltMetafactory(mh, BSink.class, "take", captureB, takeC, takeC, takeB));
+        }
+    }
+
+    void tryASink(CallSite cs) throws Throwable {
+        ASink sink = (ASink) cs.dynamicInvoker().invoke();
+        tryASink(sink);
+    }
+
+    void tryCapASink(CallSite cs) throws Throwable {
+        ASink sink = (ASink) cs.dynamicInvoker().invoke(new B());
+        tryASink(sink);
+    }
+
+    void tryBSink(CallSite cs) throws Throwable {
+        BSink sink = (BSink) cs.dynamicInvoker().invoke();
+        tryBSink(sink);
+    }
+
+    void tryCapBSink(CallSite cs) throws Throwable {
+        BSink sink = (BSink) cs.dynamicInvoker().invoke(new B());
+        tryBSink(sink);
+    }
+
+    void tryASink(ASink sink) {
+        try { sink.take(new C()); }
+        catch (ClassCastException e) {
+            throw new AssertionError("Unexpected cast failure: " + e + " " + lastMFParams());
+        }
+
+        try {
+            sink.take(new B());
+            throw new AssertionError("Missing cast from A to C: " + lastMFParams());
+        }
+        catch (ClassCastException e) { /* expected */ }
+
+        try {
+            sink.take(new NotC());
+            throw new AssertionError("Missing cast from A to C: " + lastMFParams());
+        }
+        catch (ClassCastException e) { /* expected */ }
+    }
+
+    void tryBSink(BSink sink) {
+        try { sink.take(new C()); }
+        catch (ClassCastException e) {
+            throw new AssertionError("Unexpected cast failure: " + e + " " + lastMFParams());
+        }
+
+        try {
+            sink.take(new B());
+            throw new AssertionError("Missing cast from B to C: " + lastMFParams());
+        }
+        catch (ClassCastException e) { /* expected */ }
+
+        try {
+            sink.take(new NotC());
+            throw new AssertionError("Missing cast from B to C: " + lastMFParams());
+        }
+        catch (ClassCastException e) { /* expected */ }
+    }
+
+    MethodHandle lastMH;
+    Class<?>[] lastCaptured;
+    MethodType lastInstMT;
+    MethodType lastSamMT;
+    MethodType[] lastBridgeMTs;
+
+    String lastMFParams() {
+        return "mh=" + lastMH +
+               ", captured=" + Arrays.toString(lastCaptured) +
+               ", instMT=" + lastInstMT +
+               ", samMT=" + lastSamMT +
+               ", bridgeMTs=" + Arrays.toString(lastBridgeMTs);
+    }
+
+    CallSite invokeMetafactory(MethodHandle mh, Class<?> sam, String methodName,
+                               Class<?>[] captured, MethodType instMT, MethodType samMT) {
+        lastMH = mh;
+        lastCaptured = captured;
+        lastInstMT = instMT;
+        lastSamMT = samMT;
+        lastBridgeMTs = new MethodType[]{};
+        try {
+            return LambdaMetafactory.metafactory(lookup, methodName, methodType(sam, captured),
+                                                 samMT, mh, instMT);
+        }
+        catch (LambdaConversionException e) {
+            // unexpected linkage error
+            throw new RuntimeException(e);
+        }
+    }
+
+    CallSite invokeAltMetafactory(MethodHandle mh, Class<?> sam, String methodName,
+                                  Class<?>[] captured, MethodType instMT,
+                                  MethodType samMT, MethodType... bridgeMTs) {
+        lastMH = mh;
+        lastCaptured = captured;
+        lastInstMT = instMT;
+        lastSamMT = samMT;
+        lastBridgeMTs = bridgeMTs;
+        try {
+            boolean bridge = bridgeMTs.length > 0;
+            Object[] args = new Object[bridge ? 5+bridgeMTs.length : 4];
+            args[0] = samMT;
+            args[1] = mh;
+            args[2] = instMT;
+            args[3] = bridge ? LambdaMetafactory.FLAG_BRIDGES : 0;
+            if (bridge) {
+                args[4] = bridgeMTs.length;
+                for (int i = 0; i < bridgeMTs.length; i++) args[5+i] = bridgeMTs[i];
+            }
+            return LambdaMetafactory.altMetafactory(lookup, methodName, methodType(sam, captured), args);
+        }
+        catch (LambdaConversionException e) {
+            // unexpected linkage error
+            throw new RuntimeException(e);
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/invoke/lambda/MetafactorySamReturnTest.java	Thu Mar 13 14:55:50 2014 -0700
@@ -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.
+ */
+
+/*
+ * @test
+ * @bug 8035776
+ * @summary metafactory should fail if impl return does not match sam/bridge returns
+ */
+import java.lang.invoke.*;
+import java.util.Arrays;
+import static java.lang.invoke.MethodType.methodType;
+
+public class MetafactorySamReturnTest {
+
+    static final MethodHandles.Lookup lookup = MethodHandles.lookup();
+
+    public interface I {}
+
+    public static class C {
+        public static void m_void(String arg) {}
+        public static boolean m_boolean(String arg) { return true; }
+        public static char m_char(String arg) { return 'x'; }
+        public static byte m_byte(String arg) { return 12; }
+        public static short m_short(String arg) { return 12; }
+        public static int m_int(String arg) { return 12; }
+        public static long m_long(String arg) { return 12; }
+        public static float m_float(String arg) { return 12; }
+        public static double m_double(String arg) { return 12; }
+        public static String m_String(String arg) { return ""; }
+        public static Integer m_Integer(String arg) { return 23; }
+        public static Object m_Object(String arg) { return new Object(); }
+
+        public static MethodHandle getMH(Class<?> c) {
+            try {
+                return lookup.findStatic(C.class, "m_" + c.getSimpleName(), methodType(c, String.class));
+            }
+            catch (NoSuchMethodException | IllegalAccessException e) {
+                throw new RuntimeException(e);
+            }
+        }
+    }
+
+    public static void main(String... args) {
+        Class<?>[] t = { void.class, boolean.class, char.class,
+                         byte.class, short.class, int.class, long.class, float.class, double.class,
+                         String.class, Integer.class, Object.class };
+
+        for (int i = 0; i < t.length; i++) {
+            MethodHandle mh = C.getMH(t[i]);
+            for (int j = 0; j < t.length; j++) {
+                // TEMPORARY EXCEPTIONS
+                if (t[j] == void.class) continue;
+                if (t[i].isPrimitive() && t[j] == Object.class) continue;
+                if (t[i] == char.class && (t[j] == int.class || t[j] == long.class || t[j] == float.class || t[j] == double.class)) continue;
+                if (t[i] == byte.class && (t[j] == short.class || t[j] == int.class || t[j] == long.class || t[j] == float.class || t[j] == double.class)) continue;
+                if (t[i] == short.class && (t[j] == int.class || t[j] == long.class || t[j] == float.class || t[j] == double.class)) continue;
+                if (t[i] == int.class && (t[j] == long.class || t[j] == float.class || t[j] == double.class)) continue;
+                if (t[i] == long.class && (t[j] == float.class || t[j] == double.class)) continue;
+                if (t[i] == float.class && t[j] == double.class) continue;
+                if (t[i] == int.class && t[j] == Integer.class) continue;
+                if (t[i] == Integer.class && (t[j] == int.class || t[j] == long.class || t[j] == float.class || t[j] == double.class)) continue;
+                // END TEMPORARY EXCEPTIONS
+                boolean correct = (t[i].isPrimitive() || t[j].isPrimitive())
+                                  ? t[i] == t[j]
+                                  : t[j].isAssignableFrom(t[i]);
+                MethodType mti = methodType(t[i], String.class);
+                MethodType mtiCS = methodType(t[i], CharSequence.class);
+                MethodType mtj = methodType(t[j], String.class);
+                MethodType mtjObj = methodType(t[j], Object.class);
+                test(correct, mh, mti, mtj);
+                testBridge(correct, mh, mti, mti, mtjObj);
+                testBridge(correct, mh, mti, mti, mtiCS, mtjObj);
+            }
+        }
+    }
+
+    static void test(boolean correct, MethodHandle mh, MethodType instMT, MethodType samMT) {
+        tryMetafactory(correct, mh, new Class<?>[]{}, instMT, samMT);
+        tryAltMetafactory(correct, mh, new Class<?>[]{}, instMT, samMT);
+    }
+
+    static void testBridge(boolean correct, MethodHandle mh, MethodType instMT, MethodType samMT, MethodType... bridgeMTs) {
+        tryAltMetafactory(correct, mh, new Class<?>[]{}, instMT, samMT, bridgeMTs);
+    }
+
+    static void tryMetafactory(boolean correct, MethodHandle mh, Class<?>[] captured,
+                               MethodType instMT, MethodType samMT) {
+        try {
+            LambdaMetafactory.metafactory(lookup, "run", methodType(I.class, captured),
+                                          samMT, mh, instMT);
+            if (!correct) {
+                throw new AssertionError("Uncaught linkage error:" +
+                                         " impl=" + mh +
+                                         ", captured=" + Arrays.toString(captured) +
+                                         ", inst=" + instMT +
+                                         ", sam=" + samMT);
+            }
+        }
+        catch (LambdaConversionException e) {
+            if (correct) {
+                throw new AssertionError("Unexpected linkage error:" +
+                                         " e=" + e +
+                                         ", impl=" + mh +
+                                         ", captured=" + Arrays.toString(captured) +
+                                         ", inst=" + instMT +
+                                         ", sam=" + samMT);
+            }
+        }
+    }
+
+    static void tryAltMetafactory(boolean correct, MethodHandle mh, Class<?>[] captured,
+                                  MethodType instMT, MethodType samMT, MethodType... bridgeMTs) {
+        boolean bridge = bridgeMTs.length > 0;
+        Object[] args = new Object[bridge ? 5+bridgeMTs.length : 4];
+        args[0] = samMT;
+        args[1] = mh;
+        args[2] = instMT;
+        args[3] = bridge ? LambdaMetafactory.FLAG_BRIDGES : 0;
+        if (bridge) {
+            args[4] = bridgeMTs.length;
+            for (int i = 0; i < bridgeMTs.length; i++) args[5+i] = bridgeMTs[i];
+        }
+        try {
+            LambdaMetafactory.altMetafactory(lookup, "run", methodType(I.class, captured), args);
+            if (!correct) {
+                throw new AssertionError("Uncaught linkage error:" +
+                                         " impl=" + mh +
+                                         ", captured=" + Arrays.toString(captured) +
+                                         ", inst=" + instMT +
+                                         ", sam=" + samMT +
+                                         ", bridges=" + Arrays.toString(bridgeMTs));
+            }
+        }
+        catch (LambdaConversionException e) {
+            if (correct) {
+                throw new AssertionError("Unexpected linkage error:" +
+                                         " e=" + e +
+                                         ", impl=" + mh +
+                                         ", captured=" + Arrays.toString(captured) +
+                                         ", inst=" + instMT +
+                                         ", sam=" + samMT +
+                                         ", bridges=" + Arrays.toString(bridgeMTs));
+            }
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/net/ServerSocket/AnotherSelectFdsLimit.java	Thu Mar 13 14:55:50 2014 -0700
@@ -0,0 +1,78 @@
+/*
+ * 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 8035897
+ * @summary FD_SETSIZE should be set on macosx
+ * @run main/othervm AnotherSelectFdsLimit 1023
+ * @run main/othervm AnotherSelectFdsLimit 1024
+ * @run main/othervm AnotherSelectFdsLimit 1025
+ * @run main/othervm AnotherSelectFdsLimit 1600
+ */
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.SocketTimeoutException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class AnotherSelectFdsLimit {
+    static final int DEFAULT_FDS_TO_USE = 1600;
+
+    public static void main(String [] args) throws Exception {
+        if (!System.getProperty("os.name").contains("OS X")) {
+            System.out.println("Test only run on MAC. Exiting.");
+            return;
+        }
+
+        int fdsToUse = DEFAULT_FDS_TO_USE;
+        if (args.length == 1)
+            fdsToUse = Integer.parseInt(args[0]);
+
+        System.out.println("Using " + fdsToUse + " fds.");
+
+        List<Thread> threads = new ArrayList<>();
+        for (int i=0; i<fdsToUse; i++)
+            threads.add(new WorkerThread());
+
+        for (Thread t : threads)
+            t.start();
+
+        for (Thread t : threads)
+            t.join();
+    }
+
+    static class WorkerThread extends Thread {
+        public void run() {
+            try (ServerSocket ss = new ServerSocket(0)) {
+                ss.setSoTimeout(2000);
+                ss.accept();
+            } catch (SocketTimeoutException x) {
+                // expected
+            } catch (IOException x) {
+                throw new java.io.UncheckedIOException(x);
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JMenuItem/8031573/bug8031573.html	Thu Mar 13 14:55:50 2014 -0700
@@ -0,0 +1,40 @@
+<!--
+ 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>
+
+Verify that high resolution system icons are used JCheckBoxMenuItem 
+on HiDPI displays.
+
+If the display does not support HiDPI mode press PASS.
+
+1. Run the test on HiDPI Display.
+2. Press the Menu in the applet
+3. Check that the icon on the JCheckBoxMenuItem is smooth
+If so, press PASS, else press FAIL.
+
+<applet  code="bug8031573.class" width=250 height=250></applet>
+
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JMenuItem/8031573/bug8031573.java	Thu Mar 13 14:55:50 2014 -0700
@@ -0,0 +1,60 @@
+/*
+ * 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.FlowLayout;
+import javax.swing.JApplet;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.SwingUtilities;
+
+/* @test
+ * @bug 8031573
+ * @summary [macosx] Checkmarks of JCheckBoxMenuItems aren't rendered
+ *           in high resolution on Retina
+ * @author Alexander Scherbatiy
+ * @run applet/manual=yesno bug8031573.html
+ */
+public class bug8031573 extends JApplet {
+
+    @Override
+    public void init() {
+        try {
+            SwingUtilities.invokeAndWait(new Runnable() {
+
+                @Override
+                public void run() {
+                    JMenuBar bar = new JMenuBar();
+                    JMenu menu = new JMenu("Menu");
+                    JCheckBoxMenuItem checkBoxMenuItem
+                            = new JCheckBoxMenuItem("JCheckBoxMenuItem");
+                    checkBoxMenuItem.setSelected(true);
+                    menu.add(checkBoxMenuItem);
+                    bar.add(menu);
+                    setJMenuBar(bar);
+                }
+            });
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JPopupMenu/7154841/bug7154841.java	Thu Mar 13 14:55:50 2014 -0700
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013, 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 7154841
+  @summary JPopupMenu is overlapped by a Dock on Mac OS X
+  @author Petr Pchelko
+ */
+
+import sun.awt.OSInfo;
+import sun.awt.SunToolkit;
+
+import java.awt.*;
+import javax.swing.*;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseMotionAdapter;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class bug7154841 {
+
+    private static final int STEP = 10;
+
+    private static volatile boolean passed = false;
+    private static JFrame frame;
+    private static JPopupMenu popupMenu;
+    private static AtomicReference<Rectangle> screenBounds = new AtomicReference<>();
+
+    private static void initAndShowUI() {
+        popupMenu = new JPopupMenu();
+        for (int i = 0; i < 100; i++) {
+            JRadioButtonMenuItem item = new JRadioButtonMenuItem(" Test " + i);
+            item.addMouseMotionListener(new MouseMotionAdapter() {
+                @Override
+                public void mouseMoved(MouseEvent e) {
+                    passed = true;
+                }
+            });
+            popupMenu.add(item);
+        }
+
+        frame = new JFrame();
+        screenBounds.set(getScreenBounds());
+        frame.setBounds(screenBounds.get());
+        frame.setVisible(true);
+    }
+
+    public static void main(String[] args) throws Exception {
+        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
+            return; // Test only for Mac OS X
+        }
+
+        try {
+            Robot r = new Robot();
+            r.setAutoDelay(100);
+            r.setAutoWaitForIdle(true);
+            r.mouseMove(0, 0);
+
+            SwingUtilities.invokeAndWait(bug7154841::initAndShowUI);
+
+            sleep();
+
+            SwingUtilities.invokeAndWait(() -> {
+                popupMenu.show(frame, frame.getX() + frame.getWidth() / 2, frame.getY() + frame.getHeight() / 2);
+            });
+
+            sleep();
+
+            int y = (int)screenBounds.get().getY() + (int)screenBounds.get().getHeight() - 10;
+            int center = (int)(screenBounds.get().getX() + screenBounds.get().getWidth() / 2);
+            for (int x = center - 10 * STEP; x < center + 10 * STEP; x += STEP) {
+                r.mouseMove(x, y);
+            }
+
+            if (!passed) {
+                throw new RuntimeException("Failed: no mouse events on the popup menu");
+            }
+        } finally {
+            SwingUtilities.invokeLater(() -> {
+                if (frame != null) {
+                    frame.dispose();
+                }
+            });
+        }
+    }
+
+    public static Rectangle getScreenBounds() {
+        return GraphicsEnvironment
+                .getLocalGraphicsEnvironment()
+                .getDefaultScreenDevice()
+                .getDefaultConfiguration()
+                .getBounds();
+    }
+
+    private static void sleep() {
+        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        try {
+            Thread.sleep(200);
+        } catch (InterruptedException ignored) { }
+    }
+}
--- a/test/javax/xml/jaxp/transform/8004476/TestBase.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/test/javax/xml/jaxp/transform/8004476/TestBase.java	Thu Mar 13 14:55:50 2014 -0700
@@ -1,7 +1,26 @@
 /*
  * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ * 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.security.Policy;
 
 /**
--- a/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java	Wed Feb 26 19:26:42 2014 +0100
+++ b/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java	Thu Mar 13 14:55:50 2014 -0700
@@ -32,6 +32,7 @@
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
+import jdk.testlibrary.ProcessTools;
 
 /**
  * @test
@@ -43,11 +44,9 @@
  *          both agent properties and jvmstat buffer.
  * @build jdk.testlibrary.ProcessTools
  * @build TestManager TestApplication
- * @run main/othervm/timeout=300 LocalManagementTest
+ * @run main/othervm/timeout=300 -XX:+UsePerfData LocalManagementTest
  */
 
-import jdk.testlibrary.ProcessTools;
-
 public class LocalManagementTest {
     private static final  String TEST_CLASSPATH = System.getProperty("test.class.path");
     private static final  String TEST_JDK = System.getProperty("test.jdk");
@@ -240,4 +239,4 @@
             }
         }
     }
-}
\ No newline at end of file
+}