changeset 3207:f32b03dc4e76

Merge
author lana
date Sun, 05 Dec 2010 15:26:16 -0800
parents 0e0bdcd9c101 c80287e4d606
children 51dd8df77406
files
diffstat 28 files changed, 642 insertions(+), 105 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Thu Dec 02 23:44:01 2010 -0800
+++ b/.hgtags	Sun Dec 05 15:26:16 2010 -0800
@@ -93,3 +93,5 @@
 1657ed4e1d86c8aa2028ab5a41f9da1ac4a369f8 jdk7-b116
 3e6726bbf80a4254ecd01051c8ed77ee19325e46 jdk7-b117
 b357910aa04aead2a16b6d6ff395a8df4b51d1dd jdk7-b118
+ecab7eefb8f2326fd90fb632f47f1b6f81e928f8 jdk7-b119
+37d74e29687cf07c2bf9411af58c7e42440855c3 jdk7-b120
--- a/make/sun/xawt/mapfile-vers	Thu Dec 02 23:44:01 2010 -0800
+++ b/make/sun/xawt/mapfile-vers	Sun Dec 05 15:26:16 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	Thu Dec 02 23:44:01 2010 -0800
+++ b/src/share/classes/java/awt/Component.java	Sun Dec 05 15:26:16 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	Thu Dec 02 23:44:01 2010 -0800
+++ b/src/share/classes/java/awt/Container.java	Sun Dec 05 15:26:16 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	Thu Dec 02 23:44:01 2010 -0800
+++ b/src/share/classes/java/awt/ScrollPane.java	Sun Dec 05 15:26:16 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	Thu Dec 02 23:44:01 2010 -0800
+++ b/src/share/classes/java/awt/Window.java	Sun Dec 05 15:26:16 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/javax/swing/GroupLayout.java	Thu Dec 02 23:44:01 2010 -0800
+++ b/src/share/classes/javax/swing/GroupLayout.java	Sun Dec 05 15:26:16 2010 -0800
@@ -653,6 +653,10 @@
      */
     public ParallelGroup createParallelGroup(Alignment alignment,
             boolean resizable){
+        if (alignment == null) {
+            throw new IllegalArgumentException("alignment must be non null");
+        }
+
         if (alignment == Alignment.BASELINE) {
             return new BaselineGroup(resizable);
         }
--- a/src/share/classes/javax/swing/JComponent.java	Thu Dec 02 23:44:01 2010 -0800
+++ b/src/share/classes/javax/swing/JComponent.java	Sun Dec 05 15:26:16 2010 -0800
@@ -4734,6 +4734,8 @@
      * Notifies this component that it now has a parent component.
      * When this method is invoked, the chain of parent components is
      * set up with <code>KeyboardAction</code> event listeners.
+     * This method is called by the toolkit internally and should
+     * not be called directly by programs.
      *
      * @see #registerKeyboardAction
      */
@@ -4750,6 +4752,8 @@
      * Notifies this component that it no longer has a parent component.
      * When this method is invoked, any <code>KeyboardAction</code>s
      * set up in the the chain of parent components are removed.
+     * This method is called by the toolkit internally and should
+     * not be called directly by programs.
      *
      * @see #registerKeyboardAction
      */
--- a/src/share/classes/javax/swing/Popup.java	Thu Dec 02 23:44:01 2010 -0800
+++ b/src/share/classes/javax/swing/Popup.java	Sun Dec 05 15:26:16 2010 -0800
@@ -156,7 +156,8 @@
 
             component.setLocation(ownerX, ownerY);
             component.getContentPane().add(contents, BorderLayout.CENTER);
-            contents.invalidate();
+            component.invalidate();
+            component.validate();
             if(component.isVisible()) {
                 // Do not call pack() if window is not visible to
                 // avoid early native peer creation
--- a/src/share/classes/javax/swing/text/DefaultHighlighter.java	Thu Dec 02 23:44:01 2010 -0800
+++ b/src/share/classes/javax/swing/text/DefaultHighlighter.java	Sun Dec 05 15:26:16 2010 -0800
@@ -113,6 +113,14 @@
      * @exception BadLocationException if the specified location is invalid
      */
     public Object addHighlight(int p0, int p1, Highlighter.HighlightPainter p) throws BadLocationException {
+        if (p0 < 0) {
+            throw new BadLocationException("Invalid start offset", p0);
+        }
+
+        if (p1 < p0) {
+            throw new BadLocationException("Invalid end offset", p1);
+        }
+
         Document doc = component.getDocument();
         HighlightInfo i = (getDrawsLayeredHighlights() &&
                            (p instanceof LayeredHighlighter.LayerPainter)) ?
@@ -217,6 +225,14 @@
      * @exception BadLocationException if the specified location is invalid
      */
     public void changeHighlight(Object tag, int p0, int p1) throws BadLocationException {
+        if (p0 < 0) {
+            throw new BadLocationException("Invalid beginning of the range", p0);
+        }
+
+        if (p1 < p0) {
+            throw new BadLocationException("Invalid end of the range", p1);
+        }
+
         Document doc = component.getDocument();
         if (tag instanceof LayeredHighlightInfo) {
             LayeredHighlightInfo lhi = (LayeredHighlightInfo)tag;
--- a/src/share/classes/sun/awt/UngrabEvent.java	Thu Dec 02 23:44:01 2010 -0800
+++ b/src/share/classes/sun/awt/UngrabEvent.java	Sun Dec 05 15:26:16 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	Thu Dec 02 23:44:01 2010 -0800
+++ b/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java	Sun Dec 05 15:26:16 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	Thu Dec 02 23:44:01 2010 -0800
+++ b/src/solaris/native/sun/awt/awt_MToolkit.c	Sun Dec 05 15:26:16 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	Thu Dec 02 23:44:01 2010 -0800
+++ b/src/solaris/native/sun/awt/fontpath.c	Sun Dec 05 15:26:16 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	Thu Dec 02 23:44:01 2010 -0800
+++ b/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c	Sun Dec 05 15:26:16 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	Thu Dec 02 23:44:01 2010 -0800
+++ b/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.h	Sun Dec 05 15:26:16 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	Thu Dec 02 23:44:01 2010 -0800
+++ b/src/solaris/native/sun/xawt/XWindow.c	Sun Dec 05 15:26:16 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	Thu Dec 02 23:44:01 2010 -0800
+++ b/src/windows/native/sun/windows/awt_Component.cpp	Sun Dec 05 15:26:16 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	Thu Dec 02 23:44:01 2010 -0800
+++ b/src/windows/native/sun/windows/awt_Robot.cpp	Sun Dec 05 15:26:16 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	Sun Dec 05 15:26:16 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	Sun Dec 05 15:26:16 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. ");
+   }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/GroupLayout/6613904/bug6613904.java	Sun Dec 05 15:26:16 2010 -0800
@@ -0,0 +1,65 @@
+/*
+ * 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 6613904
+ * @summary javax.swing.GroupLayout.createParallelGroup(..) doesn't throw IllegalArgumentException for null arg
+ * @author Pavel Porvatov
+ */
+
+import javax.swing.*;
+
+public class bug6613904 {
+    public static void main(String[] args) {
+        SwingUtilities.invokeLater(new Runnable() {
+            public void run() {
+                GroupLayout groupLayout = new GroupLayout(new JPanel());
+
+                try {
+                    groupLayout.createParallelGroup(null);
+
+                    throw new RuntimeException("groupLayout.createParallelGroup(null) doesn't throw IAE");
+                } catch (IllegalArgumentException e) {
+                    // Ok
+                }
+
+                try {
+                    groupLayout.createParallelGroup(null, true);
+
+                    throw new RuntimeException("groupLayout.createParallelGroup(null, true) doesn't throw IAE");
+                } catch (IllegalArgumentException e) {
+                    // Ok
+                }
+
+                try {
+                    groupLayout.createParallelGroup(null, false);
+
+                    throw new RuntimeException("groupLayout.createParallelGroup(null, false) doesn't throw IAE");
+                } catch (IllegalArgumentException e) {
+                    // Ok
+                }
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JPopupMenu/6987844/bug6987844.java	Sun Dec 05 15:26:16 2010 -0800
@@ -0,0 +1,94 @@
+/*
+ * 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 6987844
+ * @summary Incorrect width of JComboBox drop down
+ * @author Alexander Potochkin
+ * @run main bug6987844
+ */
+
+import sun.awt.SunToolkit;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.InputEvent;
+
+public class bug6987844 {
+    static JMenu menu1;
+    static JMenu menu2;
+
+    public static void main(String... args) throws Exception {
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        Robot robot = new Robot();
+        robot.setAutoDelay(200);
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                JFrame frame = new JFrame();
+                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+                JMenuBar bar = new JMenuBar();
+                menu1 = new JMenu("Menu1");
+                menu1.add(new JMenuItem("item"));
+                bar.add(menu1);
+                menu2 = new JMenu("Menu2");
+                menu2.add(new JMenuItem("item"));
+                menu2.add(new JMenuItem("item"));
+                bar.add(menu2);
+
+                frame.setJMenuBar(bar);
+                frame.pack();
+
+                frame.setVisible(true);
+            }
+        });
+        toolkit.realSync();
+        Point point1 = menu1.getLocationOnScreen();
+        Point point2 = menu2.getLocationOnScreen();
+
+        robot.mouseMove(point1.x + 1, point1.y + 1);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+        robot.mouseMove(point2.x + 1, point2.y + 1);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+        robot.mouseMove(point1.x + 1, point1.y + 1);
+        toolkit.realSync();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                Dimension popupSize1 = menu1.getPopupMenu().getSize();
+                Dimension popupSize2 = menu2.getPopupMenu().getSize();
+                if (popupSize1.equals(popupSize2)) {
+                    throw new RuntimeException("First popup unexpedetly changed its size");
+                }
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/text/DefaultHighlighter/6771184/bug6771184.java	Sun Dec 05 15:26:16 2010 -0800
@@ -0,0 +1,86 @@
+/*
+ * 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 6771184
+ * @summary Some methods in text package don't throw BadLocationException when expected
+ * @author Pavel Porvatov
+ */
+
+import javax.swing.*;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Highlighter;
+import javax.swing.text.JTextComponent;
+import java.awt.*;
+
+public class bug6771184 {
+    public static void main(String[] args) {
+        SwingUtilities.invokeLater(new Runnable() {
+            public void run() {
+                JTextArea textArea = new JTextArea("Tested string");
+
+                Highlighter highlighter = textArea.getHighlighter();
+                Highlighter.HighlightPainter myPainter = new Highlighter.HighlightPainter() {
+                    public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent c) {
+                    }
+                };
+
+                int negativeTestedData[][] = {{50, 0},
+                        {-1, 1},
+                        {-5, -4},
+                        {Integer.MAX_VALUE, Integer.MIN_VALUE},
+                        {Integer.MIN_VALUE, Integer.MAX_VALUE},
+                        {Integer.MIN_VALUE, Integer.MIN_VALUE}};
+
+                for (int[] data : negativeTestedData) {
+                    try {
+                        highlighter.addHighlight(data[0], data[1], myPainter);
+
+                        throw new RuntimeException("Method addHighlight() does not throw BadLocationException for (" +
+                                data[0] + ", " + data[1] + ") ");
+                    } catch (BadLocationException e) {
+                        // Ok
+                    }
+
+                    Object objRef;
+
+                    try {
+                        objRef = highlighter.addHighlight(0, 1, myPainter);
+                    } catch (BadLocationException e) {
+                        throw new RuntimeException("highlighter.addHighlight(0, 1, myPainter) throws exception", e);
+                    }
+
+                    try {
+                        highlighter.changeHighlight(objRef, data[0], data[1]);
+
+                        throw new RuntimeException("Method changeHighlight() does not throw BadLocationException for (" +
+                                data[0] + ", " + data[1] + ") ");
+                    } catch (BadLocationException e) {
+                        // Ok
+                    }
+                }
+            }
+        });
+    }
+}
--- a/test/sun/java2d/GdiRendering/InsetClipping.java	Thu Dec 02 23:44:01 2010 -0800
+++ b/test/sun/java2d/GdiRendering/InsetClipping.java	Sun Dec 05 15:26:16 2010 -0800
@@ -85,6 +85,9 @@
             } catch (Exception e) {}
         }
         try {
+            Thread.sleep(2000);
+        } catch (InterruptedException ex) {}
+        try {
             Robot robot = new Robot();
             Point clientLoc = clipTest.getLocationOnScreen();
             Insets insets = clipTest.getInsets();
--- a/test/sun/java2d/SunGraphics2D/DrawImageBilinear.java	Thu Dec 02 23:44:01 2010 -0800
+++ b/test/sun/java2d/SunGraphics2D/DrawImageBilinear.java	Sun Dec 05 15:26:16 2010 -0800
@@ -56,6 +56,9 @@
     private VolatileImage vimg;
     private static volatile BufferedImage capture;
     private static void doCapture(Component test) {
+        try {
+            Thread.sleep(2000);
+        } catch (InterruptedException ex) {}
         // Grab the screen region
         try {
             Robot robot = new Robot();
--- a/test/sun/java2d/SunGraphics2D/SourceClippingBlitTest/SourceClippingBlitTest.java	Thu Dec 02 23:44:01 2010 -0800
+++ b/test/sun/java2d/SunGraphics2D/SourceClippingBlitTest/SourceClippingBlitTest.java	Sun Dec 05 15:26:16 2010 -0800
@@ -204,6 +204,9 @@
         int w = getWidth();
         int h = getHeight();
         Toolkit.getDefaultToolkit().sync();
+        try {
+            Thread.sleep(2000);
+        } catch (InterruptedException ex) {}
         Point p = getLocationOnScreen();
         grabbedBI = robot.createScreenCapture(new Rectangle(p.x, p.y, w, h));
 
--- a/test/sun/java2d/X11SurfaceData/SharedMemoryPixmapsTest/SharedMemoryPixmapsTest.java	Thu Dec 02 23:44:01 2010 -0800
+++ b/test/sun/java2d/X11SurfaceData/SharedMemoryPixmapsTest/SharedMemoryPixmapsTest.java	Sun Dec 05 15:26:16 2010 -0800
@@ -120,6 +120,9 @@
         }
 
         private boolean testRendering() throws RuntimeException {
+            try {
+                Thread.sleep(2000);
+            } catch (InterruptedException ex) {}
             Robot r = null;
             try {
                 r = new Robot();