Merge
authorlana
Wed, 19 Sep 2012 12:38:53 -0700
changeset 13783 539a1187467a
parent 13769 ba52da5186ad (current diff)
parent 13782 1ca9ff9c0254 (diff)
child 13823 9a7055463e06
Merge
jdk/src/macosx/classes/sun/awt/SunToolkitSubclass.java
--- a/jdk/src/macosx/classes/sun/awt/SunToolkitSubclass.java	Mon Sep 17 13:44:07 2012 +0400
+++ /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	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java	Wed Sep 19 12:38:53 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	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Wed Sep 19 12:38:53 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.h	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/AWTEvent.h	Wed Sep 19 12:38:53 2012 -0700
@@ -33,5 +33,7 @@
 void DeliverJavaMouseEvent(JNIEnv *env, NSEvent *event, jobject peer);
 void SendAdditionalJavaEvents(JNIEnv *env, NSEvent *nsEvent, jobject peer);
 jint GetJavaMouseModifiers(NSInteger button, NSUInteger modifierFlags);
+jint NsKeyModifiersToJavaModifiers(NSUInteger nsFlags, BOOL isExtMods);
+NSUInteger JavaModifiersToNsKeyModifiers(jint javaModifiers, BOOL isExtMods);
 
 #endif /* __AWTEVENT_H */
--- a/jdk/src/macosx/native/sun/awt/AWTEvent.m	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/AWTEvent.m	Wed Sep 19 12:38:53 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"
@@ -244,6 +245,7 @@
     //NSUInteger cgsRightMask;
     unsigned short leftKeyCode;
     unsigned short rightKeyCode;
+    jint javaExtMask;
     jint javaMask;
     jint javaKey;
 }
@@ -254,6 +256,7 @@
         0,
         0,
         0, // no Java equivalent
+        0, // no Java equivalent
         java_awt_event_KeyEvent_VK_CAPS_LOCK
     },
     {
@@ -263,6 +266,7 @@
         56,
         60,
         java_awt_event_InputEvent_SHIFT_DOWN_MASK,
+        java_awt_event_InputEvent_SHIFT_MASK,
         java_awt_event_KeyEvent_VK_SHIFT
     },
     {
@@ -272,6 +276,7 @@
         59,
         62,
         java_awt_event_InputEvent_CTRL_DOWN_MASK,
+        java_awt_event_InputEvent_CTRL_MASK,
         java_awt_event_KeyEvent_VK_CONTROL
     },
     {
@@ -281,6 +286,7 @@
         58,
         61,
         java_awt_event_InputEvent_ALT_DOWN_MASK,
+        java_awt_event_InputEvent_ALT_MASK,
         java_awt_event_KeyEvent_VK_ALT
     },
     {
@@ -290,6 +296,7 @@
         55,
         54,
         java_awt_event_InputEvent_META_DOWN_MASK,
+        java_awt_event_InputEvent_META_MASK,
         java_awt_event_KeyEvent_VK_META
     },
     // NSNumericPadKeyMask
@@ -298,10 +305,11 @@
         0,
         0,
         0, // no Java equivalent
+        0, // no Java equivalent
         java_awt_event_KeyEvent_VK_HELP
     },
     // NSFunctionKeyMask
-    {0, 0, 0, 0, 0}
+    {0, 0, 0, 0, 0, 0}
 };
 
 /*
@@ -371,26 +379,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;
             }
         }
@@ -491,25 +540,51 @@
 /*
  * This returns the java modifiers for a key NSEvent.
  */
-static jint
-NsKeyModifiersToJavaModifiers(NSUInteger nsFlags)
+jint NsKeyModifiersToJavaModifiers(NSUInteger nsFlags, BOOL isExtMods)
 {
     jint javaModifiers = 0;
     const struct _nsKeyToJavaModifier* cur;
 
     for (cur = nsKeyToJavaModifierTable; cur->nsMask != 0; ++cur) {
         if ((cur->nsMask & nsFlags) != 0) {
-            javaModifiers |= cur->javaMask;
+            javaModifiers |= isExtMods? cur->javaExtMask : cur->javaMask;
         }
     }
 
     return javaModifiers;
 }
 
+/*
+ * This returns the NSEvent flags for java key modifiers.
+ */
+NSUInteger JavaModifiersToNsKeyModifiers(jint javaModifiers, BOOL isExtMods)
+{
+    NSUInteger nsFlags = 0;
+    const struct _nsKeyToJavaModifier* cur;
+
+    for (cur = nsKeyToJavaModifierTable; cur->nsMask != 0; ++cur) {
+        jint mask = isExtMods? cur->javaExtMask : cur->javaMask; 
+        if ((mask & javaModifiers) != 0) {
+            nsFlags |= cur->nsMask;
+        }
+    }
+
+    // special case
+    jint mask = isExtMods? java_awt_event_InputEvent_ALT_GRAPH_DOWN_MASK : 
+                           java_awt_event_InputEvent_ALT_GRAPH_MASK;
+
+    if ((mask & javaModifiers) != 0) {
+        nsFlags |= NSAlternateKeyMask;      
+    }
+
+    return nsFlags;
+}
+
+
 jint GetJavaMouseModifiers(NSInteger button, NSUInteger modifierFlags)
 {
     // Mousing needs the key modifiers
-    jint modifiers = NsKeyModifiersToJavaModifiers(modifierFlags);
+    jint modifiers = NsKeyModifiersToJavaModifiers(modifierFlags, YES);
 
 
     /*
@@ -590,7 +665,7 @@
 
 JNF_COCOA_ENTER(env);
 
-    jmodifiers = NsKeyModifiersToJavaModifiers(modifierFlags);
+    jmodifiers = NsKeyModifiersToJavaModifiers(modifierFlags, YES);
 
 JNF_COCOA_EXIT(env);
 
@@ -615,20 +690,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 +762,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	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/AWTWindow.m	Wed Sep 19 12:38:53 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/macosx/native/sun/awt/CDragSource.m	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/CDragSource.m	Wed Sep 19 12:38:53 2012 -0700
@@ -460,7 +460,7 @@
     }
 
     // Convert fModifiers (extModifiers) to NS:
-    NSUInteger modifiers = [DnDUtilities mapJavaExtModifiersToNSKeyModifiers:fModifiers];
+    NSUInteger modifiers = JavaModifiersToNsKeyModifiers(fModifiers, TRUE); 
 
     // Just a dummy value ...
     NSInteger eventNumber = 0;
@@ -658,7 +658,7 @@
     }
 
     // b) drag actions (key modifiers) have changed:
-    jint modifiers = [DnDUtilities currentJavaExtKeyModifiers];
+    jint modifiers = NsKeyModifiersToJavaModifiers([NSEvent modifierFlags], YES);
     if (fDragKeyModifiers != modifiers) {
         NSDragOperation currentOp = [DnDUtilities nsDragOperationForModifiers:[NSEvent modifierFlags]];
         NSDragOperation allowedOp = [DnDUtilities mapJavaDragOperationToNS:fSourceActions] & currentOp;
--- a/jdk/src/macosx/native/sun/awt/CMenuItem.m	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/CMenuItem.m	Wed Sep 19 12:38:53 2012 -0700
@@ -70,6 +70,18 @@
     JNIEnv *env = [ThreadUtilities getJNIEnv];
 JNF_COCOA_ENTER(env);
 
+    // If we are called as a result of user pressing a shorcut, do nothing,
+    // because AVTView has already sent corresponding key event to the Java 
+    // layer from performKeyEquivalent
+    NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent];
+    if ([currEvent type] == NSKeyDown) {
+        NSString *menuKey = [sender keyEquivalent];
+        NSString *eventKey = [currEvent characters];
+        if ([menuKey isEqualToString:eventKey]) {
+            return;
+        }
+    }
+
     if (fIsCheckbox) {
         static JNF_CLASS_CACHE(jc_CCheckboxMenuItem, "sun/lwawt/macosx/CCheckboxMenuItem");
         static JNF_MEMBER_CACHE(jm_ckHandleAction, jc_CCheckboxMenuItem, "handleAction", "(Z)V");
@@ -83,14 +95,8 @@
         static JNF_CLASS_CACHE(jc_CMenuItem, "sun/lwawt/macosx/CMenuItem");
         static JNF_MEMBER_CACHE(jm_handleAction, jc_CMenuItem, "handleAction", "(JI)V"); // AWT_THREADING Safe (event)
 
-        NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent];
         NSUInteger modifiers = [currEvent modifierFlags];
-        jint javaModifiers = 0;
-
-        if ((modifiers & NSCommandKeyMask) != 0)   javaModifiers |= java_awt_Event_META_MASK;
-        if ((modifiers & NSShiftKeyMask) != 0)     javaModifiers |= java_awt_Event_SHIFT_MASK;
-        if ((modifiers & NSControlKeyMask) != 0)   javaModifiers |= java_awt_Event_CTRL_MASK;
-        if ((modifiers & NSAlternateKeyMask) != 0) javaModifiers |= java_awt_Event_ALT_MASK;
+        jint javaModifiers = NsKeyModifiersToJavaModifiers(modifiers, NO);
 
         JNFCallVoidMethod(env, fPeer, jm_handleAction, UTC(currEvent), javaModifiers); // AWT_THREADING Safe (event)
     }
@@ -117,10 +123,7 @@
             modifiers &= ~java_awt_event_KeyEvent_SHIFT_MASK;
         }
 
-        if ((modifiers & java_awt_event_KeyEvent_SHIFT_MASK) != 0) modifierMask |= NSShiftKeyMask;
-        if ((modifiers & java_awt_event_KeyEvent_CTRL_MASK) != 0)  modifierMask |= NSControlKeyMask;
-        if ((modifiers & java_awt_event_KeyEvent_ALT_MASK) != 0)   modifierMask |= NSAlternateKeyMask;
-        if ((modifiers & java_awt_event_KeyEvent_META_MASK) != 0)  modifierMask |= NSCommandKeyMask;
+        modifierMask = JavaModifiersToNsKeyModifiers(modifiers, NO);
     }
 
     [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
--- a/jdk/src/macosx/native/sun/awt/DnDUtilities.h	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/DnDUtilities.h	Wed Sep 19 12:38:53 2012 -0700
@@ -42,7 +42,6 @@
 + (jint)narrowJavaDropActions:(jint)actions;
 
 // Mouse and key modifiers mapping:
-+ (NSUInteger)mapJavaExtModifiersToNSKeyModifiers:(jint)modifiers;
 + (NSUInteger)mapJavaExtModifiersToNSMouseDownButtons:(jint)modifiers;
 + (NSUInteger)mapJavaExtModifiersToNSMouseUpButtons:(jint)modifiers;
 
@@ -50,9 +49,6 @@
 + (jint)extractJavaExtKeyModifiersFromJavaExtModifiers:(jint)modifiers;
 + (jint)extractJavaExtMouseModifiersFromJavaExtModifiers:(jint)modifiers;
 
-// Get the current keyboard modifier keys as java modifiers (for operationChanged)
-+ (jint)currentJavaExtKeyModifiers;
-
 // Getting the state of the current Drag
 + (NSDragOperation)nsDragOperationForModifiers:(NSUInteger)modifiers;
 + (jint) javaKeyModifiersForNSDragOperation:(NSDragOperation)dragOp;
--- a/jdk/src/macosx/native/sun/awt/DnDUtilities.m	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/DnDUtilities.m	Wed Sep 19 12:38:53 2012 -0700
@@ -161,28 +161,6 @@
 }
 
 // Mouse and key modifiers mapping:
-+ (NSUInteger)mapJavaExtModifiersToNSKeyModifiers:(jint)modifiers
-{
-    NSUInteger result = 0;
-
-    if ((modifiers & java_awt_event_InputEvent_SHIFT_DOWN_MASK) != 0)
-        result |= NSShiftKeyMask;
-
-    if ((modifiers & java_awt_event_InputEvent_CTRL_DOWN_MASK) != 0)
-        result |= NSControlKeyMask;
-
-    if ((modifiers & java_awt_event_InputEvent_META_DOWN_MASK) != 0)
-        result |= NSCommandKeyMask;
-
-    if ((modifiers & java_awt_event_InputEvent_ALT_DOWN_MASK) != 0)
-        result |= NSAlternateKeyMask;
-
-    if ((modifiers & java_awt_event_InputEvent_ALT_GRAPH_DOWN_MASK) != 0)
-        result |= NSAlternateKeyMask;
-
-    return result;
-}
-
 + (NSUInteger)mapJavaExtModifiersToNSMouseDownButtons:(jint)modifiers
 {
     NSUInteger result = NSLeftMouseDown;
@@ -245,32 +223,6 @@
     return modifiers & mask;
 }
 
-
-+ (jint)currentJavaExtKeyModifiers
-{
-    NSUInteger modifiers = [NSEvent modifierFlags];
-    jint jmodifiers = 0;
-
-    if(modifiers & NSShiftKeyMask) {
-        jmodifiers |= java_awt_event_InputEvent_SHIFT_DOWN_MASK;
-    }
-
-    if(modifiers & NSControlKeyMask) {
-        jmodifiers |= java_awt_event_InputEvent_CTRL_DOWN_MASK;
-    }
-
-    if(modifiers & NSAlternateKeyMask) {
-        jmodifiers |= java_awt_event_InputEvent_ALT_DOWN_MASK;
-    }
-
-    if(modifiers & NSCommandKeyMask) {
-        jmodifiers |= java_awt_event_InputEvent_META_DOWN_MASK;
-    }
-
-    return jmodifiers;
-}
-
-
 + (NSDragOperation) nsDragOperationForModifiers:(NSUInteger)modifiers {
 
     // Java first
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Wed Sep 19 12:38:53 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	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/share/classes/java/awt/EventQueue.java	Wed Sep 19 12:38:53 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	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java	Wed Sep 19 12:38:53 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	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/share/classes/java/beans/Introspector.java	Wed Sep 19 12:38:53 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	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/share/classes/java/beans/PropertyDescriptor.java	Wed Sep 19 12:38:53 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	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/share/classes/javax/swing/text/DefaultCaret.java	Wed Sep 19 12:38:53 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	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/share/classes/sun/awt/SunToolkit.java	Wed Sep 19 12:38:53 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	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/share/classes/sun/awt/image/VolatileSurfaceManager.java	Wed Sep 19 12:38:53 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	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/windows/classes/sun/java2d/ScreenUpdateManager.java	Wed Sep 19 12:38:53 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	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/windows/native/sun/windows/awt_DesktopProperties.cpp	Wed Sep 19 12:38:53 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	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/windows/native/sun/windows/awt_DesktopProperties.h	Wed Sep 19 12:38:53 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	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/windows/native/sun/windows/awt_TextField.cpp	Wed Sep 19 12:38:53 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	Wed Sep 19 12:38:53 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/JAWT/JAWT.sh	Wed Sep 19 12:38:53 2012 -0700
@@ -0,0 +1,173 @@
+#!/bin/sh
+
+# 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 JAWT.sh
+# @bug 7190587
+# @summary Tests Java AWT native interface library
+# @author kshefov
+# @run shell JAWT.sh
+
+# NB: To run on Windows with MKS and Visual Studio compiler
+# add the following options to jtreg: -e INCLUDE="%INCLUDE%;." -e LIB="%LIB%;."
+
+if [ "${TESTSRC}" = "" ]
+then TESTSRC=.
+fi
+
+if [ "${TESTJAVA}" = "" ]
+then
+  PARENT=`dirname \`which java\``
+  TESTJAVA=`dirname ${PARENT}`
+  echo "TESTJAVA not set, selecting " ${TESTJAVA}
+  echo "If this is incorrect, try setting the variable manually."
+fi
+
+# set platform-dependent variables
+OS=`uname -s`
+case "$OS" in
+  Linux )
+    NULL=/dev/null
+    PS=":"
+    FS="/"
+    ${TESTJAVA}${FS}bin${FS}java -version 2>&1 | grep '64-Bit' > $NULL
+    if [ $? -eq '0' ]
+    then
+        ARCH="amd64"
+    else
+        ARCH="i386"
+    fi
+    SYST="linux"
+    MAKEFILE="Makefile.unix"
+    CC="gcc"
+	MAKE="make"
+	LD_LIBRARY_PATH="."
+    ;;
+  SunOS )
+    NULL=/dev/null
+    PS=":"
+    FS="/"
+    if [ `uname -p | grep -c 'sparc'` -gt '0' ]
+    then
+        ARCH="sparc"
+    else
+        ARCH="i386"
+    fi
+    SYST="solaris"
+    MAKEFILE="Makefile.unix"
+    CC="gcc"
+	MAKE="make"
+	LD_LIBRARY_PATH="."
+    ;;
+  Windows* )
+    NULL=null
+    PS=";"
+    FS="\\"
+    MAKEFILE="Makefile.win"
+    CC="cl"
+	MAKE="nmake"
+	${TESTJAVA}${FS}bin${FS}java -d64 -version 2>&1 | grep '64-Bit' > $NULL
+    if [ "$?" -eq '0' ]
+    then
+        ARCH="amd64"
+    else
+        ARCH="i386"
+    fi
+	SYST="windows"
+    ;;
+  CYGWIN* )
+    NULL=/dev/null
+    PS=":"
+    FS="/"
+    MAKEFILE="Makefile.cygwin"
+    CC="gcc"
+	${TESTJAVA}${FS}bin${FS}java -d64 -version 2>&1 | grep '64-Bit' > $NULL
+    if [ "$?" -eq '0' ]
+    then
+        ARCH="amd64"
+    else
+        ARCH="i386"
+    fi
+	SYST="cygwin"	
+	MAKE="make"
+    ;;
+  Darwin )
+    echo "Test passed. This test is not for MacOS."
+    exit 0;
+    ;;
+  * )
+    echo "Unrecognized system!"
+    exit 1;
+    ;;
+esac
+
+# Skip unsupported platforms
+case `uname -m` in
+    arm* | ppc* )
+      echo "Test passed. Not supported on current architecture."
+      exit 0
+      ;;
+esac
+
+echo "OS-ARCH is" ${SYST}-${ARCH}
+${TESTJAVA}${FS}jre${FS}bin${FS}java -fullversion 2>&1
+
+which ${MAKE} >${NULL} 2>&1
+if [ "$?" -ne '0' ]
+then
+    echo "No make found. Test passed."
+    exit 0
+fi
+
+which ${CC} >${NULL} 2>&1
+if [ "$?" -ne '0' ]
+then
+    echo "No C compiler found. Test passed."
+    exit 0
+fi
+case "$OS" in
+    SunOS )
+      ${CC} -v >${NULL} 2>&1
+      if [ "$?" -ne '0' ]
+      then
+          echo "No C compiler found. Test passed."
+          exit 0
+      fi
+esac
+
+cp ${TESTSRC}${FS}${MAKEFILE} .
+
+JAVA=${TESTJAVA}${FS}jre${FS}bin${FS}java
+JAVAC=${TESTJAVA}${FS}bin${FS}javac
+JAVAH=${TESTJAVA}${FS}bin${FS}javah
+
+export CC SYST ARCH LD_LIBRARY_PATH
+
+${JAVAC} -d . ${TESTSRC}${FS}MyCanvas.java
+${JAVAH} -jni -classpath . -d . MyCanvas
+${MAKE} -f ${MAKEFILE}
+${JAVA} -classpath . MyCanvas
+
+exit $?
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/JAWT/Makefile.cygwin	Wed Sep 19 12:38:53 2012 -0700
@@ -0,0 +1,49 @@
+# 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.
+
+CFLAGS =	
+OBJS =		myfile.o
+HEADERS =	MyCanvas.h
+CLASSES =	MyCanvas.class
+
+JAVA =		$(TESTJAVA)/bin/java -classpath .
+JAVAC =		$(TESTJAVA)/bin/javac
+JAVAH =		$(TESTJAVA)/bin/javah
+DEL =		rm -rf
+LINK =		$(CC)
+
+INCLUDES =	-I $(TESTJAVA)/include/win32 -I $(TESTJAVA)/include -I .
+
+LIBS =		$(TESTJAVA)/lib/jawt.lib -lgdi32
+
+all:		$(CLASSES) mylib.dll
+
+mylib.dll: $(HEADERS) $(OBJS) 
+	$(LINK) -shared -o mylib.dll $(OBJS) $(LIBS) 
+
+myfile.o:
+	$(CC) $(CFLAGS)  $(INCLUDES) -c $(TESTSRC)/myfile.cpp
+
+clean:
+	$(DEL) mylib.* *.h *.class *.o
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/JAWT/Makefile.unix	Wed Sep 19 12:38:53 2012 -0700
@@ -0,0 +1,48 @@
+# 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.
+
+CFLAGS =	-fPIC -O
+OBJS =		myfile.o
+HEADERS =	MyCanvas.h
+CLASSES =	MyCanvas.class
+
+ENV =		/usr/bin/env
+JAVA =		$(TESTJAVA)/bin/java -classpath .
+JAVAC =		$(TESTJAVA)/bin/javac
+JAVAH =		$(TESTJAVA)/bin/javah
+LINK =		ld
+
+J_INC =		$(TESTJAVA)/include
+INCLUDES =	-I$(J_INC) -I$(J_INC)/$(SYST) -I.
+LIBS =		-L$(TESTJAVA)/jre/lib/$(ARCH) -ljawt -lX11
+
+all:		$(CLASSES) libmylib.so
+
+libmylib.so: $(HEADERS) $(OBJS) 
+	$(LINK) -G -o libmylib.so $(OBJS) $(LIBS)
+
+myfile.o:	$(TESTSRC)/myfile.c
+	$(CC)  $(CFLAGS) $(INCLUDES) -c $(TESTSRC)/myfile.c
+
+clean:
+	rm -rf libmylib.so $(HEADERS) $(CLASSES) $(OBJS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/JAWT/Makefile.win	Wed Sep 19 12:38:53 2012 -0700
@@ -0,0 +1,47 @@
+# 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.
+
+CFLAGS =	-nologo
+OBJS =		myfile.obj
+HEADERS =	MyCanvas.h
+CLASSES =	MyCanvas.class
+
+DEL =		del /Q
+LINK =		link
+
+INCLUDES =	-I$(TESTJAVA)\include\win32 -I$(TESTJAVA)\include
+
+LIBS =		gdi32.lib user32.lib $(TESTJAVA)\lib\jawt.lib
+
+all:		$(CLASSES) mylib.dll
+
+mylib.dll: $(HEADERS) $(OBJS) 
+	$(LINK) -nologo -dll -out:mylib.dll $(OBJS) $(LIBS)
+
+myfile.obj: $(TESTSRC)\myfile.cpp
+	$(CC) $(CFLAGS) $(INCLUDES) -c $(TESTSRC)\myfile.cpp
+
+clean:
+	$(DEL) mylib.* 
+	$(DEL) $(HEADERS) $(CLASSES)
+	$(DEL) *.obj
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/JAWT/MyCanvas.java	Wed Sep 19 12:38:53 2012 -0700
@@ -0,0 +1,72 @@
+/**
+ * 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.
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+
+public class MyCanvas extends Canvas {
+
+    static {
+        try {
+            System.loadLibrary("mylib");
+        } catch (Throwable t) {
+            System.out.println("Test failed!!");
+            t.printStackTrace();
+            System.exit(1);
+        }
+    }
+
+    public native void paint(Graphics g);
+
+    public static void main(String[] args) {
+        try {
+            Robot robot = new Robot();
+            Frame f = new Frame();
+            f.setBounds(0, 0, 100, 100);
+            f.add(new MyCanvas());
+            f.addWindowListener(new WindowAdapter() {
+                public void windowClosing(WindowEvent ev) {
+                    System.exit(0);
+                }
+            });
+            f.setVisible(true);
+            robot.delay(5000);
+            Color col1 = new Color(0, 0, 0);
+            Color col2 = robot.getPixelColor(f.getX()+50, f.getY()+50);
+            if (col1.equals(col2)) {
+                System.out.println("Test passed!");
+            } else {
+                throw new RuntimeException("Color of JAWT canvas is wrong or " +
+                        "it was not rendered. " + "Check that other windows " +
+                        "do not block the test frame.");
+            }
+            System.exit(0);
+        } catch (Throwable t) {
+            System.out.println("Test failed!");
+            t.printStackTrace();
+            System.exit(1);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/JAWT/myfile.c	Wed Sep 19 12:38:53 2012 -0700
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+#include "MyCanvas.h"
+#include "jawt_md.h"
+
+/*
+ * Class:     MyCanvas
+ * Method:    paint
+ * Signature: (Ljava/awt/Graphics;)V
+ */
+JNIEXPORT void JNICALL Java_MyCanvas_paint
+(JNIEnv* env, jobject canvas, jobject graphics)
+{
+    JAWT awt;
+    JAWT_DrawingSurface* ds;
+    JAWT_DrawingSurfaceInfo* dsi;
+    JAWT_X11DrawingSurfaceInfo* dsi_x11;
+    jboolean result;
+    jint lock;
+    GC gc;
+    jobject ref;
+
+    /* Get the AWT */
+    awt.version = JAWT_VERSION_1_4;
+    if (JAWT_GetAWT(env, &awt) == JNI_FALSE) {
+        printf("AWT Not found\n");
+        return;
+    }
+
+    /* Lock the AWT */
+    awt.Lock(env);
+
+    /* Unlock the AWT */
+    awt.Unlock(env);
+
+    /* Get the drawing surface */
+    ds = awt.GetDrawingSurface(env, canvas);
+    if (ds == NULL) {
+        printf("NULL drawing surface\n");
+        return;
+    }
+
+    /* Lock the drawing surface */
+    lock = ds->Lock(ds);
+    printf("Lock value %d\n", (int)lock);
+    if((lock & JAWT_LOCK_ERROR) != 0) {
+        printf("Error locking surface\n");
+        awt.FreeDrawingSurface(ds);
+        return;
+    }
+
+    /* Get the drawing surface info */
+    dsi = ds->GetDrawingSurfaceInfo(ds);
+    if (dsi == NULL) {
+        printf("Error getting surface info\n");
+        ds->Unlock(ds);
+        awt.FreeDrawingSurface(ds);
+        return;
+    }
+
+    /* Get the platform-specific drawing info */
+    dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
+
+    /* Now paint */
+    gc = XCreateGC(dsi_x11->display, dsi_x11->drawable, 0, 0);
+    XSetForeground(dsi_x11->display, gc, 0);
+    XFillRectangle(dsi_x11->display, dsi_x11->drawable, gc,
+                   5, 5, 90, 90);
+    XFreeGC(dsi_x11->display, gc);
+    ref = awt.GetComponent(env, (void*)(dsi_x11->drawable));
+    if (!(*env)->IsSameObject(env, ref, canvas)) {
+        printf("Error! Different objects!\n");
+    }
+
+    /* Free the drawing surface info */
+    ds->FreeDrawingSurfaceInfo(dsi);
+
+    /* Unlock the drawing surface */
+    ds->Unlock(ds);
+
+    /* Free the drawing surface */
+    awt.FreeDrawingSurface(ds);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/JAWT/myfile.cpp	Wed Sep 19 12:38:53 2012 -0700
@@ -0,0 +1,110 @@
+/*
+ * 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.
+ */
+
+#include <windows.h>
+#include "MyCanvas.h"
+#include "jawt_md.h"
+
+/*
+ * Class:     MyCanvas
+ * Method:    paint
+ * Signature: (Ljava/awt/Graphics;)V
+ */
+
+extern "C" {
+
+JNIEXPORT void JNICALL Java_MyCanvas_paint
+(JNIEnv* env, jobject canvas, jobject graphics)
+{
+    /* Get the AWT */
+    JAWT awt;
+    awt.version = JAWT_VERSION_1_4;
+    if (JAWT_GetAWT(env, &awt) == JNI_FALSE) {
+        printf("AWT Not found\n");
+        return;
+    }
+
+    /* Lock the AWT */
+    awt.Lock(env);
+
+    /* Unlock the AWT */
+    awt.Unlock(env);
+
+    /* Get the drawing surface */
+    JAWT_DrawingSurface* ds = awt.GetDrawingSurface(env, canvas);
+    if (ds == NULL) {
+        printf("NULL drawing surface\n");
+        return;
+    }
+
+    /* Lock the drawing surface */
+    jint lock = ds->Lock(ds);
+    printf("Lock value %d\n", (int)lock);
+    if((lock & JAWT_LOCK_ERROR) != 0) {
+        printf("Error locking surface\n");
+        return;
+    }
+
+    /* Get the drawing surface info */
+    JAWT_DrawingSurfaceInfo* dsi = ds->GetDrawingSurfaceInfo(ds);
+    if (dsi == NULL) {
+        printf("Error getting surface info\n");
+        ds->Unlock(ds);
+        return;
+    }
+
+    /* Get the platform-specific drawing info */
+    JAWT_Win32DrawingSurfaceInfo* dsi_win =
+        (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
+
+    /* Now paint */
+    PAINTSTRUCT ps;
+    /* Do not use the HDC returned from BeginPaint()!! */
+    ::BeginPaint(dsi_win->hwnd, &ps);
+    HBRUSH hbrush = (HBRUSH)::GetStockObject(BLACK_BRUSH);
+    RECT rect;
+    rect.left = 5;
+    rect.top = 5;
+    rect.right = 95;
+    rect.bottom = 95;
+    ::FillRect(dsi_win->hdc, &rect, hbrush);
+    ::EndPaint(dsi_win->hwnd, &ps);
+
+    jobject ref = awt.GetComponent(env, (void*)(dsi_win->hwnd));
+    if (!env->IsSameObject(ref, canvas)) {
+        printf("Error! Different objects!\n");
+    }
+
+    /* Free the drawing surface info */
+    ds->FreeDrawingSurfaceInfo(dsi);
+
+    /* Unlock the drawing surface */
+    ds->Unlock(ds);
+
+    /* Free the drawing surface */
+    awt.FreeDrawingSurface(ds);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/event/KeyEvent/DeadKey/deadKeyMacOSX.java	Wed Sep 19 12:38:53 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	Wed Sep 19 12:38:53 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	Wed Sep 19 12:38:53 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");
+    }
+}