changeset 6461:09d0888ef9b6

Merge
author vinnie
date Thu, 11 Jul 2013 05:38:23 -0700
parents e2c7640fcacb 311956930113
children 886d46986b72
files
diffstat 28 files changed, 552 insertions(+), 250 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Thu Jun 27 09:34:52 2013 -0700
+++ b/.hgtags	Thu Jul 11 05:38:23 2013 -0700
@@ -323,3 +323,5 @@
 2043900095890e676f5ed0f959f470e2138c2a9a jdk7u40-b28
 d3186a0676dbc7ab80e00fa67f952b67933d5a35 jdk7u40-b29
 60d52db33828bf0355a94be2a82df90c901592f3 jdk7u40-b30
+c2522d149ff6663ed1d3602c88c286cff25a43a7 jdk7u40-b31
+b9f86896cd0aa9b83e472a90b20ae7c253fba633 jdk7u40-b32
--- a/src/macosx/classes/sun/lwawt/LWComponentPeer.java	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/macosx/classes/sun/lwawt/LWComponentPeer.java	Thu Jul 11 05:38:23 2013 -0700
@@ -328,7 +328,7 @@
         return peerTreeLock;
     }
 
-    final T getTarget() {
+    public final T getTarget() {
         return target;
     }
 
--- a/src/macosx/classes/sun/lwawt/LWWindowPeer.java	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/macosx/classes/sun/lwawt/LWWindowPeer.java	Thu Jul 11 05:38:23 2013 -0700
@@ -787,7 +787,8 @@
                     Point lp = lastMouseEventPeer.windowToLocal(x, y,
                                                                 lastWindowPeer);
                     Component target = lastMouseEventPeer.getTarget();
-                    postMouseEnteredExitedEvent(target, id, when, modifiers, lp,
+                    postMouseEnteredExitedEvent(target, MouseEvent.MOUSE_EXITED,
+                            when, modifiers, lp,
                             screenX, screenY, clickCount, popupTrigger, button);
                 }
                 lastMouseEventPeer = null;
@@ -805,12 +806,14 @@
                         oldp.x += r.x - lr.x;
                         oldp.y += r.y - lr.y;
                         Component target = lastMouseEventPeer.getTarget();
-                        postMouseEnteredExitedEvent(target, id, when, modifiers, oldp,
+                        postMouseEnteredExitedEvent(target, MouseEvent.MOUSE_EXITED,
+                                when, modifiers, oldp,
                                 screenX, screenY, clickCount, popupTrigger, button);
                     } else {
                         Point oldp = lastMouseEventPeer.windowToLocal(x, y, this);
                         Component target = lastMouseEventPeer.getTarget();
-                        postMouseEnteredExitedEvent(target, id, when, modifiers, oldp,
+                        postMouseEnteredExitedEvent(target, MouseEvent.MOUSE_EXITED,
+                                when, modifiers, oldp,
                                 screenX, screenY, clickCount, popupTrigger, button);
                     }
                 }
@@ -818,7 +821,8 @@
                 if (targetPeer != null && targetPeer.isEnabled() && id != MouseEvent.MOUSE_ENTERED) {
                     Point newp = targetPeer.windowToLocal(x, y, curWindowPeer);
                     Component target = targetPeer.getTarget();
-                    postMouseEnteredExitedEvent(target, id, when, modifiers, newp,
+                    postMouseEnteredExitedEvent(target, MouseEvent.MOUSE_ENTERED,
+                            when, modifiers, newp,
                             screenX, screenY, clickCount, popupTrigger, button);
                 }
             }
--- a/src/macosx/classes/sun/lwawt/macosx/CCursorManager.java	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CCursorManager.java	Thu Jul 11 05:38:23 2013 -0700
@@ -51,15 +51,6 @@
 
     @Override
     protected Point getCursorPosition() {
-        synchronized(this) {
-            if (isDragging) {
-                // during the drag operation, the appkit thread is blocked,
-                // so nativeGetCursorPosition invocation may cause a deadlock.
-                // In order to avoid this, we returns last know cursor position.
-                return new Point(dragPos);
-            }
-        }
-
         final Point2D nativePosition = nativeGetCursorPosition();
         return new Point((int)nativePosition.getX(), (int)nativePosition.getY());
     }
@@ -101,31 +92,4 @@
         // do something special
         throw new RuntimeException("Unimplemented");
     }
-
-    // package private methods to handle cursor change during drag-and-drop
-    private boolean isDragging = false;
-    private Point dragPos = null;
-
-    synchronized void startDrag(int x, int y) {
-        if (isDragging) {
-            throw new RuntimeException("Invalid Drag state in CCursorManager!");
-        }
-        isDragging = true;
-        dragPos = new Point(x, y);
-    }
-
-    synchronized void updateDragPosition(int x, int y) {
-        if (!isDragging) {
-            throw new RuntimeException("Invalid Drag state in CCursorManager!");
-        }
-        dragPos.move(x, y);
-    }
-
-    synchronized void stopDrag() {
-        if (!isDragging) {
-            throw new RuntimeException("Invalid Drag state in CCursorManager!");
-        }
-        isDragging = false;
-        dragPos = null;
-    }
 }
--- a/src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java	Thu Jul 11 05:38:23 2013 -0700
@@ -38,8 +38,12 @@
 import javax.accessibility.*;
 
 import java.util.Map;
+import java.util.concurrent.Callable;
+
 import sun.awt.dnd.*;
 import sun.lwawt.LWComponentPeer;
+import sun.lwawt.LWWindowPeer;
+import sun.lwawt.PlatformWindow;
 
 
 public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
@@ -104,13 +108,8 @@
         }
 
         //It sure will be LWComponentPeer instance as rootComponent is a Window
-        LWComponentPeer peer = (LWComponentPeer)rootComponent.getPeer();
-        //Get a pointer to a native window
-        CPlatformWindow platformWindow = (CPlatformWindow) peer.getPlatformWindow();
-        long nativeWindowPtr = platformWindow.getNSWindowPtr();
-
-        // Get drag cursor:
-        Cursor cursor = this.getCursor();
+        PlatformWindow platformWindow = ((LWComponentPeer)rootComponent.getPeer()).getPlatformWindow();
+        long nativeViewPtr = CPlatformWindow.getNativeViewPtr(platformWindow);
 
         // If there isn't any drag image make one of default appearance:
         if (fDragImage == null)
@@ -139,19 +138,15 @@
 
         try {
             // Create native dragging source:
-            final long nativeDragSource = createNativeDragSource(component, peer, nativeWindowPtr, transferable, triggerEvent,
+            final long nativeDragSource = createNativeDragSource(component, nativeViewPtr, transferable, triggerEvent,
                 (int) (dragOrigin.getX()), (int) (dragOrigin.getY()), extModifiers,
-                clickCount, timestamp, cursor, fDragCImage, dragImageOffset.x, dragImageOffset.y,
+                clickCount, timestamp, fDragCImage, dragImageOffset.x, dragImageOffset.y,
                 getDragSourceContext().getSourceActions(), formats, formatMap);
 
             if (nativeDragSource == 0)
                 throw new InvalidDnDOperationException("");
 
             setNativeContext(nativeDragSource);
-
-            CCursorManager.getInstance().startDrag(
-                    (int) (dragOrigin.getX()),
-                    (int) (dragOrigin.getY()));
         }
 
         catch (Exception e) {
@@ -160,6 +155,8 @@
 
         SunDropTargetContextPeer.setCurrentJVMLocalSourceTransferable(transferable);
 
+        CCursorManager.getInstance().setCursor(getCursor());
+
         // Create a new thread to run the dragging operation since it's synchronous, only coming back
         // after dragging is finished. This leaves the AWT event thread free to handle AWT events which
         // are posted during dragging by native event handlers.
@@ -173,8 +170,6 @@
                     } catch (Exception e) {
                         e.printStackTrace();
                     } finally {
-                        CCursorManager.getInstance().stopDrag();
-
                         releaseNativeDragSource(nativeDragSource);
                         fDragImage = null;
                         if (fDragCImage != null) {
@@ -189,8 +184,6 @@
         }
 
         catch (Exception e) {
-            CCursorManager.getInstance().stopDrag();
-
             final long nativeDragSource = getNativeContext();
             setNativeContext(0);
             releaseNativeDragSource(nativeDragSource);
@@ -416,13 +409,24 @@
                                 final int modifiers,
                                 final int x, final int y) {
 
-        CCursorManager.getInstance().updateDragPosition(x, y);
+        try {
+            Component componentAt = LWCToolkit.invokeAndWait(
+                    new Callable<Component>() {
+                        @Override
+                        public Component call() {
+                            LWWindowPeer mouseEventComponent = LWWindowPeer.getWindowUnderCursor();
+                            if (mouseEventComponent == null) {
+                                return null;
+                            }
+                            Component root = SwingUtilities.getRoot(mouseEventComponent.getTarget());
+                            if (root == null) {
+                                return null;
+                            }
+                            Point rootLocation = root.getLocationOnScreen();
+                            return getDropTargetAt(root, x - rootLocation.x, y - rootLocation.y);
+                        }
+                    }, getComponent());
 
-        Component rootComponent = SwingUtilities.getRoot(getComponent());
-        if(rootComponent != null) {
-            Point componentPoint = new Point(x, y);
-            SwingUtilities.convertPointFromScreen(componentPoint, rootComponent);
-            Component componentAt = SwingUtilities.getDeepestComponentAt(rootComponent, componentPoint.x, componentPoint.y);
             if(componentAt != hoveringComponent) {
                 if(hoveringComponent != null) {
                     dragExit(x, y);
@@ -432,20 +436,36 @@
                 }
                 hoveringComponent = componentAt;
             }
+
+            postDragSourceDragEvent(targetActions, modifiers, x, y,
+                    DISPATCH_MOUSE_MOVED);
+        } catch (Exception e) {
+            throw new InvalidDnDOperationException("Failed to handle DragMouseMoved event");
         }
-        postDragSourceDragEvent(targetActions, modifiers, x, y,
-                                DISPATCH_MOUSE_MOVED);
     }
 
-    /**
-     * upcall from native code
-     */
-    private void dragEnter(final int targetActions,
-                           final int modifiers,
-                           final int x, final int y) {
-        CCursorManager.getInstance().updateDragPosition(x, y);
+    //Returns the first lightweight or heavyweight Component which has a dropTarget ready to accept the drag
+    //Should be called from the EventDispatchThread
+    private static Component getDropTargetAt(Component root, int x, int y) {
+        if (!root.contains(x, y) || !root.isEnabled() || !root.isVisible()) {
+            return null;
+        }
 
-        postDragSourceDragEvent(targetActions, modifiers, x, y, DISPATCH_ENTER);
+        if (root.getDropTarget() != null && root.getDropTarget().isActive()) {
+            return root;
+        }
+
+        if (root instanceof Container) {
+            for (Component comp : ((Container) root).getComponents()) {
+                Point loc = comp.getLocation();
+                Component dropTarget = getDropTargetAt(comp, x - loc.x, y - loc.y);
+                if (dropTarget != null) {
+                    return dropTarget;
+                }
+            }
+        }
+
+        return null;
     }
 
     /**
@@ -455,19 +475,15 @@
         hoveringComponent = null;
     }
 
-    public void setCursor(Cursor c) throws InvalidDnDOperationException {
-        // TODO : BG
-        //AWTLockAccess.awtLock();
-        super.setCursor(c);
-        //AWTLockAccess.awtUnlock();
+    @Override
+    protected void setNativeCursor(long nativeCtxt, Cursor c, int cType) {
+        CCursorManager.getInstance().setCursor(c);
     }
 
-    protected native void setNativeCursor(long nativeCtxt, Cursor c, int cType);
-
     // Native support:
-    private native long createNativeDragSource(Component component, ComponentPeer peer, long nativePeer, Transferable transferable,
+    private native long createNativeDragSource(Component component, long nativePeer, Transferable transferable,
         InputEvent triggerEvent, int dragPosX, int dragPosY, int extModifiers, int clickCount, long timestamp,
-        Cursor cursor, CImage nsDragImage, int dragImageOffsetX, int dragImageOffsetY,
+        CImage nsDragImage, int dragImageOffsetX, int dragImageOffsetY,
         int sourceActions, long[] formats, Map formatMap);
 
     private native void doDragging(long nativeDragSource);
--- a/src/macosx/classes/sun/lwawt/macosx/CDropTarget.java	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CDropTarget.java	Thu Jul 11 05:38:23 2013 -0700
@@ -30,6 +30,7 @@
 import java.awt.dnd.DropTarget;
 
 import sun.lwawt.LWComponentPeer;
+import sun.lwawt.PlatformWindow;
 
 
 public final class CDropTarget {
@@ -50,21 +51,11 @@
         fComponent = component;
         fPeer = peer;
 
-        // Make sure the drop target is a ComponentModel:
-        if (!(peer instanceof LWComponentPeer))
-            throw new IllegalArgumentException("CDropTarget's peer must be a LWComponentPeer.");
-
-        // Get model pointer (CButton.m and such) and its native peer:
-        LWComponentPeer model = (LWComponentPeer) peer;
-        if (model.getPlatformWindow() instanceof CPlatformWindow) {
-            CPlatformWindow platformWindow = (CPlatformWindow) model.getPlatformWindow();
-            long nativePeer = platformWindow.getNSWindowPtr();
-
-            // Create native dragging destination:
-            fNativeDropTarget = this.createNativeDropTarget(dropTarget, component, peer, nativePeer);
-            if (fNativeDropTarget == 0) {
-                throw new IllegalStateException("CDropTarget.createNativeDropTarget() failed.");
-            }
+        long nativePeer = CPlatformWindow.getNativeViewPtr(((LWComponentPeer) peer).getPlatformWindow());
+        // Create native dragging destination:
+        fNativeDropTarget = this.createNativeDropTarget(dropTarget, component, peer, nativePeer);
+        if (fNativeDropTarget == 0) {
+            throw new IllegalStateException("CDropTarget.createNativeDropTarget() failed.");
         }
     }
 
--- a/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java	Thu Jul 11 05:38:23 2013 -0700
@@ -125,6 +125,17 @@
         }
     }
 
+    /**
+     * When the window is activated and had focus before the deactivation
+     * calling this method triggers focus events in the following order:
+     *  1. WINDOW_ACTIVATED for this EmbeddedFrame
+     *  2. WINDOW_GAINED_FOCUS for this EmbeddedFrame
+     *  3. FOCUS_GAINED for the most recent focus owner in this EmbeddedFrame
+     *
+     * The caller must not requestFocus on the EmbeddedFrame together with calling this method.
+     *
+     * @param parentWindowActive true if the window is activated, false otherwise
+     */
     public void handleWindowFocusEvent(boolean parentWindowActive) {
         this.parentWindowActive = parentWindowActive;
         // ignore focus "lost" native request as it may mistakenly
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Thu Jul 11 05:38:23 2013 -0700
@@ -923,6 +923,21 @@
         }
     }
 
+    /**
+     * Helper method to get a pointer to the native view from the PlatformWindow.
+     */
+    static long getNativeViewPtr(PlatformWindow platformWindow) {
+        long nativePeer = 0L;
+        if (platformWindow instanceof CPlatformWindow) {
+            nativePeer = ((CPlatformWindow) platformWindow).getContentView().getAWTView();
+        } else if (platformWindow instanceof CViewPlatformEmbeddedFrame){
+            nativePeer = ((CViewPlatformEmbeddedFrame) platformWindow).getNSViewPtr();
+        } else {
+            throw new IllegalArgumentException("Unsupported platformWindow implementation");
+        }
+        return nativePeer;
+    }
+
     /*************************************************************
      * Callbacks from the AWTWindow and AWTView objc classes.
      *************************************************************/
--- a/src/macosx/native/sun/awt/CDragSource.h	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/macosx/native/sun/awt/CDragSource.h	Thu Jul 11 05:38:23 2013 -0700
@@ -33,7 +33,6 @@
 @private
     NSView*        fView;
     jobject            fComponent;
-    jobject            fComponentPeer;
     jobject            fDragSourceContextPeer;
 
     jobject            fTransferable;
@@ -43,8 +42,6 @@
     jint                fClickCount;
     jint                fModifiers;
 
-    jobject            fCursor;
-
     NSImage*        fDragImage;
     NSPoint            fDragImageOffset;
 
@@ -59,12 +56,22 @@
 + (CDragSource *) currentDragSource;
 
 // Common methods:
-- (id)init:(jobject)jdragsourcecontextpeer component:(jobject)jcomponent peer:(jobject)jpeer control:(id)control
-    transferable:(jobject)jtransferable triggerEvent:(jobject)jtrigger
-    dragPosX:(jint)dragPosX dragPosY:(jint)dragPosY modifiers:(jint)extModifiers clickCount:(jint)clickCount timeStamp:(jlong)timeStamp
-    cursor:(jobject)jcursor
-    dragImage:(jobject)jnsdragimage dragImageOffsetX:(jint)jdragimageoffsetx dragImageOffsetY:(jint)jdragimageoffsety
-    sourceActions:(jint)jsourceactions formats:(jlongArray)jformats formatMap:(jobject)jformatmap;
+- (id)        init:(jobject)jDragSourceContextPeer
+         component:(jobject)jComponent
+           control:(id)control
+      transferable:(jobject)jTransferable
+      triggerEvent:(jobject)jTrigger
+          dragPosX:(jint)dragPosX
+          dragPosY:(jint)dragPosY
+         modifiers:(jint)extModifiers
+        clickCount:(jint)clickCount
+         timeStamp:(jlong)timeStamp
+         dragImage:(jobject)jDragImage
+  dragImageOffsetX:(jint)jDragImageOffsetX
+  dragImageOffsetY:(jint)jDragImageOffsetY
+     sourceActions:(jint)jSourceActions
+           formats:(jlongArray)jFormats
+         formatMap:(jobject)jFormatMap;
 
 - (void)removeFromView:(JNIEnv *)env;
 
--- a/src/macosx/native/sun/awt/CDragSource.m	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/macosx/native/sun/awt/CDragSource.m	Thu Jul 11 05:38:23 2013 -0700
@@ -84,12 +84,22 @@
     return sCurrentDragSource;
 }
 
-- (id)init:(jobject)jdragsourcecontextpeer component:(jobject)jcomponent peer:(jobject)jpeer control:(id)control
-    transferable:(jobject)jtransferable triggerEvent:(jobject)jtrigger
-    dragPosX:(jint)dragPosX dragPosY:(jint)dragPosY modifiers:(jint)extModifiers clickCount:(jint)clickCount
-    timeStamp:(jlong)timeStamp cursor:(jobject)jcursor
-    dragImage:(jobject)jnsdragimage dragImageOffsetX:(jint)jdragimageoffsetx dragImageOffsetY:(jint)jdragimageoffsety
-    sourceActions:(jint)jsourceactions formats:(jlongArray)jformats formatMap:(jobject)jformatmap
+- (id)        init:(jobject)jDragSourceContextPeer
+         component:(jobject)jComponent
+           control:(id)control
+      transferable:(jobject)jTransferable
+      triggerEvent:(jobject)jTrigger
+          dragPosX:(jint)dragPosX
+          dragPosY:(jint)dragPosY
+         modifiers:(jint)extModifiers
+        clickCount:(jint)clickCount
+         timeStamp:(jlong)timeStamp
+         dragImage:(jobject)jDragImage
+  dragImageOffsetX:(jint)jDragImageOffsetX
+  dragImageOffsetY:(jint)jDragImageOffsetY
+     sourceActions:(jint)jSourceActions
+           formats:(jlongArray)jFormats
+         formatMap:(jobject)jFormatMap
 {
     self = [super init];
     DLog2(@"[CDragSource init]: %@\n", self);
@@ -100,27 +110,25 @@
     // Construct the object if we have a valid model for it:
     if (control != nil) {
         JNIEnv *env = [ThreadUtilities getJNIEnv];
-        fComponent = JNFNewGlobalRef(env, jcomponent);
-        fComponentPeer = JNFNewGlobalRef(env, jpeer);
-        fDragSourceContextPeer = JNFNewGlobalRef(env, jdragsourcecontextpeer);
+        fComponent = JNFNewGlobalRef(env, jComponent);
+        fDragSourceContextPeer = JNFNewGlobalRef(env, jDragSourceContextPeer);
 
-        fTransferable = JNFNewGlobalRef(env, jtransferable);
-        fTriggerEvent = JNFNewGlobalRef(env, jtrigger);
-        fCursor = JNFNewGlobalRef(env, jcursor);
+        fTransferable = JNFNewGlobalRef(env, jTransferable);
+        fTriggerEvent = JNFNewGlobalRef(env, jTrigger);
 
-        if (jnsdragimage) {
+        if (jDragImage) {
             JNF_MEMBER_CACHE(nsImagePtr, CImageClass, "ptr", "J");
-            jlong imgPtr = JNFGetLongField(env, jnsdragimage, nsImagePtr);
+            jlong imgPtr = JNFGetLongField(env, jDragImage, nsImagePtr);
             fDragImage = (NSImage*) jlong_to_ptr(imgPtr); // Double-casting prevents compiler 'd$|//
 
             [fDragImage retain];
         }
 
-        fDragImageOffset = NSMakePoint(jdragimageoffsetx, jdragimageoffsety);
+        fDragImageOffset = NSMakePoint(jDragImageOffsetX, jDragImageOffsetY);
 
-        fSourceActions = jsourceactions;
-        fFormats = JNFNewGlobalRef(env, jformats);
-        fFormatMap = JNFNewGlobalRef(env, jformatmap);
+        fSourceActions = jSourceActions;
+        fFormats = JNFNewGlobalRef(env, jFormats);
+        fFormatMap = JNFNewGlobalRef(env, jFormatMap);
 
         fTriggerEventTimeStamp = timeStamp;
         fDragPos = NSMakePoint(dragPosX, dragPosY);
@@ -129,9 +137,8 @@
 
         // Set this object as a dragging source:
 
-        AWTView *awtView = [((NSWindow *) control) contentView];
-        fView = [awtView retain];
-        [awtView setDragSource:self];
+        fView = [(AWTView *) control retain];
+        [fView setDragSource:self];
 
         // Let AWTEvent know Java drag is getting underway:
         [NSEvent javaDraggingBegin];
@@ -158,11 +165,6 @@
         fComponent = NULL;
     }
 
-    if (fComponentPeer != NULL) {
-        JNFDeleteGlobalRef(env, fComponentPeer);
-        fComponentPeer = NULL;
-    }
-
     if (fDragSourceContextPeer != NULL) {
         JNFDeleteGlobalRef(env, fDragSourceContextPeer);
         fDragSourceContextPeer = NULL;
@@ -178,11 +180,6 @@
         fTriggerEvent = NULL;
     }
 
-    if (fCursor != NULL) {
-        JNFDeleteGlobalRef(env, fCursor);
-        fCursor = NULL;
-    }
-
     if (fFormats != NULL) {
         JNFDeleteGlobalRef(env, fFormats);
         fFormats = NULL;
@@ -586,11 +583,6 @@
 {
     AWT_ASSERT_NOT_APPKIT_THREAD;
 
-    // Set the drag cursor (or not 3839999)
-    //JNIEnv *env = [ThreadUtilities getJNIEnv];
-    //jobject gCursor = JNFNewGlobalRef(env, fCursor);
-    //[EventFactory setJavaCursor:gCursor withEnv:env];
-
     [self performSelectorOnMainThread:@selector(doDrag) withObject:nil waitUntilDone:YES]; // AWT_THREADING Safe (called from unique asynchronous thread)
 }
 
--- a/src/macosx/native/sun/awt/CDragSourceContextPeer.m	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/macosx/native/sun/awt/CDragSourceContextPeer.m	Thu Jul 11 05:38:23 2013 -0700
@@ -34,12 +34,13 @@
 /*
  * Class:     sun_lwawt_macosx_CDragSourceContextPeer
  * Method:    createNativeDragSource
- * Signature: (Ljava/awt/Component;Ljava/awt/peer/ComponentPeer;JLjava/awt/datatransfer/Transferable;Ljava/awt/event/InputEvent;IIIIJLjava/awt/Cursor;IJIII[JLjava/util/Map;)J
+ * Signature: (Ljava/awt/Component;JLjava/awt/datatransfer/Transferable;
+               Ljava/awt/event/InputEvent;IIIIJIJIII[JLjava/util/Map;)J
  */
 JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_createNativeDragSource
-  (JNIEnv *env, jobject jthis, jobject jcomponent, jobject jpeer, jlong jnativepeer, jobject jtransferable,
+  (JNIEnv *env, jobject jthis, jobject jcomponent, jlong jnativepeer, jobject jtransferable,
    jobject jtrigger, jint jdragposx, jint jdragposy, jint jextmodifiers, jint jclickcount, jlong jtimestamp,
-   jobject jcursor, jobject jnsdragimage, jint jdragimageoffsetx, jint jdragimageoffsety,
+   jobject jnsdragimage, jint jdragimageoffsetx, jint jdragimageoffsety,
    jint jsourceactions, jlongArray jformats, jobject jformatmap)
 {
     id controlObj = (id) jlong_to_ptr(jnativepeer);
@@ -47,12 +48,22 @@
 
 JNF_COCOA_ENTER(env);
     [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
-        dragSource = [[CDragSource alloc] init:jthis component:jcomponent peer:jpeer control:controlObj
-            transferable:jtransferable triggerEvent:jtrigger dragPosX:jdragposx
-            dragPosY:jdragposy modifiers:jextmodifiers clickCount:jclickcount timeStamp:jtimestamp
-            cursor:jcursor dragImage:jnsdragimage dragImageOffsetX:jdragimageoffsetx
-            dragImageOffsetY:jdragimageoffsety sourceActions:jsourceactions
-            formats:jformats formatMap:jformatmap];
+        dragSource = [[CDragSource alloc] init:jthis
+                                     component:jcomponent
+                                       control:controlObj
+                                  transferable:jtransferable
+                                  triggerEvent:jtrigger
+                                      dragPosX:jdragposx
+                                      dragPosY:jdragposy
+                                     modifiers:jextmodifiers
+                                    clickCount:jclickcount
+                                     timeStamp:jtimestamp
+                                     dragImage:jnsdragimage
+                              dragImageOffsetX:jdragimageoffsetx
+                              dragImageOffsetY:jdragimageoffsety
+                                 sourceActions:jsourceactions
+                                       formats:jformats
+                                     formatMap:jformatmap];
     }];
 JNF_COCOA_EXIT(env);
 
@@ -94,19 +105,3 @@
     [dragSource removeFromView:env];
 JNF_COCOA_EXIT(env);
 }
-
-/*
- * Class:     sun_lwawt_macosx_CDragSourceContextPeer
- * Method:    setNativeCursor
- * Signature: (JLjava/awt/Cursor;I)V
- */
-JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_setNativeCursor
-  (JNIEnv *env, jobject jthis, jlong nativeDragSourceVal, jobject jcursor, jint jcursortype)
-{
-   //AWT_ASSERT_NOT_APPKIT_THREAD;
-
-//JNF_COCOA_ENTER(env);
-//    jobject gCursor = JNFNewGlobalRef(env, jcursor);
-//    [EventFactory setJavaCursor:gCursor withEnv:env];
-//JNF_COCOA_EXIT(env);
-}
--- a/src/macosx/native/sun/awt/CDropTarget.m	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/macosx/native/sun/awt/CDropTarget.m	Thu Jul 11 05:38:23 2013 -0700
@@ -81,9 +81,8 @@
         fComponent = JNFNewGlobalRef(env, jcomponent);
         fDropTarget = JNFNewGlobalRef(env, jdropTarget);
 
-        AWTView *awtView = [((NSWindow *) control) contentView];
-        fView = [awtView retain];
-        [awtView setDropTarget:self];
+        fView = [((AWTView *) control) retain];
+        [fView setDropTarget:self];
 
 
     } else {
@@ -177,6 +176,10 @@
 {
     DLog2(@"[CDropTarget dealloc]: %@\n", self);
 
+    if(sCurrentDropTarget == self) {
+        sCurrentDropTarget = nil;
+    }
+
     [fView release];
     fView = nil;
 
@@ -490,7 +493,10 @@
         JNF_MEMBER_CACHE(handleEnterMessageMethod, jc_CDropTargetContextPeer, "handleEnterMessage", "(Ljava/awt/Component;IIII[JJ)I");
         if (sDraggingError == FALSE) {
             // Double-casting self gets rid of 'different size' compiler warning:
-            actions = JNFCallIntMethod(env, fDropTargetContextPeer, handleEnterMessageMethod, fComponent, (jint) javaLocation.x, (jint) javaLocation.y, dropAction, actions, formats, ptr_to_jlong(self)); // AWT_THREADING Safe (CToolkitThreadBlockedHandler)
+            // AWT_THREADING Safe (CToolkitThreadBlockedHandler)
+            actions = JNFCallIntMethod(env, fDropTargetContextPeer, handleEnterMessageMethod,
+                                       fComponent, (jint) javaLocation.x, (jint) javaLocation.y,
+                                       dropAction, actions, formats, ptr_to_jlong(self));
         }
 
         if (sDraggingError == FALSE) {
@@ -510,11 +516,6 @@
             // Remember the dragOp for no-op'd update messages:
             sUpdateOperation = dragOp;
         }
-
-        // If we are in the same process as the sender, make the sender post the appropriate message
-        if (sender) {
-            [[CDragSource currentDragSource] postDragEnter];
-        }
     }
 
     // 9-11-02 Note: the native event thread would not handle an exception gracefully:
@@ -608,11 +609,9 @@
         JNF_MEMBER_CACHE(handleExitMessageMethod, jc_CDropTargetContextPeer, "handleExitMessage", "(Ljava/awt/Component;J)V");
         if (sDraggingError == FALSE) {
             DLog3(@"  - dragExit: loc native %f, %f\n", sDraggingLocation.x, sDraggingLocation.y);
-            JNFCallVoidMethod(env, fDropTargetContextPeer, handleExitMessageMethod, fComponent, ptr_to_jlong(self)); // AWT_THREADING Safe (CToolkitThreadBlockedHandler)
-            // If we are in the same process as the sender, make the sender post the appropriate message
-            if (sender) {
-                [[CDragSource currentDragSource] postDragExit];
-            }
+             // AWT_THREADING Safe (CToolkitThreadBlockedHandler) 
+            JNFCallVoidMethod(env, fDropTargetContextPeer,
+                              handleExitMessageMethod, fComponent, ptr_to_jlong(self));
         }
 
         // 5-27-03 Note: [Radar 3270455]
--- a/src/macosx/native/sun/awt/CMenuItem.m	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/macosx/native/sun/awt/CMenuItem.m	Thu Jul 11 05:38:23 2013 -0700
@@ -82,8 +82,13 @@
         // keys, so we need to do the same translation here that we do
         // for the regular key down events
         if ([eventKey length] == 1) {
-            unichar ch =  NsCharToJavaChar([eventKey characterAtIndex:0], 0);
-            eventKey = [NSString stringWithCharacters: &ch length: 1];
+            unichar origChar = [eventKey characterAtIndex:0];
+            unichar newChar =  NsCharToJavaChar(origChar, 0);
+            if (newChar == java_awt_event_KeyEvent_CHAR_UNDEFINED) {
+                newChar = origChar;
+            }
+
+            eventKey = [NSString stringWithCharacters: &newChar length: 1];
         }
 
         if ([menuKey isEqualToString:eventKey]) {
--- a/src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java	Thu Jul 11 05:38:23 2013 -0700
@@ -274,7 +274,7 @@
      * upcall from native code
      */
 
-    private void dragEnter(final int targetActions,
+    protected void dragEnter(final int targetActions,
                            final int modifiers,
                            final int x, final int y) {
         postDragSourceDragEvent(targetActions, modifiers, x, y, DISPATCH_ENTER);
@@ -352,10 +352,6 @@
 
     public static void setDragDropInProgress(boolean b)
       throws InvalidDnDOperationException {
-        if (dragDropInProgress == b) {
-            throw new InvalidDnDOperationException(getExceptionMessage(b));
-        }
-
         synchronized (SunDragSourceContextPeer.class) {
             if (dragDropInProgress == b) {
                 throw new InvalidDnDOperationException(getExceptionMessage(b));
--- a/src/share/classes/sun/java2d/SunGraphics2D.java	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/share/classes/sun/java2d/SunGraphics2D.java	Thu Jul 11 05:38:23 2013 -0700
@@ -1770,20 +1770,10 @@
     }
 
     public Rectangle getClipBounds() {
-        Rectangle r;
         if (clipState == CLIP_DEVICE) {
-            r = null;
-        } else if (transformState <= TRANSFORM_INT_TRANSLATE) {
-            if (usrClip instanceof Rectangle) {
-                r = new Rectangle((Rectangle) usrClip);
-            } else {
-                r = usrClip.getBounds();
-            }
-            r.translate(-transX, -transY);
-        } else {
-            r = getClip().getBounds();
+            return null;
         }
-        return r;
+        return getClipBounds(new Rectangle());
     }
 
     public Rectangle getClipBounds(Rectangle r) {
@@ -1792,11 +1782,11 @@
                 if (usrClip instanceof Rectangle) {
                     r.setBounds((Rectangle) usrClip);
                 } else {
-                    r.setBounds(usrClip.getBounds());
+                    r.setFrame(usrClip.getBounds2D());
                 }
                 r.translate(-transX, -transY);
             } else {
-                r.setBounds(getClip().getBounds());
+                r.setFrame(getClip().getBounds2D());
             }
         } else if (r == null) {
             throw new NullPointerException("null rectangle parameter");
@@ -1971,10 +1961,10 @@
             matrix[2] = matrix[0] + rect.getWidth();
             matrix[3] = matrix[1] + rect.getHeight();
             tx.transform(matrix, 0, matrix, 0, 2);
-            rect = new Rectangle2D.Float();
-            rect.setFrameFromDiagonal(matrix[0], matrix[1],
-                                      matrix[2], matrix[3]);
-            return rect;
+            fixRectangleOrientation(matrix, rect);
+            return new Rectangle2D.Double(matrix[0], matrix[1],
+                                          matrix[2] - matrix[0],
+                                          matrix[3] - matrix[1]);
         }
 
         if (tx.isIdentity()) {
@@ -1984,6 +1974,22 @@
         return tx.createTransformedShape(clip);
     }
 
+    /**
+     * Sets orientation of the rectangle according to the clip.
+     */
+    private static void fixRectangleOrientation(double[] m, Rectangle2D clip) {
+        if (clip.getWidth() > 0 != (m[2] - m[0] > 0)) {
+            double t = m[0];
+            m[0] = m[2];
+            m[2] = t;
+        }
+        if (clip.getHeight() > 0 != (m[3] - m[1] > 0)) {
+            double t = m[1];
+            m[1] = m[3];
+            m[3] = t;
+        }
+    }
+
     public void clipRect(int x, int y, int w, int h) {
         clip(new Rectangle(x, y, w, h));
     }
--- a/src/share/classes/sun/misc/VM.java	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/share/classes/sun/misc/VM.java	Thu Jul 11 05:38:23 2013 -0700
@@ -216,6 +216,16 @@
         return allowArraySyntax;
     }
 
+    private static boolean allowGetCallerClass = false;
+
+    // Reflection.getCallerClass(int) is disabled by default.
+    // It can be enabled by setting the system property
+    // "jdk.reflect.allowGetCallerClass" and also used by
+    // logging stack walk of a resource bundle if it is turned on.
+    public static boolean allowGetCallerClass() {
+        return allowGetCallerClass;
+    }
+
     /**
      * Returns the system property of the specified key saved at
      * system initialization time.  This method should only be used
@@ -280,6 +290,16 @@
                                ? defaultAllowArraySyntax
                                : Boolean.parseBoolean(s));
 
+        // Reflection.getCallerClass(int) is disabled by default.
+        // It can be enabled by setting the system property
+        // "jdk.reflect.allowGetCallerClass" and also used by
+        // logging stack walk of a resource bundle if it is turned on.
+        s = props.getProperty("jdk.reflect.allowGetCallerClass");
+        allowGetCallerClass = (s != null
+                                   ? (s.isEmpty() || Boolean.parseBoolean(s))
+                                   : false) ||
+             Boolean.valueOf(props.getProperty("jdk.logging.allowStackWalkSearch"));
+
         // Remove other private system properties
         // used by java.lang.Integer.IntegerCache
         props.remove("java.lang.Integer.IntegerCache.high");
--- a/src/share/classes/sun/reflect/Reflection.java	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/share/classes/sun/reflect/Reflection.java	Thu Jul 11 05:38:23 2013 -0700
@@ -65,7 +65,15 @@
     @Deprecated
     @CallerSensitive
     public static Class getCallerClass(int depth) {
-        return getCallerClass0(depth+1);
+        if (sun.misc.VM.allowGetCallerClass()) {
+            return getCallerClass0(depth+1);
+        }
+        throw new UnsupportedOperationException("This method is in the sun.* " +
+             "namespace so it is not a supported, public interface. " +
+             "The 7u40 release notes describe a temporary mechanism " +
+             "to reenable the historical functionality of this method. " +
+             "Update code to function properly and this method will be " +
+             "removed without further warning in a subsequent 7 update release.");
     }
 
     // If the VM enforces getting caller class with @CallerSensitive,
--- a/src/solaris/classes/sun/awt/X11/XBaseMenuWindow.java	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/solaris/classes/sun/awt/X11/XBaseMenuWindow.java	Thu Jul 11 05:38:23 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -904,11 +904,12 @@
      */
     public void dispose() {
         setDisposed(true);
-        EventQueue.invokeLater(new Runnable() {
+        InvocationEvent ev = new InvocationEvent(target, new Runnable() {
             public void run() {
                 doDispose();
             }
         });
+        super.postEvent(ev);
     }
 
     /**
@@ -933,11 +934,12 @@
      * so events can not be processed using standart means
      */
     void postEvent(final AWTEvent event) {
-        EventQueue.invokeLater(new Runnable() {
-                public void run() {
-                    handleEvent(event);
-                }
-            });
+        InvocationEvent ev = new InvocationEvent(event.getSource(), new Runnable() {
+            public void run() {
+                handleEvent(event);
+            }
+        });
+        super.postEvent(ev);
     }
 
     /**
--- a/src/solaris/classes/sun/awt/X11/XChoicePeer.java	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/solaris/classes/sun/awt/X11/XChoicePeer.java	Thu Jul 11 05:38:23 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -1027,15 +1027,17 @@
             //fix 6252982: PIT: Keyboard FocusTraversal not working when choice's drop-down is visible, on XToolkit
             if (e instanceof KeyEvent){
                 // notify XWindow that this event had been already handled and no need to post it again
-                EventQueue.invokeLater(new Runnable() {
-                        public void run() {
-                            if(target.isFocusable() &&
-                               getParentTopLevel().isFocusableWindow() )
-                            {
-                                handleJavaKeyEvent((KeyEvent)e);
-                            }
+                InvocationEvent ev = new InvocationEvent(target, new Runnable() {
+                    public void run() {
+                        if(target.isFocusable() &&
+                                getParentTopLevel().isFocusableWindow() )
+                        {
+                            handleJavaKeyEvent((KeyEvent)e);
                         }
-                    });
+                    }
+                });
+                postEvent(ev);
+
                 return true;
             } else {
                 if (e instanceof MouseEvent){
@@ -1077,11 +1079,13 @@
     //convenient method
     //do not generate this kind of Events
     public boolean handleMouseEventByChoice(final MouseEvent me){
-        EventQueue.invokeLater(new Runnable() {
-                public void run() {
-                    handleJavaMouseEvent(me);
-                }
-            });
+        InvocationEvent ev = new InvocationEvent(target, new Runnable() {
+            public void run() {
+                handleJavaMouseEvent(me);
+            }
+        });
+        postEvent(ev);
+
         return true;
     }
 
--- a/src/solaris/classes/sun/awt/X11/XListPeer.java	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/solaris/classes/sun/awt/X11/XListPeer.java	Thu Jul 11 05:38:23 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -1646,11 +1646,12 @@
      * Do handleJavaMouseEvent on EDT
      */
     void handleJavaMouseEventOnEDT(final MouseEvent me){
-        EventQueue.invokeLater(new Runnable() {
-                public void run() {
-                    handleJavaMouseEvent(me);
-                }
-            });
+        InvocationEvent ev = new InvocationEvent(target, new Runnable() {
+            public void run() {
+                handleJavaMouseEvent(me);
+            }
+        });
+        postEvent(ev);
     }
 
     /*
--- a/src/solaris/classes/sun/print/IPPPrintService.java	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/solaris/classes/sun/print/IPPPrintService.java	Thu Jul 11 05:38:23 2013 -0700
@@ -1029,7 +1029,16 @@
             // now supports collation and that most OS has a way
             // of setting it, it is a safe assumption to just always
             // include SheetCollate as supported attribute.
-            catList.add(SheetCollate.class);
+
+            /*
+               In Linux, we use Postscript for rendering but Linux still
+               has issues in propagating Postscript-embedded setpagedevice
+               setting like collation.  Therefore, we temporarily exclude
+               Linux.
+            */
+            if (!UnixPrintServiceLookup.isLinux()) {
+                catList.add(SheetCollate.class);
+            }
         }
 
         // With the assumption that  Chromaticity is equivalent to
--- a/src/solaris/classes/sun/print/UnixPrintServiceLookup.java	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/solaris/classes/sun/print/UnixPrintServiceLookup.java	Thu Jul 11 05:38:23 2013 -0700
@@ -123,6 +123,10 @@
         return osname.equals("SunOS");
     }
 
+    static boolean isLinux() {
+        return (osname.equals("Linux"));
+    }
+
     static boolean isBSD() {
         return (osname.equals("Linux") ||
                 osname.contains("OS X"));
--- a/src/solaris/native/com/sun/management/UnixOperatingSystem_md.c	Thu Jun 27 09:34:52 2013 -0700
+++ b/src/solaris/native/com/sun/management/UnixOperatingSystem_md.c	Thu Jul 11 05:38:23 2013 -0700
@@ -372,7 +372,7 @@
     size_t fds_size;
 
     kres = pid_for_task(mach_task_self(), &my_pid);
-    if (res != KERN_SUCCESS) {
+    if (kres != KERN_SUCCESS) {
         throw_internal_error(env, "pid_for_task failed");
         return -1;
     }
--- a/test/ProblemList.txt	Thu Jun 27 09:34:52 2013 -0700
+++ b/test/ProblemList.txt	Thu Jul 11 05:38:23 2013 -0700
@@ -393,9 +393,6 @@
 
 # jdk_tools
 
-# 8012474
-sun/tools/jmap/Basic.sh                                         generic-all
-
 # 6461635
 com/sun/tools/attach/BasicTests.sh                              generic-all
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Graphics2D/Test8004859/Test8004859.java	Thu Jul 11 05:38:23 2013 -0700
@@ -0,0 +1,102 @@
+/*
+ * 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 java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.geom.NoninvertibleTransformException;
+import java.awt.image.BufferedImage;
+
+import sun.java2d.SunGraphics2D;
+
+/**
+ * @test
+ * @bug 8004859
+ * @summary getClipBounds/getClip should return equivalent bounds.
+ * @author Sergey Bylokhov
+ */
+public final class Test8004859 {
+
+    private static Shape[] clips = {new Rectangle(0, 0, -1, -1), new Rectangle(
+            100, 100, -100, -100)};
+
+    private static boolean status = true;
+
+    public static void main(final String[] args)
+            throws NoninvertibleTransformException {
+        final BufferedImage bi = new BufferedImage(300, 300,
+                                                   BufferedImage.TYPE_INT_RGB);
+        final Graphics2D g = (Graphics2D) bi.getGraphics();
+        test(g);
+        g.translate(2.0, 2.0);
+        test(g);
+        g.translate(-4.0, -4.0);
+        test(g);
+        g.scale(2.0, 2.0);
+        test(g);
+        g.scale(-4.0, -4.0);
+        test(g);
+        g.rotate(Math.toRadians(90));
+        test(g);
+        g.rotate(Math.toRadians(90));
+        test(g);
+        g.rotate(Math.toRadians(90));
+        test(g);
+        g.rotate(Math.toRadians(90));
+        test(g);
+        g.dispose();
+        if (!status) {
+            throw new RuntimeException("Test failed");
+        }
+    }
+
+    private static void test(final Graphics2D g) {
+        for (final Shape clip : clips) {
+            g.setClip(clip);
+            if (!g.getClip().equals(clip)) {
+                System.err.println("Expected clip: " + clip);
+                System.err.println("Actual clip: " + g.getClip());
+                System.err.println("bounds="+g.getClip().getBounds2D());
+                System.err.println("bounds="+g.getClip().getBounds());
+                status = false;
+            }
+            final Rectangle bounds = g.getClipBounds();
+            if (!clip.equals(bounds)) {
+                System.err.println("Expected getClipBounds(): " + clip);
+                System.err.println("Actual getClipBounds(): " + bounds);
+                status = false;
+            }
+            g.getClipBounds(bounds);
+            if (!clip.equals(bounds)) {
+                System.err.println("Expected getClipBounds(r): " + clip);
+                System.err.println("Actual getClipBounds(r): " + bounds);
+                status = false;
+            }
+            if (!clip.getBounds2D().isEmpty() && ((SunGraphics2D) g).clipRegion
+                    .isEmpty()) {
+                System.err.println("clipRegion should not be empty");
+                status = false;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java	Thu Jul 11 05:38:23 2013 -0700
@@ -0,0 +1,97 @@
+/*
+ * 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 @summary JVM crash if the frame is disposed in DropTargetListener
+ * @author Petr Pchelko
+ * @library ../../regtesthelpers
+ * @build Util
+ * @compile DisposeFrameOnDragTest.java
+ * @run main/othervm DisposeFrameOnDragTest
+ */
+import java.awt.AWTException;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.dnd.DropTargetAdapter;
+import java.awt.dnd.DropTargetDragEvent;
+import java.awt.dnd.DropTargetDropEvent;
+import java.awt.event.InputEvent;
+import java.lang.reflect.InvocationTargetException;
+import java.util.TooManyListenersException;
+import javax.swing.JFrame;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+import test.java.awt.regtesthelpers.Util;
+
+public class DisposeFrameOnDragTest {
+
+    private static JTextArea textArea;
+
+    public static void main(String[] args) throws Throwable {
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                constructTestUI();
+            }
+        });
+
+        Util.waitForIdle(null);
+        try {
+            Point loc = textArea.getLocationOnScreen();
+            Util.drag(new Robot(),
+                    new Point((int) loc.x + 3, (int) loc.y + 3),
+                    new Point((int) loc.x + 40, (int) loc.y + 40),
+                    InputEvent.BUTTON1_MASK);
+        } catch (AWTException ex) {
+            throw new RuntimeException("Could not initiate a drag operation");
+        }
+        Util.waitForIdle(null);
+    }
+
+    private static void constructTestUI() {
+        final JFrame frame = new JFrame("Test frame");
+        textArea = new JTextArea("Drag Me!");
+        try {
+            textArea.getDropTarget().addDropTargetListener(new DropTargetAdapter() {
+                @Override
+                public void drop(DropTargetDropEvent dtde) {
+                    //IGNORE
+                }
+
+                @Override
+                public void dragOver(DropTargetDragEvent dtde) {
+                    frame.dispose();
+                }
+            });
+        } catch (TooManyListenersException ex) {
+            throw new RuntimeException(ex);
+        }
+        textArea.setSize(100, 100);
+        textArea.setDragEnabled(true);
+        textArea.select(0, textArea.getText().length());
+        frame.add(textArea);
+        frame.setBounds(100, 100, 100, 100);
+        frame.setVisible(true);
+    }
+}
--- a/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java	Thu Jun 27 09:34:52 2013 -0700
+++ b/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java	Thu Jul 11 05:38:23 2013 -0700
@@ -35,10 +35,11 @@
 import javax.swing.*;
 
 public class ActionListenerCalledTwiceTest {
-    static String menuItems[] = { "Item1", "Item2" };
+    static String menuItems[] = { "Item1", "Item2", "Item3" };
     static KeyStroke keyStrokes[] = {
         KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.META_MASK),
-        KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)
+        KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
+        KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.SHIFT_MASK),
     };
 
     static volatile int listenerCallCounter = 0;
--- a/test/sun/reflect/GetCallerClass.java	Thu Jun 27 09:34:52 2013 -0700
+++ b/test/sun/reflect/GetCallerClass.java	Thu Jul 11 05:38:23 2013 -0700
@@ -23,29 +23,83 @@
 
 /*
  * @test
- * @bug 8016814
- * @summary Test sun.reflect.Reflection.getCallerClass(int)
+ * @bug 8016814 8014925
+ * @summary Test sun.reflect.Reflection.getCallerClass(int) disabled by default
  * @compile -XDignore.symbol.file GetCallerClass.java
- * @run main GetCallerClass
+ * @run main/othervm GetCallerClass
+ * @run main/othervm -Djdk.reflect.allowGetCallerClass GetCallerClass
+ * @run main/othervm -Djdk.reflect.allowGetCallerClass=true GetCallerClass
+ * @run main/othervm -Djdk.reflect.allowGetCallerClass=false GetCallerClass
  */
 
 public class GetCallerClass {
     public static void main(String[] args) throws Exception {
-        Class<?> c = Temp.test();
-        if (c != GetCallerClass.class) {
-            throw new RuntimeException("Incorrect caller: " + c);
+        String s = System.getProperty("jdk.reflect.allowGetCallerClass");
+        boolean allowed;
+        if (s == null || s.equals("false")) {
+            allowed = false;
+        } else if (s.equals("") || s.equals("true")) {
+            allowed = true;
+        } else {
+            throw new RuntimeException("Unsupported test setting");
+        }
+
+        try {
+            Class<?> c = Test.test();
+            if (!allowed) {
+                throw new RuntimeException("Reflection.getCallerClass should not be allowed");
+            }
+            Class<?> caller = Test.caller();
+            if (c != GetCallerClass.class || caller != c) {
+                throw new RuntimeException("Incorrect caller: " + c);
+            }
+            Test.selfTest();
+        } catch (UnsupportedOperationException e) {
+            if (allowed) throw e;
         }
     }
 
     @sun.reflect.CallerSensitive
     public Class<?> getCallerClass() {
-        // 0: Reflection 1: getCallerClass 2: Temp.test 3: main
+        // 0: Reflection 1: getCallerClass 2: Test.test 3: main
         return sun.reflect.Reflection.getCallerClass(3);
     }
 
-    static class Temp {
+    static class Test {
+        // Returns the caller of this method
         public static Class<?> test() {
             return new GetCallerClass().getCallerClass();
         }
+        @sun.reflect.CallerSensitive
+        public static Class<?> caller() {
+            return sun.reflect.Reflection.getCallerClass();
+        }
+        @sun.reflect.CallerSensitive
+        public static void selfTest() {
+            // 0: Reflection 1: Test.selfTest
+            Class<?> c = sun.reflect.Reflection.getCallerClass(1);
+            if (c != Test.class || caller() != c) {
+                throw new RuntimeException("Incorrect caller: " + c);
+            }
+            Inner1.deep();
+        }
+
+        static class Inner1 {
+            static void deep() {
+                 deeper();
+            }
+            static void deeper() {
+                 Inner2.deepest();
+            }
+            static class Inner2 {
+                static void deepest() {
+                    // 0: Reflection 1: deepest 2: deeper 3: deep 4: Test.selfTest
+                    Class<?> c = sun.reflect.Reflection.getCallerClass(4);
+                    if (c != Test.class) {
+                        throw new RuntimeException("Incorrect caller: " + c);
+                    }
+                }
+            }
+        }
     }
 }