Merge
authorlana
Fri, 14 Sep 2012 14:10:01 -0700
changeset 13780 ae50a0e73148
parent 13779 011727a60840 (diff)
parent 13701 8a4d13c013c2 (current diff)
child 13781 bf3d53b1fba7
Merge
--- a/jdk/src/macosx/classes/sun/awt/SunToolkitSubclass.java	Thu Sep 13 13:16:04 2012 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.awt;
-
-// This class exists only so we can flush the PostEventQueue for the right AppContext
-// The default flushPendingEvents only flushes the thread-local context, which is wrong.
-// c.f. 3746956
-public abstract class SunToolkitSubclass extends SunToolkit {
-    public static void flushPendingEvents(AppContext appContext) {
-        flushLock.lock();
-        PostEventQueue postEventQueue = (PostEventQueue)appContext.get("PostEventQueue");
-        if (postEventQueue != null) {
-            postEventQueue.flush();
-        }
-        flushLock.unlock();
-    }
-}
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java	Thu Sep 13 13:16:04 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java	Fri Sep 14 14:10:01 2012 -0700
@@ -134,7 +134,7 @@
         boolean postsTyped = false;
 
         char testChar = KeyEvent.CHAR_UNDEFINED;
-        char testDeadChar = 0;
+        boolean isDeadChar = (chars!= null && chars.length() == 0);
 
         if (isFlagsChangedEvent) {
             int[] in = new int[] {modifierFlags, keyCode};
@@ -150,14 +150,18 @@
                 testChar = chars.charAt(0);
             }
 
-            int[] in = new int[] {testChar, testDeadChar, modifierFlags, keyCode};
-            int[] out = new int[2]; // [jkeyCode, jkeyLocation]
+            int[] in = new int[] {testChar, isDeadChar ? 1 : 0, modifierFlags, keyCode};
+            int[] out = new int[3]; // [jkeyCode, jkeyLocation, deadChar]
 
             postsTyped = NSEvent.nsToJavaKeyInfo(in, out);
             if (!postsTyped) {
                 testChar = KeyEvent.CHAR_UNDEFINED;
             }
 
+            if(isDeadChar){
+                testChar = (char) out[2];
+            }
+
             jkeyCode = out[0];
             jkeyLocation = out[1];
             jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) :
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Thu Sep 13 13:16:04 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Fri Sep 14 14:10:01 2012 -0700
@@ -536,7 +536,7 @@
             SunToolkit.postEvent(appContext, invocationEvent);
 
             // 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock
-            sun.awt.SunToolkitSubclass.flushPendingEvents(appContext);
+            SunToolkit.flushPendingEvents(appContext);
         } else {
             // This should be the equivalent to EventQueue.invokeAndWait
             ((LWCToolkit)Toolkit.getDefaultToolkit()).getSystemEventQueueForInvokeAndWait().postEvent(invocationEvent);
@@ -561,7 +561,7 @@
             SunToolkit.postEvent(appContext, invocationEvent);
 
             // 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock
-            sun.awt.SunToolkitSubclass.flushPendingEvents(appContext);
+            SunToolkit.flushPendingEvents(appContext);
         } else {
             // This should be the equivalent to EventQueue.invokeAndWait
             ((LWCToolkit)Toolkit.getDefaultToolkit()).getSystemEventQueueForInvokeAndWait().postEvent(invocationEvent);
--- a/jdk/src/macosx/native/sun/awt/AWTEvent.m	Thu Sep 13 13:16:04 2012 -0700
+++ b/jdk/src/macosx/native/sun/awt/AWTEvent.m	Fri Sep 14 14:10:01 2012 -0700
@@ -26,6 +26,7 @@
 #import <JavaNativeFoundation/JavaNativeFoundation.h>
 #import <JavaRuntimeSupport/JavaRuntimeSupport.h>
 #import <sys/time.h>
+#include <Carbon/Carbon.h>
 
 #import "LWCToolkit.h"
 #import "ThreadUtilities.h"
@@ -371,26 +372,67 @@
     return nsChar;
 }
 
+static unichar NsGetDeadKeyChar(unsigned short keyCode)
+{
+    TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
+    CFDataRef uchr = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData);
+    const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout*)CFDataGetBytePtr(uchr);
+    // Carbon modifiers should be used instead of NSEvent modifiers
+    UInt32 modifierKeyState = (GetCurrentEventKeyModifiers() >> 8) & 0xFF;
+
+    if (keyboardLayout) {
+        UInt32 deadKeyState = 0;
+        UniCharCount maxStringLength = 255;
+        UniCharCount actualStringLength = 0;
+        UniChar unicodeString[maxStringLength];
+
+        // get the deadKeyState
+        OSStatus status = UCKeyTranslate(keyboardLayout,
+                                         keyCode, kUCKeyActionDown, modifierKeyState,
+                                         LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit,
+                                         &deadKeyState,
+                                         maxStringLength,
+                                         &actualStringLength, unicodeString);
+
+        if (status == noErr && deadKeyState != 0) {
+            // Press SPACE to get the dead key char
+            status = UCKeyTranslate(keyboardLayout,
+                                    kVK_Space, kUCKeyActionDown, 0,
+                                    LMGetKbdType(), 0,
+                                    &deadKeyState,
+                                    maxStringLength,
+                                    &actualStringLength, unicodeString);
+
+            if (status == noErr && actualStringLength > 0) {
+                return unicodeString[0];
+            }
+        }
+    }
+    return 0;
+}
+
 /*
  * This is the function that uses the table above to take incoming
  * NSEvent keyCodes and translate to the Java virtual key code.
  */
 static void
-NsCharToJavaVirtualKeyCode(unichar ch, unichar deadChar,
+NsCharToJavaVirtualKeyCode(unichar ch, BOOL isDeadChar,
                            NSUInteger flags, unsigned short key,
-                           jint *keyCode, jint *keyLocation, BOOL *postsTyped)
+                           jint *keyCode, jint *keyLocation, BOOL *postsTyped, unichar *deadChar)
 {
     static size_t size = sizeof(keyTable) / sizeof(struct _key);
     NSInteger offset;
 
-    if (deadChar) {
+    if (isDeadChar) {
+        unichar testDeadChar = NsGetDeadKeyChar(key);
         const struct CharToVKEntry *map;
         for (map = charToDeadVKTable; map->c != 0; ++map) {
-            if (deadChar == map->c) {
+            if (testDeadChar == map->c) {
                 *keyCode = map->javaKey;
                 *postsTyped = NO;
                 // TODO: use UNKNOWN here?
                 *keyLocation = java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN;
+                *deadChar = testDeadChar;
                 return;
             }
         }
@@ -615,20 +657,22 @@
 
     // in  = [testChar, testDeadChar, modifierFlags, keyCode]
     jchar testChar = (jchar)data[0];
-    jchar testDeadChar = (jchar)data[1];
+    BOOL isDeadChar = (data[1] != 0);
     jint modifierFlags = data[2];
     jshort keyCode = (jshort)data[3];
 
     jint jkeyCode = java_awt_event_KeyEvent_VK_UNDEFINED;
     jint jkeyLocation = java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN;
+    jchar testDeadChar = 0;
 
-    NsCharToJavaVirtualKeyCode((unichar)testChar, (unichar)testDeadChar,
+    NsCharToJavaVirtualKeyCode((unichar)testChar, isDeadChar,
                                (NSUInteger)modifierFlags, (unsigned short)keyCode,
-                               &jkeyCode, &jkeyLocation, &postsTyped);
+                               &jkeyCode, &jkeyLocation, &postsTyped, &testDeadChar);
 
     // out = [jkeyCode, jkeyLocation];
     (*env)->SetIntArrayRegion(env, outData, 0, 1, &jkeyCode);
     (*env)->SetIntArrayRegion(env, outData, 1, 1, &jkeyLocation);
+    (*env)->SetIntArrayRegion(env, outData, 2, 1, (jint *)&testDeadChar);
 
     (*env)->ReleaseIntArrayElements(env, inData, data, 0);
 
@@ -685,12 +729,12 @@
 (JNIEnv *env, jclass cls, char nsChar, jint modifierFlags)
 {
     jchar javaChar = 0;
-    
+
 JNF_COCOA_ENTER(env);
-    
+
     javaChar = NsCharToJavaChar(nsChar, modifierFlags);
 
 JNF_COCOA_EXIT(env);
-    
+
     return javaChar;
 }
--- a/jdk/src/macosx/native/sun/awt/AWTWindow.m	Thu Sep 13 13:16:04 2012 -0700
+++ b/jdk/src/macosx/native/sun/awt/AWTWindow.m	Fri Sep 14 14:10:01 2012 -0700
@@ -178,8 +178,8 @@
         [self.nsWindow setDocumentEdited:IS(bits, DOCUMENT_MODIFIED)];
     }
 
-    if ([self.nsWindow respondsToSelector:@selector(toggleFullScreen:)]) {
-        if (IS(mask, FULLSCREENABLE)) {
+    if (IS(mask, FULLSCREENABLE) && [self.nsWindow respondsToSelector:@selector(toggleFullScreen:)]) {
+        if (IS(bits, FULLSCREENABLE)) {
             [self.nsWindow setCollectionBehavior:(1 << 7) /*NSWindowCollectionBehaviorFullScreenPrimary*/];
         } else {
             [self.nsWindow setCollectionBehavior:NSWindowCollectionBehaviorDefault];
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Thu Sep 13 13:16:04 2012 -0700
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Fri Sep 14 14:10:01 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -644,6 +644,9 @@
                    "released SPACE", "released"
                  }),
 
+            "Caret.width",
+                  new DesktopProperty("win.caret.width", null),
+
             "CheckBox.font", ControlFont,
             "CheckBox.interiorBackground", WindowBackgroundColor,
             "CheckBox.background", ControlBackgroundColor,
--- a/jdk/src/share/classes/java/awt/EventQueue.java	Thu Sep 13 13:16:04 2012 -0700
+++ b/jdk/src/share/classes/java/awt/EventQueue.java	Fri Sep 14 14:10:01 2012 -0700
@@ -1047,6 +1047,10 @@
 
     final boolean detachDispatchThread(EventDispatchThread edt, boolean forceDetach) {
         /*
+         * Minimize discard possibility for non-posted events
+         */
+        SunToolkit.flushPendingEvents();
+        /*
          * This synchronized block is to secure that the event dispatch
          * thread won't die in the middle of posting a new event to the
          * associated event queue. It is important because we notify
@@ -1060,11 +1064,8 @@
                 /*
                  * Don't detach the thread if any events are pending. Not
                  * sure if it's a possible scenario, though.
-                 *
-                 * Fix for 4648733. Check both the associated java event
-                 * queue and the PostEventQueue.
                  */
-                if (!forceDetach && (peekEvent() != null) || !SunToolkit.isPostEventQueueEmpty()) {
+                if (!forceDetach && (peekEvent() != null)) {
                     return false;
                 }
                 dispatchThread = null;
--- a/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java	Thu Sep 13 13:16:04 2012 -0700
+++ b/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java	Fri Sep 14 14:10:01 2012 -0700
@@ -495,6 +495,16 @@
         indexedReadMethodName = old.indexedReadMethodName;
     }
 
+    void updateGenericsFor(Class<?> type) {
+        super.updateGenericsFor(type);
+        try {
+            setIndexedPropertyType(findIndexedPropertyType(getIndexedReadMethod0(), getIndexedWriteMethod0()));
+        }
+        catch (IntrospectionException exception) {
+            setIndexedPropertyType(null);
+        }
+    }
+
     /**
      * Returns a hash code value for the object.
      * See {@link java.lang.Object#hashCode} for a complete description.
--- a/jdk/src/share/classes/java/beans/Introspector.java	Thu Sep 13 13:16:04 2012 -0700
+++ b/jdk/src/share/classes/java/beans/Introspector.java	Fri Sep 14 14:10:01 2012 -0700
@@ -574,26 +574,25 @@
             // replace existing property descriptor
             // only if we have types to resolve
             // in the context of this.beanClass
-            try {
-                String name = pd.getName();
-                Method read = pd.getReadMethod();
-                Method write = pd.getWriteMethod();
-                boolean cls = true;
-                if (read != null) cls = cls && read.getGenericReturnType() instanceof Class;
-                if (write != null) cls = cls && write.getGenericParameterTypes()[0] instanceof Class;
-                if (pd instanceof IndexedPropertyDescriptor) {
-                    IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor)pd;
-                    Method readI = ipd.getIndexedReadMethod();
-                    Method writeI = ipd.getIndexedWriteMethod();
-                    if (readI != null) cls = cls && readI.getGenericReturnType() instanceof Class;
-                    if (writeI != null) cls = cls && writeI.getGenericParameterTypes()[1] instanceof Class;
-                    if (!cls) {
-                        pd = new IndexedPropertyDescriptor(this.beanClass, name, read, write, readI, writeI);
-                    }
-                } else if (!cls) {
-                    pd = new PropertyDescriptor(this.beanClass, name, read, write);
+            Method read = pd.getReadMethod();
+            Method write = pd.getWriteMethod();
+            boolean cls = true;
+            if (read != null) cls = cls && read.getGenericReturnType() instanceof Class;
+            if (write != null) cls = cls && write.getGenericParameterTypes()[0] instanceof Class;
+            if (pd instanceof IndexedPropertyDescriptor) {
+                IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
+                Method readI = ipd.getIndexedReadMethod();
+                Method writeI = ipd.getIndexedWriteMethod();
+                if (readI != null) cls = cls && readI.getGenericReturnType() instanceof Class;
+                if (writeI != null) cls = cls && writeI.getGenericParameterTypes()[1] instanceof Class;
+                if (!cls) {
+                    pd = new IndexedPropertyDescriptor(ipd);
+                    pd.updateGenericsFor(this.beanClass);
                 }
-            } catch ( IntrospectionException e ) {
+            }
+            else if (!cls) {
+                pd = new PropertyDescriptor(pd);
+                pd.updateGenericsFor(this.beanClass);
             }
         }
         list.add(pd);
--- a/jdk/src/share/classes/java/beans/PropertyDescriptor.java	Thu Sep 13 13:16:04 2012 -0700
+++ b/jdk/src/share/classes/java/beans/PropertyDescriptor.java	Fri Sep 14 14:10:01 2012 -0700
@@ -632,6 +632,16 @@
         constrained = old.constrained;
     }
 
+    void updateGenericsFor(Class<?> type) {
+        setClass0(type);
+        try {
+            setPropertyType(findPropertyType(getReadMethod0(), getWriteMethod0()));
+        }
+        catch (IntrospectionException exception) {
+            setPropertyType(null);
+        }
+    }
+
     /**
      * Returns the property type that corresponds to the read and write method.
      * The type precedence is given to the readMethod.
--- a/jdk/src/share/classes/javax/swing/text/DefaultCaret.java	Thu Sep 13 13:16:04 2012 -0700
+++ b/jdk/src/share/classes/javax/swing/text/DefaultCaret.java	Fri Sep 14 14:10:01 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1503,9 +1503,14 @@
 
         if (caretWidth > -1) {
             return caretWidth;
+        } else {
+            Object property = UIManager.get("Caret.width");
+            if (property instanceof Integer) {
+                return ((Integer) property).intValue();
+            } else {
+                return 1;
+            }
         }
-
-        return 1;
     }
 
     // --- serialization ---------------------------------------------
--- a/jdk/src/share/classes/sun/awt/SunToolkit.java	Thu Sep 13 13:16:04 2012 -0700
+++ b/jdk/src/share/classes/sun/awt/SunToolkit.java	Fri Sep 14 14:10:01 2012 -0700
@@ -506,40 +506,25 @@
         postEvent(targetToAppContext(e.getSource()), pe);
     }
 
-    protected static final Lock flushLock = new ReentrantLock();
-    private static boolean isFlushingPendingEvents = false;
-
     /*
      * Flush any pending events which haven't been posted to the AWT
      * EventQueue yet.
      */
     public static void flushPendingEvents()  {
-        flushLock.lock();
-        try {
-            // Don't call flushPendingEvents() recursively
-            if (!isFlushingPendingEvents) {
-                isFlushingPendingEvents = true;
-                AppContext appContext = AppContext.getAppContext();
-                PostEventQueue postEventQueue =
-                    (PostEventQueue)appContext.get(POST_EVENT_QUEUE_KEY);
-                if (postEventQueue != null) {
-                    postEventQueue.flush();
-                }
-            }
-        } finally {
-            isFlushingPendingEvents = false;
-            flushLock.unlock();
-        }
+        AppContext appContext = AppContext.getAppContext();
+        flushPendingEvents(appContext);
     }
 
-    public static boolean isPostEventQueueEmpty()  {
-        AppContext appContext = AppContext.getAppContext();
+    /*
+     * Flush the PostEventQueue for the right AppContext.
+     * The default flushPendingEvents only flushes the thread-local context,
+     * which is not always correct, c.f. 3746956
+     */
+    public static void flushPendingEvents(AppContext appContext) {
         PostEventQueue postEventQueue =
-            (PostEventQueue)appContext.get(POST_EVENT_QUEUE_KEY);
+                (PostEventQueue)appContext.get(POST_EVENT_QUEUE_KEY);
         if (postEventQueue != null) {
-            return postEventQueue.noEvents();
-        } else {
-            return true;
+            postEventQueue.flush();
         }
     }
 
@@ -2045,17 +2030,12 @@
     private EventQueueItem queueTail = null;
     private final EventQueue eventQueue;
 
-    // For the case when queue is cleared but events are not posted
-    private volatile boolean isFlushing = false;
+    private Thread flushThread = null;
 
     PostEventQueue(EventQueue eq) {
         eventQueue = eq;
     }
 
-    public synchronized boolean noEvents() {
-        return queueHead == null && !isFlushing;
-    }
-
     /*
      * Continually post pending AWTEvents to the Java EventQueue. The method
      * is synchronized to ensure the flush is completed before a new event
@@ -2066,20 +2046,48 @@
      * potentially lead to deadlock
      */
     public void flush() {
-        EventQueueItem tempQueue;
-        synchronized (this) {
-            tempQueue = queueHead;
-            queueHead = queueTail = null;
-            isFlushing = true;
-        }
+
+        Thread newThread = Thread.currentThread();
+
         try {
-            while (tempQueue != null) {
-                eventQueue.postEvent(tempQueue.event);
-                tempQueue = tempQueue.next;
+            EventQueueItem tempQueue;
+            synchronized (this) {
+                // Avoid method recursion
+                if (newThread == flushThread) {
+                    return;
+                }
+                // Wait for other threads' flushing
+                while (flushThread != null) {
+                    wait();
+                }
+                // Skip everything if queue is empty
+                if (queueHead == null) {
+                    return;
+                }
+                // Remember flushing thread
+                flushThread = newThread;
+
+                tempQueue = queueHead;
+                queueHead = queueTail = null;
+            }
+            try {
+                while (tempQueue != null) {
+                    eventQueue.postEvent(tempQueue.event);
+                    tempQueue = tempQueue.next;
+                }
+            }
+            finally {
+                // Only the flushing thread can get here
+                synchronized (this) {
+                    // Forget flushing thread, inform other pending threads
+                    flushThread = null;
+                    notifyAll();
+                }
             }
         }
-        finally {
-            isFlushing = false;
+        catch (InterruptedException e) {
+            // Couldn't allow exception go up, so at least recover the flag
+            newThread.interrupt();
         }
     }
 
--- a/jdk/src/share/classes/sun/awt/image/VolatileSurfaceManager.java	Thu Sep 13 13:16:04 2012 -0700
+++ b/jdk/src/share/classes/sun/awt/image/VolatileSurfaceManager.java	Fri Sep 14 14:10:01 2012 -0700
@@ -333,11 +333,12 @@
             // using a SurfaceData that was created in a different
             // display mode.
             sdBackup = null;
-            sdCurrent = getBackupSurface();
             // Now, invalidate the old hardware-based SurfaceData
+            // Note that getBackupSurface may set sdAccel to null so we have to invalidate it before
             SurfaceData oldData = sdAccel;
             sdAccel = null;
             oldData.invalidate();
+            sdCurrent = getBackupSurface();
         }
         // Update graphicsConfig for the vImg in case it changed due to
         // this display change event
--- a/jdk/src/windows/classes/sun/java2d/ScreenUpdateManager.java	Thu Sep 13 13:16:04 2012 -0700
+++ b/jdk/src/windows/classes/sun/java2d/ScreenUpdateManager.java	Fri Sep 14 14:10:01 2012 -0700
@@ -110,6 +110,11 @@
     public SurfaceData getReplacementScreenSurface(WComponentPeer peer,
                                                    SurfaceData oldsd)
     {
+        SurfaceData surfaceData = peer.getSurfaceData();
+        if (surfaceData.isValid()) {
+            return surfaceData;
+        }
+        peer.replaceSurfaceData();
         return peer.getSurfaceData();
     }
 
--- a/jdk/src/windows/native/sun/windows/awt_DesktopProperties.cpp	Thu Sep 13 13:16:04 2012 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_DesktopProperties.cpp	Fri Sep 14 14:10:01 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -70,6 +70,7 @@
     GetNonClientParameters();
     GetIconParameters();
     GetColorParameters();
+    GetCaretParameters();
     GetOtherParameters();
     GetSoundEvents();
     GetSystemProperties();
@@ -636,6 +637,10 @@
     SetSoundProperty(TEXT("win.sound.start"), TEXT("SystemStart"));
 }
 
+void AwtDesktopProperties::GetCaretParameters() {
+    SetIntegerProperty(TEXT("win.caret.width"), GetIntegerParameter(SPI_GETCARETWIDTH));
+}
+
 BOOL AwtDesktopProperties::GetBooleanParameter(UINT spi) {
     BOOL        flag;
     SystemParametersInfo(spi, 0, &flag, 0);
--- a/jdk/src/windows/native/sun/windows/awt_DesktopProperties.h	Thu Sep 13 13:16:04 2012 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_DesktopProperties.h	Fri Sep 14 14:10:01 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -64,6 +64,7 @@
         void GetColorParameters();
         void GetOtherParameters();
         void GetSoundEvents();
+        void GetCaretParameters();
 
         static BOOL GetBooleanParameter(UINT spi);
         static UINT GetIntegerParameter(UINT spi);
--- a/jdk/src/windows/native/sun/windows/awt_TextField.cpp	Thu Sep 13 13:16:04 2012 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_TextField.cpp	Fri Sep 14 14:10:01 2012 -0700
@@ -75,6 +75,7 @@
 AwtTextField::HandleEvent(MSG *msg, BOOL synthetic)
 {
     MsgRouting returnVal;
+    BOOL systemBeeperEnabled = FALSE;
     /*
      * RichEdit 1.0 control starts internal message loop if the
      * left mouse button is pressed while the cursor is not over
@@ -217,7 +218,34 @@
         }
         delete msg;
         return mrConsume;
+    } else if (msg->message == WM_KEYDOWN) {
+        UINT virtualKey = (UINT) msg->wParam;
+
+        switch(virtualKey){
+          case VK_RETURN:
+          case VK_UP:
+          case VK_DOWN:
+          case VK_LEFT:
+          case VK_RIGHT:
+          case VK_DELETE:
+          case VK_BACK:
+              SystemParametersInfo(SPI_GETBEEP, 0, &systemBeeperEnabled, 0);
+              if(systemBeeperEnabled){
+                  // disable system beeper for the RICHEDIT control to be compatible
+                  // with the EDIT control behaviour
+                  SystemParametersInfo(SPI_SETBEEP, 0, NULL, 0);
+              }
+              break;
+          }
+    } else if (msg->message == WM_SETTINGCHANGE) {
+        if (msg->wParam == SPI_SETBEEP) {
+            SystemParametersInfo(SPI_GETBEEP, 0, &systemBeeperEnabled, 0);
+            if(systemBeeperEnabled){
+                SystemParametersInfo(SPI_SETBEEP, 1, NULL, 0);
+            }
+        }
     }
+
     /*
      * Store the 'synthetic' parameter so that the WM_PASTE security check
      * happens only for synthetic events.
@@ -226,6 +254,10 @@
     returnVal = AwtComponent::HandleEvent(msg, synthetic);
     m_synthetic = FALSE;
 
+    if(systemBeeperEnabled){
+        SystemParametersInfo(SPI_SETBEEP, 1, NULL, 0);
+    }
+
     return returnVal;
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/EventQueue/PostEventOrderingTest/PostEventOrderingTest.java	Fri Sep 14 14:10:01 2012 -0700
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test PostEventOrderingTest.java
+ * @bug 4171596 6699589
+ * @summary Checks that the posting of events between the PostEventQueue
+ * @summary and the EventQueue maintains proper ordering.
+ * @run main PostEventOrderingTest
+ * @author fredx
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import sun.awt.AppContext;
+import sun.awt.SunToolkit;
+
+public class PostEventOrderingTest {
+    static boolean testPassed = true;
+
+    public static void main(String[] args) throws Throwable {
+        EventQueue q = Toolkit.getDefaultToolkit().getSystemEventQueue();
+        for (int i = 0; i < 100; i++) {
+            for (int j = 0; j < 100; j++) {
+                q.postEvent(new PostActionEvent());
+                for (int k = 0; k < 10; k++) {
+                    SunToolkit.postEvent(AppContext.getAppContext(), new PostActionEvent());
+                }
+            }
+            for (int k = 0; k < 100; k++) {
+                SunToolkit.postEvent(AppContext.getAppContext(), new PostActionEvent());
+            }
+        }
+
+        for (;;) {
+            Thread.currentThread().sleep(100);
+            if (q.peekEvent() == null) {
+                Thread.currentThread().sleep(100);
+                if (q.peekEvent() == null)
+                    break;
+            }
+        }
+
+        if (!testPassed) {
+            throw new Exception("PostEventOrderingTest FAILED -- events dispatched out of order.");
+        } else {
+            System.out.println("PostEventOrderingTest passed!");
+        }
+    }
+}
+
+class PostActionEvent extends ActionEvent implements ActiveEvent {
+    static int counter = 0;
+    static int mostRecent = -1;
+
+    int myval;
+
+    public PostActionEvent() {
+        super("", ACTION_PERFORMED, "" + counter);
+        myval = counter++;
+    }
+
+    public void dispatch() {
+        //System.out.println("myval = "+myval+", mostRecent = "+mostRecent+", diff = "+(myval-mostRecent)+".");
+        if ((myval - mostRecent) != 1)
+            PostEventOrderingTest.testPassed = false;
+        mostRecent = myval;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/event/KeyEvent/DeadKey/deadKeyMacOSX.java	Fri Sep 14 14:10:01 2012 -0700
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 7196547
+ * @summary Dead Key implementation for KeyEvent on Mac OS X
+ * @author alexandr.scherbatiy area=awt.event
+ * @run main deadKeyMacOSX
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.event.KeyEvent;
+import sun.awt.OSInfo;
+import sun.awt.SunToolkit;
+
+public class deadKeyMacOSX {
+
+    private static SunToolkit toolkit;
+    private static volatile int state = 0;
+
+    public static void main(String[] args) throws Exception {
+
+        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
+            return;
+        }
+
+        toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        Robot robot = new Robot();
+        robot.setAutoDelay(50);
+
+        createAndShowGUI();
+
+        // Pressed keys: Alt + E + A
+        // Results:  ALT + VK_DEAD_ACUTE + a with accute accent
+        robot.keyPress(KeyEvent.VK_ALT);
+        robot.keyPress(KeyEvent.VK_E);
+        robot.keyRelease(KeyEvent.VK_E);
+        robot.keyRelease(KeyEvent.VK_ALT);
+
+        robot.keyPress(KeyEvent.VK_A);
+        robot.keyRelease(KeyEvent.VK_A);
+
+        if (state != 3) {
+            throw new RuntimeException("Wrong number of key events.");
+        }
+    }
+
+    static void createAndShowGUI() {
+        Frame frame = new Frame();
+        frame.setSize(300, 300);
+        Panel panel = new Panel();
+        panel.addKeyListener(new DeadKeyListener());
+        frame.add(panel);
+        frame.setVisible(true);
+        toolkit.realSync();
+
+        panel.requestFocusInWindow();
+        toolkit.realSync();
+    }
+
+    static class DeadKeyListener extends KeyAdapter {
+
+        @Override
+        public void keyPressed(KeyEvent e) {
+            int keyCode = e.getKeyCode();
+            char keyChar = e.getKeyChar();
+
+            switch (state) {
+                case 0:
+                    if (keyCode != KeyEvent.VK_ALT) {
+                        throw new RuntimeException("Alt is not pressed.");
+                    }
+                    state++;
+                    break;
+                case 1:
+                    if (keyCode != KeyEvent.VK_DEAD_ACUTE) {
+                        throw new RuntimeException("Dead ACUTE is not pressed.");
+                    }
+                    if (keyChar != 0xB4) {
+                        throw new RuntimeException("Pressed char is not dead acute.");
+                    }
+
+                    state++;
+                    break;
+                case 2:
+                    if (keyCode != KeyEvent.VK_A) {
+                        throw new RuntimeException("A is not pressed.");
+                    }
+                    if (keyChar != 0xE1) {
+                        throw new RuntimeException("A char does not have ACCUTE accent");
+                    }
+                    state++;
+                    break;
+                default:
+                    throw new RuntimeException("Excessive keyPressed event.");
+            }
+        }
+
+        @Override
+        public void keyTyped(KeyEvent e) {
+            int keyCode = e.getKeyCode();
+            char keyChar = e.getKeyChar();
+
+            if (state == 3) {
+                if (keyCode != 0) {
+                    throw new RuntimeException("Key code should be undefined.");
+                }
+                if (keyChar != 0xE1) {
+                    throw new RuntimeException("A char does not have ACCUTE accent");
+                }
+            } else {
+                throw new RuntimeException("Wron number of keyTyped events.");
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/Test7193977.java	Fri Sep 14 14:10:01 2012 -0700
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 7193977
+ * @summary Tests that generified property descriptors do not loose additional info
+ * @author Sergey Malenkov
+ */
+
+import java.awt.Image;
+import java.beans.BeanDescriptor;
+import java.beans.BeanInfo;
+import java.beans.EventSetDescriptor;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.MethodDescriptor;
+import java.beans.PropertyDescriptor;
+import java.util.Arrays;
+import java.util.List;
+
+public class Test7193977 {
+
+    private static final List<String> names = Arrays.asList("listType", "list", "value");
+
+    public static void main(String args[]) {
+        for (String name : names) {
+            test(Abstract.class, name);
+            test(Concrete.class, name);
+        }
+    }
+
+    private static void test(Class<?> type, String name) {
+        if (!Boolean.TRUE.equals(BeanUtils.getPropertyDescriptor(type, name).getValue("transient"))) {
+            throw new Error("property '" + name + "' is not transient");
+        }
+    }
+
+    public static final class Concrete extends Abstract<String> {
+    }
+
+    public static abstract class Abstract<T> {
+        private List<T> list;
+
+        public List<T> getList() {
+            return this.list;
+        }
+
+        public void setList(List<T> list) {
+            this.list = list;
+        }
+
+        public T getValue(int index) {
+            return (0 <= index) && (this.list != null) && (index < this.list.size())
+                    ? this.list.get(index)
+                    : null;
+        }
+
+        public void setValue(int index, T value) {
+            if ((0 <= index) && (this.list != null)) {
+                if (index == this.list.size()) {
+                    this.list.add(value);
+                }
+                else if (index < this.list.size()) {
+                    this.list.set(index, value);
+                }
+            }
+        }
+
+        public String getListType() {
+            return (this.list != null)
+                    ? this.list.getClass().getName()
+                    : null;
+        }
+
+        public void setListType(String type) throws Exception {
+            this.list = (type != null)
+                    ? (List<T>) Class.forName(type).newInstance()
+                    : null;
+        }
+    }
+
+    public static final class ConcreteBeanInfo extends Wrapper {
+        public ConcreteBeanInfo() throws IntrospectionException {
+            super(Concrete.class);
+        }
+    }
+
+    public static final class AbstractBeanInfo extends Wrapper {
+        public AbstractBeanInfo() throws IntrospectionException {
+            super(Abstract.class);
+            for (PropertyDescriptor pd : getPropertyDescriptors()) {
+                if (names.contains(pd.getName())) {
+                    pd.setValue("transient", Boolean.TRUE);
+                }
+            }
+        }
+    }
+
+    private static class Wrapper implements BeanInfo {
+        private final BeanInfo info;
+
+        Wrapper(Class<?> type) throws IntrospectionException {
+            this.info = Introspector.getBeanInfo(type, Introspector.IGNORE_IMMEDIATE_BEANINFO);
+        }
+
+        public BeanDescriptor getBeanDescriptor() {
+            return this.info.getBeanDescriptor();
+        }
+
+        public EventSetDescriptor[] getEventSetDescriptors() {
+            return this.info.getEventSetDescriptors();
+        }
+
+        public int getDefaultEventIndex() {
+            return this.info.getDefaultEventIndex();
+        }
+
+        public PropertyDescriptor[] getPropertyDescriptors() {
+            return this.info.getPropertyDescriptors();
+        }
+
+        public int getDefaultPropertyIndex() {
+            return this.info.getDefaultPropertyIndex();
+        }
+
+        public MethodDescriptor[] getMethodDescriptors() {
+            return this.info.getMethodDescriptors();
+        }
+
+        public BeanInfo[] getAdditionalBeanInfo() {
+            return this.info.getAdditionalBeanInfo();
+        }
+
+        public Image getIcon(int kind) {
+            return this.info.getIcon(kind);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JMenuItem/6438430/bug6438430.java	Fri Sep 14 14:10:01 2012 -0700
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 6438430
+ * @summary Tests that submenu title doesn't overlap with submenu indicator
+ *          in JPopupMenu
+ * @author Mikhail Lapshin
+ * @run main/othervm -Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel bug6438430
+ * @run main/othervm -Dswing.defaultlaf=com.sun.java.swing.plaf.motif.MotifLookAndFeel bug6438430
+ */
+
+import javax.swing.JMenuItem;
+import javax.swing.JMenu;
+import javax.swing.JCheckBoxMenuItem;
+
+public class bug6438430 {
+    public static void main(String[] args) {
+        JMenu subMenu1 = new JMenu("Long-titled Sub Menu");
+        subMenu1.add(new JMenuItem("SubMenu Item"));
+        JMenuItem checkBoxMenuItem1 = new JCheckBoxMenuItem("CheckBox");
+
+        JMenu menu1 = new JMenu("It works always");
+        menu1.add(checkBoxMenuItem1);
+        menu1.add(subMenu1);
+
+        // Simulate DefaultMenuLayout calls.
+        // The latest traversed menu item must be the widest.
+        checkBoxMenuItem1.getPreferredSize();
+        int width1 = subMenu1.getPreferredSize().width;
+        System.out.println("width1 = " + width1);
+
+
+        JMenu subMenu2 = new JMenu("Long-titled Sub Menu");
+        subMenu2.add(new JMenuItem("SubMenu Item"));
+        JMenuItem checkBoxMenuItem2 = new JCheckBoxMenuItem("CheckBox");
+
+        JMenu menu2 = new JMenu("It did not work before the fix");
+        menu2.add(subMenu2);
+        menu2.add(checkBoxMenuItem2);
+
+        // Simulate DefaultMenuLayout calls.
+        // The latest traversed menu item must be the widest.
+        subMenu2.getPreferredSize();
+        int width2 = checkBoxMenuItem2.getPreferredSize().width;
+        System.out.println("width2 = " + width2);
+
+        if (width1 != width2) {
+            throw new RuntimeException( "Submenu title and submenu indicator " +
+                                        "overlap on JMenuItem!" );
+        }
+
+        System.out.println("Test passed");
+    }
+}