changeset 3174:60a5739f97c5

Merge
author lana
date Mon, 15 Nov 2010 18:59:32 -0800
parents 809ec4b6eb88 b2e5858615d2
children 311457b67702
files
diffstat 16 files changed, 357 insertions(+), 104 deletions(-) [+]
line wrap: on
line diff
--- a/make/sun/xawt/mapfile-vers	Mon Nov 15 14:16:05 2010 -0800
+++ b/make/sun/xawt/mapfile-vers	Mon Nov 15 18:59:32 2010 -0800
@@ -429,6 +429,7 @@
         Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetClassValue;
         Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetPangoFontName;
 
+        Java_sun_awt_X11_GtkFileDialogPeer_initIDs;
         Java_sun_awt_X11_GtkFileDialogPeer_run;
         Java_sun_awt_X11_GtkFileDialogPeer_quit;
 
--- a/src/share/classes/java/awt/Component.java	Mon Nov 15 14:16:05 2010 -0800
+++ b/src/share/classes/java/awt/Component.java	Mon Nov 15 18:59:32 2010 -0800
@@ -2154,6 +2154,7 @@
      *
      * @param d the dimension specifying the new size
      *          of this component
+     * @throws NullPointerException if {@code d} is {@code null}
      * @see #setSize
      * @see #setBounds
      * @see #invalidate
@@ -2351,6 +2352,7 @@
      * invalidates the component hierarchy.
      *
      * @param r the new bounding rectangle for this component
+     * @throws NullPointerException if {@code r} is {@code null}
      * @see       #getBounds
      * @see       #setLocation(int, int)
      * @see       #setLocation(Point)
@@ -4545,6 +4547,7 @@
      * where the point's <i>x</i> and <i>y</i> coordinates are defined
      * to be relative to the coordinate system of this component.
      * @param     p     the point
+     * @throws    NullPointerException if {@code p} is {@code null}
      * @see       #getComponentAt(Point)
      * @since     JDK1.1
      */
@@ -5879,7 +5882,7 @@
      * @exception ClassCastException if <code>listenerType</code>
      *          doesn't specify a class or interface that implements
      *          <code>java.util.EventListener</code>
-     *
+     * @throws NullPointerException if {@code listenerType} is {@code null}
      * @see #getComponentListeners
      * @see #getFocusListeners
      * @see #getHierarchyListeners
@@ -8038,6 +8041,7 @@
      * Prints a listing of this component to the specified output
      * stream.
      * @param    out   a print stream
+     * @throws   NullPointerException if {@code out} is {@code null}
      * @since    JDK1.0
      */
     public void list(PrintStream out) {
@@ -8050,6 +8054,7 @@
      * @param     out      a print stream
      * @param     indent   number of spaces to indent
      * @see       java.io.PrintStream#println(java.lang.Object)
+     * @throws    NullPointerException if {@code out} is {@code null}
      * @since     JDK1.0
      */
     public void list(PrintStream out, int indent) {
@@ -8062,6 +8067,7 @@
     /**
      * Prints a listing to the specified print writer.
      * @param  out  the print writer to print to
+     * @throws NullPointerException if {@code out} is {@code null}
      * @since JDK1.1
      */
     public void list(PrintWriter out) {
@@ -8073,6 +8079,7 @@
      * the specified print writer.
      * @param out the print writer to print to
      * @param indent the number of spaces to indent
+     * @throws NullPointerException if {@code out} is {@code null}
      * @see       java.io.PrintStream#println(java.lang.Object)
      * @since JDK1.1
      */
--- a/src/share/classes/java/awt/Container.java	Mon Nov 15 14:16:05 2010 -0800
+++ b/src/share/classes/java/awt/Container.java	Mon Nov 15 18:59:32 2010 -0800
@@ -1231,6 +1231,7 @@
      * reflect the changes.
      *
      * @param comp the component to be removed
+     * @throws NullPointerException if {@code comp} is {@code null}
      * @see #add
      * @see #invalidate
      * @see #validate
@@ -2154,6 +2155,7 @@
      * @exception ClassCastException if <code>listenerType</code>
      *          doesn't specify a class or interface that implements
      *          <code>java.util.EventListener</code>
+     * @exception NullPointerException if {@code listenerType} is {@code null}
      *
      * @see #getContainerListeners
      *
@@ -2705,6 +2707,7 @@
      * If there is no child component at the requested point and the
      * point is within the bounds of the container the container itself
      * is returned.
+     * @throws NullPointerException if {@code p} is {@code null}
      * @see Component#contains
      * @see #getComponentAt
      * @since 1.2
@@ -2969,6 +2972,7 @@
      *
      * @param    out      a print stream
      * @param    indent   the number of spaces to indent
+     * @throws   NullPointerException if {@code out} is {@code null}
      * @see      Component#list(java.io.PrintStream, int)
      * @since    JDK1.0
      */
@@ -2995,6 +2999,7 @@
      *
      * @param    out      a print writer
      * @param    indent   the number of spaces to indent
+     * @throws   NullPointerException if {@code out} is {@code null}
      * @see      Component#list(java.io.PrintWriter, int)
      * @since    JDK1.1
      */
--- a/src/share/classes/java/awt/ScrollPane.java	Mon Nov 15 14:16:05 2010 -0800
+++ b/src/share/classes/java/awt/ScrollPane.java	Mon Nov 15 18:59:32 2010 -0800
@@ -377,6 +377,7 @@
      * This is a convenience method which interfaces with the Adjustable
      * objects which represent the state of the scrollbars.
      * @param p the Point representing the position to scroll to
+     * @throws NullPointerException if {@code p} is {@code null}
      */
     public void setScrollPosition(Point p) {
         setScrollPosition(p.x, p.y);
--- a/src/share/classes/java/awt/Window.java	Mon Nov 15 14:16:05 2010 -0800
+++ b/src/share/classes/java/awt/Window.java	Mon Nov 15 18:59:32 2010 -0800
@@ -1888,6 +1888,7 @@
      * @exception ClassCastException if <code>listenerType</code>
      *          doesn't specify a class or interface that implements
      *          <code>java.util.EventListener</code>
+     * @exception NullPointerException if {@code listenerType} is {@code null}
      *
      * @see #getWindowListeners
      * @since 1.3
--- a/src/share/classes/sun/awt/UngrabEvent.java	Mon Nov 15 14:16:05 2010 -0800
+++ b/src/share/classes/sun/awt/UngrabEvent.java	Mon Nov 15 18:59:32 2010 -0800
@@ -40,8 +40,10 @@
  * <p>To listen for this event, install AWTEventListener with {@value sun.awt.SunToolkit#GRAB_EVENT_MASK}
  */
 public class UngrabEvent extends AWTEvent {
+    private final static int UNGRAB_EVENT_ID = 1998;
+
     public UngrabEvent(Component source) {
-        super(source, 0xffff);
+        super(source, UNGRAB_EVENT_ID);
     }
 
     public String toString() {
--- a/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java	Mon Nov 15 14:16:05 2010 -0800
+++ b/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java	Mon Nov 15 18:59:32 2010 -0800
@@ -42,11 +42,19 @@
 
     private FileDialog fd;
 
+    // A pointer to the native GTK FileChooser widget
+    private volatile long widget = 0L;
+
     public GtkFileDialogPeer(FileDialog fd) {
         super((Dialog) fd);
         this.fd = fd;
     }
 
+    private static native void initIDs();
+    static {
+        initIDs();
+    }
+
     private native void run(String title, int mode, String dir, String file,
             FilenameFilter filter, boolean isMultipleMode);
 
--- a/src/solaris/native/sun/awt/awt_MToolkit.c	Mon Nov 15 14:16:05 2010 -0800
+++ b/src/solaris/native/sun/awt/awt_MToolkit.c	Mon Nov 15 18:59:32 2010 -0800
@@ -2773,11 +2773,6 @@
         }
     }
 
-    /*
-    scrollBugWorkAround =
-        (strcmp(XServerVendor(awt_display), "Sun Microsystems, Inc.") == 0
-         && XVendorRelease(awt_display) == 3400);
-    */
     scrollBugWorkAround = TRUE;
 
     /*
--- a/src/solaris/native/sun/awt/fontpath.c	Mon Nov 15 14:16:05 2010 -0800
+++ b/src/solaris/native/sun/awt/fontpath.c	Mon Nov 15 18:59:32 2010 -0800
@@ -557,7 +557,8 @@
 #ifndef HEADLESS
 static int isSunXServer() {
 #ifdef __solaris__
-  return (strcmp("Sun Microsystems, Inc.", ServerVendor(awt_display)) == 0 &&
+  return ((strncmp(ServerVendor(awt_display), "Sun Microsystems, Inc.", 22) == 0) ||
+          (strncmp(ServerVendor(awt_display), "Oracle Corporation", 18) == 0) &&
           VendorRelease(awt_display) >= 6410);
 #else
   return 0;
--- a/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c	Mon Nov 15 14:16:05 2010 -0800
+++ b/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c	Mon Nov 15 18:59:32 2010 -0800
@@ -4,13 +4,29 @@
 #include <string.h>
 #include "gtk2_interface.h"
 #include "sun_awt_X11_GtkFileDialogPeer.h"
+#include "debug_assert.h"
 
 static JavaVM *jvm;
-static GtkWidget *dialog = NULL;
 
 /* To cache some method IDs */
 static jmethodID filenameFilterCallbackMethodID = NULL;
 static jmethodID setFileInternalMethodID = NULL;
+static jfieldID  widgetFieldID = NULL;
+
+JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_initIDs
+(JNIEnv *env, jclass cx)
+{
+    filenameFilterCallbackMethodID = (*env)->GetMethodID(env, cx,
+            "filenameFilterCallback", "(Ljava/lang/String;)Z");
+    DASSERT(filenameFilterCallbackMethodID != NULL);
+
+    setFileInternalMethodID = (*env)->GetMethodID(env, cx,
+            "setFileInternal", "(Ljava/lang/String;[Ljava/lang/String;)V");
+    DASSERT(setFileInternalMethodID != NULL);
+
+    widgetFieldID = (*env)->GetFieldID(env, cx, "widget", "J");
+    DASSERT(widgetFieldID != NULL);
+}
 
 static gboolean filenameFilterCallback(const GtkFileFilterInfo * filter_info, gpointer obj)
 {
@@ -20,30 +36,17 @@
 
     env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
 
-    if (filenameFilterCallbackMethodID == NULL) {
-        cx = (*env)->GetObjectClass(env, (jobject) obj);
-        if (cx == NULL) {
-            JNU_ThrowInternalError(env, "Could not get file filter class");
-            return 0;
-        }
-
-        filenameFilterCallbackMethodID = (*env)->GetMethodID(env, cx,
-                "filenameFilterCallback", "(Ljava/lang/String;)Z");
-        if (filenameFilterCallbackMethodID == NULL) {
-            JNU_ThrowInternalError(env,
-                    "Could not get filenameFilterCallback method id");
-            return 0;
-        }
-    }
-
     filename = (*env)->NewStringUTF(env, filter_info->filename);
 
     return (*env)->CallBooleanMethod(env, obj, filenameFilterCallbackMethodID,
             filename);
 }
 
-static void quit(gboolean isSignalHandler)
+static void quit(JNIEnv * env, jobject jpeer, gboolean isSignalHandler)
 {
+    GtkWidget * dialog = (GtkWidget*)jlong_to_ptr(
+            (*env)->GetLongField(env, jpeer, widgetFieldID));
+
     if (dialog != NULL)
     {
         // Callbacks from GTK signals are made within the GTK lock
@@ -57,7 +60,8 @@
         fp_gtk_widget_destroy (dialog);
 
         fp_gtk_main_quit ();
-        dialog = NULL;
+
+        (*env)->SetLongField(env, jpeer, widgetFieldID, 0);
 
         if (!isSignalHandler) {
             fp_gdk_threads_leave();
@@ -73,7 +77,7 @@
 JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_quit
 (JNIEnv * env, jobject jpeer)
 {
-    quit(FALSE);
+    quit(env, jpeer, FALSE);
 }
 
 /**
@@ -132,24 +136,8 @@
 
     if (responseId == GTK_RESPONSE_ACCEPT) {
         current_folder = fp_gtk_file_chooser_get_current_folder(
-                GTK_FILE_CHOOSER(dialog));
-        filenames = fp_gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
-    }
-
-    if (setFileInternalMethodID == NULL) {
-        cx = (*env)->GetObjectClass(env, (jobject) obj);
-        if (cx == NULL) {
-            JNU_ThrowInternalError(env, "Could not get GTK peer class");
-            return;
-        }
-
-        setFileInternalMethodID = (*env)->GetMethodID(env, cx,
-                "setFileInternal", "(Ljava/lang/String;[Ljava/lang/String;)V");
-        if (setFileInternalMethodID == NULL) {
-            JNU_ThrowInternalError(env,
-                    "Could not get setFileInternalMethodID method id");
-            return;
-        }
+                GTK_FILE_CHOOSER(aDialog));
+        filenames = fp_gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(aDialog));
     }
 
     jcurrent_folder = (*env)->NewStringUTF(env, current_folder);
@@ -159,7 +147,7 @@
             jfilenames);
     fp_g_free(current_folder);
 
-    quit(TRUE);
+    quit(env, (jobject)obj, TRUE);
 }
 
 /*
@@ -172,6 +160,7 @@
         jstring jtitle, jint mode, jstring jdir, jstring jfile,
         jobject jfilter, jboolean multiple)
 {
+    GtkWidget *dialog = NULL;
     GtkFileFilter *filter;
 
     if (jvm == NULL) {
@@ -233,8 +222,12 @@
 
     fp_g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(
             handle_response), jpeer);
+
+    (*env)->SetLongField(env, jpeer, widgetFieldID, ptr_to_jlong(dialog));
+
     fp_gtk_widget_show(dialog);
 
     fp_gtk_main();
     fp_gdk_threads_leave();
 }
+
--- a/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.h	Mon Nov 15 14:16:05 2010 -0800
+++ b/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.h	Mon Nov 15 18:59:32 2010 -0800
@@ -11,6 +11,14 @@
 
 /*
  * Class:     sun_awt_X11_GtkFileDialogPeer
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_initIDs
+(JNIEnv *, jclass);
+
+/*
+ * Class:     sun_awt_X11_GtkFileDialogPeer
  * Method:    run
  * Signature: (Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/io/FilenameFilter;Z;)V
  */
--- a/src/solaris/native/sun/xawt/XWindow.c	Mon Nov 15 14:16:05 2010 -0800
+++ b/src/solaris/native/sun/xawt/XWindow.c	Mon Nov 15 18:59:32 2010 -0800
@@ -766,7 +766,9 @@
 static Boolean
 isXsunServer(XEvent *event) {
     if( awt_ServerDetected ) return awt_IsXsun;
-    if( strncmp( ServerVendor( event->xkey.display ), "Sun Microsystems, Inc.", 32) ) {
+    if( (strncmp( ServerVendor( event->xkey.display ), "Sun Microsystems, Inc.", 22) != 0) &&
+        (strncmp( ServerVendor( event->xkey.display ), "Oracle Corporation", 18) != 0) )
+    {
         awt_ServerDetected = True;
         awt_IsXsun = False;
         return False;
--- a/src/windows/native/sun/windows/awt_Component.cpp	Mon Nov 15 14:16:05 2010 -0800
+++ b/src/windows/native/sun/windows/awt_Component.cpp	Mon Nov 15 18:59:32 2010 -0800
@@ -6084,63 +6084,67 @@
 
 void AwtComponent::_SetRectangularShape(void *param)
 {
-    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-
-    SetRectangularShapeStruct *data = (SetRectangularShapeStruct *)param;
-    jobject self = data->component;
-    jint x1 = data->x1;
-    jint x2 = data->x2;
-    jint y1 = data->y1;
-    jint y2 = data->y2;
-    jobject region = data->region;
-
-    AwtComponent *c = NULL;
-
-    PDATA pData;
-    JNI_CHECK_PEER_GOTO(self, ret);
-
-    c = (AwtComponent *)pData;
-    if (::IsWindow(c->GetHWnd())) {
-        HRGN hRgn = NULL;
-        if (region || x1 || x2 || y1 || y2) {
-            // If all the params are zeros, the shape must be simply reset.
-            // Otherwise, convert it into a region.
-            RGNDATA *pRgnData = NULL;
-            RGNDATAHEADER *pRgnHdr;
-
-            /* reserving memory for the worst case */
-            size_t worstBufferSize = size_t(((x2 - x1) / 2 + 1) * (y2 - y1));
-            pRgnData = (RGNDATA *) safe_Malloc(sizeof(RGNDATAHEADER) +
-                    sizeof(RECT_T) * worstBufferSize);
-            pRgnHdr = (RGNDATAHEADER *) pRgnData;
-
-            pRgnHdr->dwSize = sizeof(RGNDATAHEADER);
-            pRgnHdr->iType = RDH_RECTANGLES;
-            pRgnHdr->nRgnSize = 0;
-            pRgnHdr->rcBound.top = 0;
-            pRgnHdr->rcBound.left = 0;
-            pRgnHdr->rcBound.bottom = LONG(y2 - y1);
-            pRgnHdr->rcBound.right = LONG(x2 - x1);
-
-            RECT_T * pRect = (RECT_T *) (((BYTE *) pRgnData) + sizeof(RGNDATAHEADER));
-            pRgnHdr->nCount = RegionToYXBandedRectangles(env, x1, y1, x2, y2, region, &pRect, worstBufferSize);
-
-            hRgn = ::ExtCreateRegion(NULL,
-                    sizeof(RGNDATAHEADER) + sizeof(RECT_T) * pRgnHdr->nCount, pRgnData);
-
-            free(pRgnData);
+    if (!AwtToolkit::IsMainThread()) {
+        AwtToolkit::GetInstance().InvokeFunction(AwtComponent::_SetRectangularShape, param);
+    } else {
+        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+
+        SetRectangularShapeStruct *data = (SetRectangularShapeStruct *)param;
+        jobject self = data->component;
+        jint x1 = data->x1;
+        jint x2 = data->x2;
+        jint y1 = data->y1;
+        jint y2 = data->y2;
+        jobject region = data->region;
+
+        AwtComponent *c = NULL;
+
+        PDATA pData;
+        JNI_CHECK_PEER_GOTO(self, ret);
+
+        c = (AwtComponent *)pData;
+        if (::IsWindow(c->GetHWnd())) {
+            HRGN hRgn = NULL;
+            if (region || x1 || x2 || y1 || y2) {
+                // If all the params are zeros, the shape must be simply reset.
+                // Otherwise, convert it into a region.
+                RGNDATA *pRgnData = NULL;
+                RGNDATAHEADER *pRgnHdr;
+
+                /* reserving memory for the worst case */
+                size_t worstBufferSize = size_t(((x2 - x1) / 2 + 1) * (y2 - y1));
+                pRgnData = (RGNDATA *) safe_Malloc(sizeof(RGNDATAHEADER) +
+                        sizeof(RECT_T) * worstBufferSize);
+                pRgnHdr = (RGNDATAHEADER *) pRgnData;
+
+                pRgnHdr->dwSize = sizeof(RGNDATAHEADER);
+                pRgnHdr->iType = RDH_RECTANGLES;
+                pRgnHdr->nRgnSize = 0;
+                pRgnHdr->rcBound.top = 0;
+                pRgnHdr->rcBound.left = 0;
+                pRgnHdr->rcBound.bottom = LONG(y2 - y1);
+                pRgnHdr->rcBound.right = LONG(x2 - x1);
+
+                RECT_T * pRect = (RECT_T *) (((BYTE *) pRgnData) + sizeof(RGNDATAHEADER));
+                pRgnHdr->nCount = RegionToYXBandedRectangles(env, x1, y1, x2, y2, region, &pRect, worstBufferSize);
+
+                hRgn = ::ExtCreateRegion(NULL,
+                        sizeof(RGNDATAHEADER) + sizeof(RECT_T) * pRgnHdr->nCount, pRgnData);
+
+                free(pRgnData);
+            }
+
+            ::SetWindowRgn(c->GetHWnd(), hRgn, TRUE);
         }
 
-        ::SetWindowRgn(c->GetHWnd(), hRgn, TRUE);
-    }
-
 ret:
-    env->DeleteGlobalRef(self);
-    if (region) {
-        env->DeleteGlobalRef(region);
-    }
-
-    delete data;
+        env->DeleteGlobalRef(self);
+        if (region) {
+            env->DeleteGlobalRef(region);
+        }
+
+        delete data;
+    }
 }
 
 void AwtComponent::_SetZOrder(void *param) {
--- a/src/windows/native/sun/windows/awt_Robot.cpp	Mon Nov 15 14:16:05 2010 -0800
+++ b/src/windows/native/sun/windows/awt_Robot.cpp	Mon Nov 15 18:59:32 2010 -0800
@@ -194,9 +194,9 @@
 
 jint AwtRobot::GetRGBPixel( jint x, jint y)
 {
-    HDC hdc = GetDC(NULL);
+    HDC hdc = ::CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
     COLORREF ref = ::GetPixel( hdc, x, y );
-    ReleaseDC(NULL,hdc);
+    ::DeleteDC(hdc);
     jint value = WinToJavaPixel(GetRValue(ref), GetGValue(ref), GetBValue(ref));
     return value;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java	Mon Nov 15 18:59:32 2010 -0800
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2010, 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 6988428
+  @summary Tests whether shape is always set
+  @author anthony.petrov@oracle.com: area=awt.toplevel
+  @run main ShapeNotSetSometimes
+*/
+
+
+import java.awt.*;
+import java.awt.event.InputEvent;
+import java.awt.geom.*;
+
+
+public class ShapeNotSetSometimes {
+
+    private Frame backgroundFrame;
+    private Frame window;
+    private static final Color BACKGROUND_COLOR = Color.BLUE;
+    private Shape shape;
+    private int[][] pointsToCheck;
+
+    private static Robot robot;
+
+    public ShapeNotSetSometimes() throws Exception {
+        EventQueue.invokeAndWait(new Runnable() {
+            public void run() {
+                initializeGUI();
+            }
+        });
+    }
+
+    private void initializeGUI() {
+        backgroundFrame = new BackgroundFrame();
+        backgroundFrame.setUndecorated(true);
+        backgroundFrame.setSize(300, 300);
+        backgroundFrame.setLocation(20, 400);
+        backgroundFrame.setVisible(true);
+
+        shape = null;
+        String shape_name = null;
+        Area a;
+        GeneralPath gp;
+        shape_name = "Rounded-corners";
+        a = new Area();
+        a.add(new Area(new Rectangle2D.Float(50, 0, 100, 150)));
+        a.add(new Area(new Rectangle2D.Float(0, 50, 200, 50)));
+        a.add(new Area(new Ellipse2D.Float(0, 0, 100, 100)));
+        a.add(new Area(new Ellipse2D.Float(0, 50, 100, 100)));
+        a.add(new Area(new Ellipse2D.Float(100, 0, 100, 100)));
+        a.add(new Area(new Ellipse2D.Float(100, 50, 100, 100)));
+        shape = a;
+        pointsToCheck = new int[][] {
+            // inside shape
+            {106, 86}, {96, 38}, {76, 107}, {180, 25}, {24, 105},
+            {196, 77}, {165, 50}, {14, 113}, {89, 132}, {167, 117},
+            // outside shape
+            {165, 196}, {191, 163}, {146, 185}, {61, 170}, {148, 171},
+            {82, 172}, {186, 11}, {199, 141}, {13, 173}, {187, 3}
+        };
+
+        window = new TestFrame();
+        window.setUndecorated(true);
+        window.setSize(200, 200);
+        window.setLocation(70, 450);
+        window.setShape(shape);
+        window.setVisible(true);
+
+        System.out.println("Checking " + window.getClass().getSuperclass().getName() + " with " + shape_name + " shape (" + window.getShape() + ")...");
+    }
+
+    class BackgroundFrame extends Frame {
+
+        @Override
+        public void paint(Graphics g) {
+
+            g.setColor(BACKGROUND_COLOR);
+            g.fillRect(0, 0, 300, 300);
+
+            super.paint(g);
+        }
+    }
+
+    class TestFrame extends Frame {
+
+        @Override
+        public void paint(Graphics g) {
+
+            g.setColor(Color.WHITE);
+            g.fillRect(0, 0, 200, 200);
+
+            super.paint(g);
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        robot = new Robot();
+
+        for(int i = 0; i < 100; i++) {
+            System.out.println("Attempt " + i);
+            new ShapeNotSetSometimes().doTest();
+        }
+    }
+
+    private void doTest() throws Exception {
+        Point wls = backgroundFrame.getLocationOnScreen();
+
+        robot.mouseMove(wls.x + 5, wls.y + 5);
+        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+        robot.delay(10);
+        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+        robot.delay(500);
+
+        EventQueue.invokeAndWait(new Runnable() {
+            public void run() {
+                window.requestFocus();
+            }
+        });
+
+        robot.waitForIdle();
+        try {
+            Thread.sleep(300);
+        } catch (InterruptedException e) {
+            // ignore this one
+        }
+
+        // check transparency
+        final int COUNT_TARGET = 10;
+
+        // checking outside points only
+        for(int i = COUNT_TARGET; i < COUNT_TARGET * 2; i++) {
+            int x = pointsToCheck[i][0];
+            int y = pointsToCheck[i][1];
+            boolean inside = i < COUNT_TARGET;
+            Color c = robot.getPixelColor(window.getX() + x, window.getY() + y);
+            System.out.println("checking " + x + ", " + y + ", color = " + c);
+            if (inside && BACKGROUND_COLOR.equals(c) || !inside && !BACKGROUND_COLOR.equals(c)) {
+                System.out.println("window.getX() = " + window.getX() + ", window.getY() = " + window.getY());
+                System.err.println("Checking for transparency failed: point: " +
+                        (window.getX() + x) + ", " + (window.getY() + y) +
+                        ", color = " + c + (inside ? " is of un" : " is not of ") +
+                        "expected background color " + BACKGROUND_COLOR);
+                throw new RuntimeException("Test failed. The shape has not been applied.");
+            }
+        }
+
+        EventQueue.invokeAndWait(new Runnable() {
+            public void run() {
+                backgroundFrame.dispose();
+                window.dispose();
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/event/OtherEvents/UngrabID/UngrabID.java	Mon Nov 15 18:59:32 2010 -0800
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2010, 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.
+ */
+
+/*
+  @test
+  @bug 6960516
+  @summary check if the ungrab event has the ID < AWTEvent.RESERVED_ID_MAX
+  @author Andrei Dmitriev : area=awt.event
+  @run main UngrabID
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+
+public class UngrabID {
+    public static void main(String[] args){
+        Frame f = new Frame("Dummy");
+        sun.awt.UngrabEvent event = new sun.awt.UngrabEvent(f);
+        if (event.getID() > AWTEvent.RESERVED_ID_MAX) {
+                System.out.println( " Event ID : "+event.getID() + " " + event.toString());
+                throw new RuntimeException(" Ungrab Event ID should be less than AWTEvent.RESERVED_ID_MAX ("+AWTEvent.RESERVED_ID_MAX+"). Actual value : "+event.getID() + " Event:" + event.toString());
+        }
+        System.out.println("Test passed. ");
+   }
+}