Merge
authorjgodinez
Tue, 03 May 2011 22:13:02 -0700
changeset 9485 2aa800293a90
parent 9470 c45ac3a3e555 (current diff)
parent 9484 ef39ea9d781b (diff)
child 9496 60957339f2b5
Merge
--- a/jdk/src/share/classes/java/awt/Component.java	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/share/classes/java/awt/Component.java	Tue May 03 22:13:02 2011 -0700
@@ -2945,6 +2945,46 @@
     }
 
     /**
+     * Revalidates the component hierarchy up to the nearest validate root.
+     * <p>
+     * This method first invalidates the component hierarchy starting from this
+     * component up to the nearest validate root. Afterwards, the component
+     * hierarchy is validated starting from the nearest validate root.
+     * <p>
+     * This is a convenience method supposed to help application developers
+     * avoid looking for validate roots manually. Basically, it's equivalent to
+     * first calling the {@link #invalidate()} method on this component, and
+     * then calling the {@link #validate()} method on the nearest validate
+     * root.
+     *
+     * @see Container#isValidateRoot
+     * @since 1.7
+     */
+    public void revalidate() {
+        synchronized (getTreeLock()) {
+            invalidate();
+
+            Container root = getContainer();
+            if (root == null) {
+                // There's no parents. Just validate itself.
+                validate();
+            } else {
+                while (!root.isValidateRoot()) {
+                    if (root.getContainer() == null) {
+                        // If there's no validate roots, we'll validate the
+                        // topmost container
+                        break;
+                    }
+
+                    root = root.getContainer();
+                }
+
+                root.validate();
+            }
+        }
+    }
+
+    /**
      * Creates a graphics context for this component. This method will
      * return <code>null</code> if this component is currently not
      * displayable.
--- a/jdk/src/share/classes/java/awt/GraphicsDevice.java	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/share/classes/java/awt/GraphicsDevice.java	Tue May 03 22:13:02 2011 -0700
@@ -257,6 +257,11 @@
      * 1.0f, and the background color alpha is set to 255 (completely opaque).
      * These values are not restored when returning to windowed mode.
      * <p>
+     * It is unspecified and platform-dependent how decorated windows operate
+     * in full-screen mode. For this reason, it is recommended to turn off
+     * the decorations in a {@code Frame} or {@code Dialog} object by using the
+     * {@code setUndecorated} method.
+     * <p>
      * When returning to windowed mode from an exclusive full-screen window,
      * any display changes made by calling {@code setDisplayMode} are
      * automatically restored to their original state.
@@ -272,6 +277,8 @@
      * @see #setDisplayMode
      * @see Component#enableInputMethods
      * @see Component#setVisible
+     * @see Frame#setUndecorated
+     * @see Dialog#setUndecorated
      *
      * @since 1.4
      */
--- a/jdk/src/share/classes/java/awt/Toolkit.java	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/share/classes/java/awt/Toolkit.java	Tue May 03 22:13:02 2011 -0700
@@ -1870,11 +1870,15 @@
 
     /**
      * Adds the specified property change listener for the named desktop
-     * property.
-     * If pcl is null, no exception is thrown and no action is performed.
+     * property. When a {@link PropertyChangeListenerProxy} object is added,
+     * its property name is ignored, and the wrapped listener is added.
+     * If {@code name} is {@code null} or {@code pcl} is {@code null},
+     * no exception is thrown and no action is performed.
      *
      * @param   name The name of the property to listen for
      * @param   pcl The property change listener
+     * @see PropertyChangeSupport#addPropertyChangeListener(String,
+                PropertyChangeListener)
      * @since   1.2
      */
     public void addPropertyChangeListener(String name, PropertyChangeListener pcl) {
@@ -1883,11 +1887,16 @@
 
     /**
      * Removes the specified property change listener for the named
-     * desktop property.
-     * If pcl is null, no exception is thrown and no action is performed.
+     * desktop property. When a {@link PropertyChangeListenerProxy} object
+     * is removed, its property name is ignored, and
+     * the wrapped listener is removed.
+     * If {@code name} is {@code null} or {@code pcl} is {@code null},
+     * no exception is thrown and no action is performed.
      *
      * @param   name The name of the property to remove
      * @param   pcl The property change listener
+     * @see PropertyChangeSupport#removePropertyChangeListener(String,
+                PropertyChangeListener)
      * @since   1.2
      */
     public void removePropertyChangeListener(String name, PropertyChangeListener pcl) {
@@ -1896,12 +1905,15 @@
 
     /**
      * Returns an array of all the property change listeners
-     * registered on this toolkit.
+     * registered on this toolkit. The returned array
+     * contains {@code PropertyChangeListenerProxy} objects
+     * that associate listeners with the names of desktop properties.
      *
-     * @return all of this toolkit's <code>PropertyChangeListener</code>s
-     *         or an empty array if no property change
-     *         listeners are currently registered
+     * @return all of this toolkit's {@ code PropertyChangeListener}
+     *         objects wrapped in {@code PropertyChangeListenerProxy} objects
+     *         or an empty array  if no listeners are added
      *
+     * @see PropertyChangeSupport#getPropertyChangeListeners()
      * @since 1.4
      */
     public PropertyChangeListener[] getPropertyChangeListeners() {
@@ -1909,13 +1921,15 @@
     }
 
     /**
-     * Returns an array of all the <code>PropertyChangeListener</code>s
-     * associated with the named property.
+     * Returns an array of all property change listeners
+     * associated with the specified name of a desktop property.
      *
      * @param  propertyName the named property
-     * @return all of the <code>PropertyChangeListener</code>s associated with
-     *         the named property or an empty array if no such listeners have
-     *         been added
+     * @return all of the {@code PropertyChangeListener} objects
+     *         associated with the specified name of a desktop property
+     *         or an empty array if no such listeners are added
+     *
+     * @see PropertyChangeSupport#getPropertyChangeListeners(String)
      * @since 1.4
      */
     public PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicSplitPaneDivider.java	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicSplitPaneDivider.java	Tue May 03 22:13:02 2011 -0700
@@ -154,7 +154,7 @@
         setBackground(UIManager.getColor("SplitPane.background"));
     }
 
-    private void revalidate() {
+    private void revalidateSplitPane() {
         invalidate();
         if (splitPane != null) {
             splitPane.revalidate();
@@ -315,7 +315,7 @@
                 setCursor((orientation == JSplitPane.HORIZONTAL_SPLIT) ?
                           Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR) :
                           Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR));
-                revalidate();
+                revalidateSplitPane();
             }
             else if (e.getPropertyName() == JSplitPane.
                       ONE_TOUCH_EXPANDABLE_PROPERTY) {
@@ -376,7 +376,7 @@
                 add(rightButton);
             }
         }
-        revalidate();
+        revalidateSplitPane();
     }
 
 
--- a/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java	Tue May 03 22:13:02 2011 -0700
@@ -29,12 +29,10 @@
 import java.awt.EventQueue;
 import java.awt.Image;
 import java.awt.Graphics;
-import java.awt.Toolkit;
 
 import java.awt.datatransfer.DataFlavor;
 import java.awt.datatransfer.FlavorMap;
 import java.awt.datatransfer.FlavorTable;
-import java.awt.datatransfer.StringSelection;
 import java.awt.datatransfer.Transferable;
 import java.awt.datatransfer.UnsupportedFlavorException;
 
@@ -66,8 +64,6 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 
-import java.security.AccessControlContext;
-import java.security.AccessControlException;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
@@ -171,7 +167,26 @@
      */
     public static final DataFlavor javaTextEncodingFlavor;
 
-    private static SortedSet standardEncodings;
+    /**
+     * Lazy initialization of Standard Encodings.
+     */
+    private static class StandardEncodingsHolder {
+        private static final SortedSet standardEncodings = load();
+
+        private static SortedSet load() {
+            final Comparator comparator =
+                    new CharsetComparator(IndexedComparator.SELECT_WORST);
+            final SortedSet tempSet = new TreeSet(comparator);
+            tempSet.add("US-ASCII");
+            tempSet.add("ISO-8859-1");
+            tempSet.add("UTF-8");
+            tempSet.add("UTF-16BE");
+            tempSet.add("UTF-16LE");
+            tempSet.add("UTF-16");
+            tempSet.add(getDefaultTextCharset());
+            return Collections.unmodifiableSortedSet(tempSet);
+        }
+    }
 
     /**
      * Tracks whether a particular text/* MIME type supports the charset
@@ -509,18 +524,7 @@
      * non-standard, character sets are not included.
      */
     public static Iterator standardEncodings() {
-        if (standardEncodings == null) {
-            TreeSet tempSet = new TreeSet(defaultCharsetComparator);
-            tempSet.add("US-ASCII");
-            tempSet.add("ISO-8859-1");
-            tempSet.add("UTF-8");
-            tempSet.add("UTF-16BE");
-            tempSet.add("UTF-16LE");
-            tempSet.add("UTF-16");
-            tempSet.add(getDefaultTextCharset());
-            standardEncodings = Collections.unmodifiableSortedSet(tempSet);
-        }
-        return standardEncodings.iterator();
+        return StandardEncodingsHolder.standardEncodings.iterator();
     }
 
     /**
@@ -2398,7 +2402,9 @@
     public static DataFlavor[] setToSortedDataFlavorArray(Set flavorsSet) {
         DataFlavor[] flavors = new DataFlavor[flavorsSet.size()];
         flavorsSet.toArray(flavors);
-        Arrays.sort(flavors, defaultFlavorComparator);
+        final Comparator comparator =
+                new DataFlavorComparator(IndexedComparator.SELECT_WORST);
+        Arrays.sort(flavors, comparator);
         return flavors;
     }
 
@@ -2455,11 +2461,6 @@
         return new ArrayList();
     }
 
-    private static CharsetComparator defaultCharsetComparator =
-        new CharsetComparator(IndexedComparator.SELECT_WORST);
-    private static DataFlavorComparator defaultFlavorComparator =
-        new DataFlavorComparator(IndexedComparator.SELECT_WORST);
-
     /**
      * A Comparator which includes a helper function for comparing two Objects
      * which are likely to be keys in the specified Map.
--- a/jdk/src/solaris/classes/sun/awt/X11/XListPeer.java	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XListPeer.java	Tue May 03 22:13:02 2011 -0700
@@ -1479,16 +1479,19 @@
         int h = height - (SCROLLBAR_AREA + (2 * MARGIN));
         hsb.setValue(hsb.getValue() + x);
 
+        int options = PAINT_ITEMS | PAINT_HSCROLL;
+
         Rectangle source = null;
         Point distance = null;
         if (x < 0) {
             source = new Rectangle(MARGIN + SPACE, MARGIN, w + x, h);
             distance = new Point(-x, 0);
+            options |= COPY_AREA;
         } else if (x > 0) {
             source = new Rectangle(MARGIN + SPACE + x, MARGIN, w - x, h);
             distance = new Point(-x, 0);
+            options |= COPY_AREA;
         }
-        int options = COPY_AREA | PAINT_ITEMS | PAINT_HSCROLL;
         repaint(vsb.getValue(), lastItemDisplayed(), options, source, distance);
     }
 
--- a/jdk/src/windows/classes/sun/awt/windows/WDataTransferer.java	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/windows/classes/sun/awt/windows/WDataTransferer.java	Tue May 03 22:13:02 2011 -0700
@@ -830,7 +830,14 @@
         if( -1 == iStartOffset ){
             throw new IOException(FAILURE_MSG + "invalid HTML format.");
         }
-        iReadCount = bufferedStream.skip(iStartOffset);
+
+        int curOffset = 0;
+        while (curOffset < iStartOffset){
+            curOffset += bufferedStream.skip(iStartOffset - curOffset);
+        }
+
+        iReadCount = curOffset;
+
         if( iStartOffset != iReadCount ){
             throw new IOException(FAILURE_MSG + "Byte stream ends in description.");
         }
--- a/jdk/src/windows/native/sun/windows/ObjectList.cpp	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/ObjectList.cpp	Tue May 03 22:13:02 2011 -0700
@@ -48,7 +48,7 @@
     m_head = item;
 }
 
-void AwtObjectList::Remove(AwtObject* obj)
+BOOL AwtObjectList::Remove(AwtObject* obj)
 {
     CriticalSection::Lock l(m_lock);
 
@@ -64,11 +64,14 @@
             }
             DASSERT(item != NULL);
             delete item;
-            return;
+            return TRUE;
         }
         lastItem = item;
         item = item->next;
     }
+
+    return FALSE;
+
 //    DASSERT(FALSE);  // should never get here...
                       // even if it does it shouldn't be fatal.
 }
--- a/jdk/src/windows/native/sun/windows/ObjectList.h	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/ObjectList.h	Tue May 03 22:13:02 2011 -0700
@@ -46,7 +46,7 @@
     AwtObjectList();
 
     void Add(AwtObject* obj);
-    void Remove(AwtObject* obj);
+    BOOL Remove(AwtObject* obj);
 #ifdef DEBUG
     /* Used for sanity checks only. */
     AwtObject* LookUp(AwtObject* obj);
--- a/jdk/src/windows/native/sun/windows/awt_Clipboard.cpp	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Clipboard.cpp	Tue May 03 22:13:02 2011 -0700
@@ -294,7 +294,7 @@
     if (format == CF_HDROP) {
         DROPFILES *dropfiles = (DROPFILES *)dataout;
         dropfiles->pFiles = sizeof(DROPFILES);
-        dropfiles->fWide = FALSE; // good guess!
+        dropfiles->fWide = TRUE; // we publish only Unicode
         dataout += sizeof(DROPFILES);
     }
 
--- a/jdk/src/windows/native/sun/windows/awt_Component.cpp	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Component.cpp	Tue May 03 22:13:02 2011 -0700
@@ -549,8 +549,6 @@
 
     m_hwnd = hwnd;
 
-    ImmAssociateContext(NULL);
-
     SetDrawState((jint)JAWT_LOCK_SURFACE_CHANGED |
         (jint)JAWT_LOCK_BOUNDS_CHANGED |
         (jint)JAWT_LOCK_CLIP_CHANGED);
@@ -1203,7 +1201,7 @@
         WIN_MSG(WM_IME_COMPOSITIONFULL)
         WIN_MSG(WM_IME_SELECT)
         WIN_MSG(WM_IME_CHAR)
-        FMT_MSG(0x0288, "WM_IME_REQUEST")
+        FMT_MSG(WM_IME_REQUEST)
         WIN_MSG(WM_IME_KEYDOWN)
         WIN_MSG(WM_IME_KEYUP)
         FMT_MSG(0x02A1, "WM_MOUSEHOVER")
@@ -1733,7 +1731,7 @@
       case WM_IME_SELECT:
       case WM_IME_KEYUP:
       case WM_IME_KEYDOWN:
-      case 0x0288: // WM_IME_REQUEST
+      case WM_IME_REQUEST:
           CallProxyDefWindowProc(message, wParam, lParam, retValue, mr);
           break;
       case WM_CHAR:
@@ -1969,7 +1967,9 @@
 {
     // fix for 6259348: we should enter the SyncCall critical section before
     // disposing the native object, that is value 1 of lParam is intended for
-    AwtToolkit::GetInstance().SendMessage(WM_AWT_DISPOSE, (WPARAM)this, (LPARAM)1);
+    if(m_peerObject != NULL) { // is not being terminating
+        AwtToolkit::GetInstance().SendMessage(WM_AWT_DISPOSE, (WPARAM)m_peerObject, (LPARAM)1);
+    }
 
     return mrConsume;
 }
@@ -2020,25 +2020,6 @@
 
 MsgRouting AwtComponent::WmShowWindow(BOOL show, UINT status)
 {
-    // NULL-InputContext is associated to all window just after they created.
-    // ( see CreateHWnd() )
-    // But to TextField and TextArea on Win95, valid InputContext is associated
-    // by system after that. This is not happen on NT4.0
-    // For workaround, force context to NULL here.
-
-    // Fix for 4730228
-    // Check if we already have Java-associated input method
-    HIMC context = 0;
-    if (m_InputMethod != NULL) {
-        // If so get the appropriate context from it and use it instead of empty context
-        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-        context = (HIMC)(UINT_PTR)(JNU_GetFieldByName(env, NULL, m_InputMethod, "context", "I").i);
-    }
-
-    if (ImmGetContext() != 0 && ImmGetContext() != context) {
-        ImmAssociateContext(context);
-    }
-
     return mrDoDefault;
 }
 
@@ -4655,10 +4636,6 @@
 ret:
     if (c && ::IsWindow(c->GetHWnd())) {
         sm_focusOwner = c->GetHWnd();
-        AwtFrame *owner = (AwtFrame*)GetComponent(c->GetProxyToplevelContainer());
-        if (owner) {
-            owner->SetLastProxiedFocusOwner(sm_focusOwner);
-        }
     } else {
         sm_focusOwner = NULL;
     }
@@ -6534,8 +6511,7 @@
 {
     TRY_NO_HANG;
 
-    PDATA pData = JNI_GET_PDATA(self);
-    AwtObject::_Dispose(pData);
+    AwtObject::_Dispose(self);
 
     CATCH_BAD_ALLOC;
 }
--- a/jdk/src/windows/native/sun/windows/awt_DnDDS.cpp	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_DnDDS.cpp	Tue May 03 22:13:02 2011 -0700
@@ -843,7 +843,7 @@
             dropfiles->pt.x = m_dropPoint.x;
             dropfiles->pt.y = m_dropPoint.y;
             dropfiles->fNC = m_fNC;
-            dropfiles->fWide = TRUE; // good guess!
+            dropfiles->fWide = TRUE; // we publish only Unicode
             dataout += sizeof(DROPFILES);
         }
 
--- a/jdk/src/windows/native/sun/windows/awt_Frame.cpp	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Frame.cpp	Tue May 03 22:13:02 2011 -0700
@@ -109,7 +109,7 @@
     m_isMenuDropped = FALSE;
     m_isInputMethodWindow = FALSE;
     m_isUndecorated = FALSE;
-    m_lastProxiedFocusOwner = NULL;
+    m_imeTargetComponent = NULL;
     m_actualFocusedWindow = NULL;
     m_iconic = FALSE;
     m_zoomed = FALSE;
@@ -311,6 +311,8 @@
     LRESULT retValue = 0L;
 
     AwtComponent *focusOwner = NULL;
+    AwtComponent *imeTargetComponent = NULL;
+
     // IME and input language related messages need to be sent to a window
     // which has the Java input focus
     switch (message) {
@@ -323,15 +325,29 @@
         case WM_IME_COMPOSITIONFULL:
         case WM_IME_SELECT:
         case WM_IME_CHAR:
-        case 0x0288: // WM_IME_REQUEST
+        case WM_IME_REQUEST:
         case WM_IME_KEYDOWN:
         case WM_IME_KEYUP:
         case WM_INPUTLANGCHANGEREQUEST:
         case WM_INPUTLANGCHANGE:
+            if (message == WM_IME_STARTCOMPOSITION) {
+                SetImeTargetComponent(sm_focusOwner);
+            }
+            imeTargetComponent = AwtComponent::GetComponent(GetImeTargetComponent());
+            if (imeTargetComponent != NULL &&
+                imeTargetComponent != this) // avoid recursive calls
+            {
+                retValue = imeTargetComponent->WindowProc(message, wParam, lParam);
+                mr = mrConsume;
+            }
+            if (message == WM_IME_ENDCOMPOSITION) {
+                SetImeTargetComponent(NULL);
+            }
+            break;
         // TODO: when a Choice's list is dropped down and we're scrolling in
         // the list WM_MOUSEWHEEL messages come to the poxy, not to the list. Why?
         case WM_MOUSEWHEEL:
-            focusOwner = AwtComponent::GetComponent(GetLastProxiedFocusOwner());
+            focusOwner = AwtComponent::GetComponent(sm_focusOwner);
             if  (focusOwner != NULL &&
                  focusOwner != this) // avoid recursive calls
             {
@@ -340,12 +356,16 @@
             }
             break;
         case WM_SETFOCUS:
+            if (sm_inSynthesizeFocus) break; // pass it up the WindowProc chain
+
             if (!sm_suppressFocusAndActivation && IsEmbeddedFrame()) {
                 AwtSetActiveWindow();
             }
             mr = mrConsume;
             break;
         case WM_KILLFOCUS:
+            if (sm_inSynthesizeFocus) break; // pass it up the WindowProc chain
+
             if (!sm_suppressFocusAndActivation && IsEmbeddedFrame()) {
                 AwtWindow::SynthesizeWmActivate(FALSE, GetHWnd(), NULL);
 
--- a/jdk/src/windows/native/sun/windows/awt_Frame.h	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Frame.h	Tue May 03 22:13:02 2011 -0700
@@ -150,8 +150,8 @@
     void CheckRetainActualFocusedWindow(HWND activatedOpositeHWnd);
     BOOL CheckActivateActualFocusedWindow(HWND deactivatedOpositeHWnd);
 
-    INLINE HWND GetLastProxiedFocusOwner() { return m_lastProxiedFocusOwner; }
-    INLINE void SetLastProxiedFocusOwner(HWND hwnd) { m_lastProxiedFocusOwner = hwnd; }
+    INLINE HWND GetImeTargetComponent() { return m_imeTargetComponent; }
+    INLINE void SetImeTargetComponent(HWND hwnd) { m_imeTargetComponent = hwnd; }
 
 protected:
     /* The frame is undecorated. */
@@ -179,9 +179,8 @@
     /* The frame is an InputMethodWindow */
     BOOL m_isInputMethodWindow;
 
-    /* Retains the last/current sm_focusOwner proxied. Actually, it should be
-     * a component of an owned window last/currently active. */
-    HWND m_lastProxiedFocusOwner;
+    // retains the target component for the IME messages
+    HWND m_imeTargetComponent;
 
     /*
      * Fix for 4823903.
--- a/jdk/src/windows/native/sun/windows/awt_MenuItem.cpp	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_MenuItem.cpp	Tue May 03 22:13:02 2011 -0700
@@ -974,8 +974,7 @@
 {
     TRY_NO_HANG;
 
-    PDATA pData = JNI_GET_PDATA(self);
-    AwtObject::_Dispose(pData);
+    AwtObject::_Dispose(self);
 
     CATCH_BAD_ALLOC;
 }
--- a/jdk/src/windows/native/sun/windows/awt_Object.cpp	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Object.cpp	Tue May 03 22:13:02 2011 -0700
@@ -60,11 +60,20 @@
 
 void AwtObject::Dispose()
 {
-    theAwtObjectList.Remove(this);
+    AwtToolkit::GetInstance().PostMessage(WM_AWT_DELETEOBJECT, (WPARAM)this, (LPARAM)0);
+}
+
+void AwtObject::_Dispose(jobject self)
+{
+    TRY_NO_VERIFY;
+
+    CriticalSection::Lock l(AwtToolkit::GetInstance().GetSyncCS());
 
     // value 0 of lParam means that we should not attempt to enter the
     // SyncCall critical section, as it was entered someshere earlier
-    AwtToolkit::GetInstance().PostMessage(WM_AWT_DELETEOBJECT, (WPARAM)this, (LPARAM)0);
+    AwtToolkit::GetInstance().SendMessage(WM_AWT_DISPOSE, (WPARAM)self, (LPARAM)0);
+
+    CATCH_BAD_ALLOC;
 }
 
 void AwtObject::_Dispose(PDATA pData)
@@ -73,14 +82,10 @@
 
     CriticalSection::Lock l(AwtToolkit::GetInstance().GetSyncCS());
 
-    if (pData != NULL) {
-        AwtObject *o = (AwtObject *)pData;
-        AwtToolkit::GetInstance().SendMessage(WM_AWT_DISPOSE, (WPARAM)o, (LPARAM)0);
-    }
+    AwtToolkit::GetInstance().SendMessage(WM_AWT_DISPOSEPDATA, (WPARAM)pData, (LPARAM)0);
 
     CATCH_BAD_ALLOC;
 }
-
 /*
  * Return the peer associated with some target.  This information is
  * maintained in a hashtable at the java level.
--- a/jdk/src/windows/native/sun/windows/awt_Object.h	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Object.h	Tue May 03 22:13:02 2011 -0700
@@ -67,6 +67,10 @@
     virtual void Dispose();
 
     // Static method to be called from JNI methods to dispose AwtObject
+    // specified by jobject
+    static void _Dispose(jobject self);
+
+    // Static method to be called from JNI methods to dispose AwtObject
     // specified by pData
     static void _Dispose(PDATA pData);
 
--- a/jdk/src/windows/native/sun/windows/awt_Robot.cpp	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Robot.cpp	Tue May 03 22:13:02 2011 -0700
@@ -353,8 +353,7 @@
 {
     TRY_NO_VERIFY;
 
-    PDATA pData = JNI_GET_PDATA(self);
-    AwtObject::_Dispose(pData);
+    AwtObject::_Dispose(self);
 
     CATCH_BAD_ALLOC;
 }
--- a/jdk/src/windows/native/sun/windows/awt_TextComponent.cpp	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_TextComponent.cpp	Tue May 03 22:13:02 2011 -0700
@@ -191,8 +191,11 @@
 {
     HIMC hIMC = ImmGetContext();
     // rc is not used for text component.
-    COMPOSITIONFORM cf = { CFS_POINT, {0,0}, {0,0,0,0} };
+    COMPOSITIONFORM cf = { CFS_FORCE_POSITION, {0,0}, {0,0,0,0} };
     GetCaretPos(&(cf.ptCurrentPos));
+    // the proxy is the native focus owner and it contains the composition window
+    // let's convert the position to a coordinate space relative to proxy
+    ::MapWindowPoints(GetHWnd(), GetProxyFocusOwner(), (LPPOINT)&cf.ptCurrentPos, 1);
     ImmSetCompositionWindow(hIMC, &cf);
 
     LOGFONT lf;
--- a/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp	Tue May 03 22:13:02 2011 -0700
@@ -740,18 +740,34 @@
               canDispose = syncCS.TryEnter();
           }
           if (canDispose) {
-              AwtObject *o = (AwtObject *)wParam;
-              o->Dispose();
-              if (shouldEnterCriticalSection) {
-                  syncCS.Leave();
+              if(wParam != NULL) {
+                  AwtObject *o = (AwtObject *) JNI_GET_PDATA((jobject)wParam);
+                  if(o != NULL && theAwtObjectList.Remove(o)) {
+                      o->Dispose();
+                  }
+                  if (shouldEnterCriticalSection) {
+                      syncCS.Leave();
+                  }
               }
           } else {
               AwtToolkit::GetInstance().PostMessage(WM_AWT_DISPOSE, wParam, lParam);
           }
           return 0;
       }
+      case WM_AWT_DISPOSEPDATA: {
+          /*
+           * NOTE: synchronization routine (like in WM_AWT_DISPOSE) was omitted because
+           * this handler is called ONLY while disposing Cursor and Font objects where
+           * synchronization takes place.
+           */
+          AwtObject *o = (AwtObject *) wParam;
+          if(o != NULL && theAwtObjectList.Remove(o)) {
+              o->Dispose();
+          }
+          return 0;
+      }
       case WM_AWT_DELETEOBJECT: {
-          AwtObject *p = (AwtObject *)wParam;
+          AwtObject *p = (AwtObject *) wParam;
           if (p->CanBeDeleted()) {
               // all the messages for this component are processed, so
               // it can be deleted
--- a/jdk/src/windows/native/sun/windows/awt_TrayIcon.cpp	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_TrayIcon.cpp	Tue May 03 22:13:02 2011 -0700
@@ -926,8 +926,7 @@
 {
     TRY;
 
-    PDATA pData = JNI_GET_PDATA(self);
-    AwtObject::_Dispose(pData);
+    AwtObject::_Dispose(self);
 
     CATCH_BAD_ALLOC;
 }
--- a/jdk/src/windows/native/sun/windows/awtmsg.h	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awtmsg.h	Tue May 03 22:13:02 2011 -0700
@@ -219,6 +219,7 @@
 
     WM_AWT_ENDCOMPOSITION,
     WM_AWT_DISPOSE,
+    WM_AWT_DISPOSEPDATA,
     WM_AWT_DELETEOBJECT,
     WM_AWT_SETCONVERSIONSTATUS,
     WM_AWT_GETCONVERSIONSTATUS,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Component/Revalidate/Revalidate.java	Tue May 03 22:13:02 2011 -0700
@@ -0,0 +1,122 @@
+/*
+ * 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.
+ *
+ * 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 7036669
+  @summary Test Component.revalidate() method
+  @author anthony.petrov@oracle.com: area=awt.component
+  @run main Revalidate
+*/
+
+import java.awt.*;
+
+public class Revalidate {
+    private static Frame frame = new Frame();
+    private static Panel panel = new Panel() {
+        @Override
+        public boolean isValidateRoot() {
+            return true;
+        }
+    };
+    private static Button button = new Button("Test");
+
+    private static void sleep() {
+        try { Thread.sleep(500); } catch (Exception e) {}
+    }
+
+    private static void printState(String str) {
+        System.out.println(str + " isValid state: ");
+        System.out.println("         frame: " + frame.isValid());
+        System.out.println("         panel: " + panel.isValid());
+        System.out.println("        button: " + button.isValid());
+    }
+
+    private static void fail(String msg) {
+        frame.dispose();
+        throw new RuntimeException(msg);
+    }
+
+    private static void check(String n, Component c, boolean v) {
+        if (c.isValid() != v) {
+            fail(n + ".isValid() = " + c.isValid() + ";   expected: " + v);
+        }
+    }
+    private static void check(String str, boolean f, boolean p, boolean b) {
+        printState(str);
+
+        check("frame", frame, f);
+        check("panel", panel, p);
+        check("button", button, b);
+    }
+
+    public static void main(String[] args) {
+        // setup
+        frame.add(panel);
+        panel.add(button);
+        frame.setBounds(200, 200, 300, 200);
+        frame.setVisible(true);
+        sleep();
+        check("Upon showing", true, true, true);
+
+        button.setBounds(1, 1, 30, 30);
+        sleep();
+        check("button.setBounds():", true, false, false);
+
+        button.revalidate();
+        sleep();
+        check("button.revalidate():", true, true, true);
+
+        button.setBounds(1, 1, 30, 30);
+        sleep();
+        check("button.setBounds():", true, false, false);
+
+        panel.revalidate();
+        sleep();
+        // because the panel's validate root is actually OK
+        check("panel.revalidate():", true, false, false);
+
+        button.revalidate();
+        sleep();
+        check("button.revalidate():", true, true, true);
+
+        panel.setBounds(2, 2, 125, 130);
+        sleep();
+        check("panel.setBounds():", false, false, true);
+
+        button.revalidate();
+        sleep();
+        check("button.revalidate():", false, true, true);
+
+        panel.setBounds(3, 3, 152, 121);
+        sleep();
+        check("panel.setBounds():", false, false, true);
+
+        panel.revalidate();
+        sleep();
+        check("panel.revalidate():", true, true, true);
+
+        // cleanup
+        frame.dispose();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/List/ScrollOutside/ScrollOut.java	Tue May 03 22:13:02 2011 -0700
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ *
+ * 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 7036733
+  @summary Regression : NullPointerException when scrolling horizontally on AWT List
+  @author Andrei Dmitriev area=awt-list
+  @library ../../regtesthelpers
+  @build Util
+  @run main ScrollOut
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import sun.awt.SunToolkit;
+import test.java.awt.regtesthelpers.Util;
+
+public class ScrollOut
+{
+    public static final void main(String args[])
+    {
+        final Frame frame = new Frame();
+        final List list = new List();
+        Robot robot = null;
+
+        for (int i = 0; i < 5; i++){
+            list.add("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+        }
+
+        frame.add(list);
+
+        frame.pack();
+        frame.setLocationRelativeTo(null);
+        frame.setVisible(true);
+
+        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+
+        try{
+            robot = new Robot();
+        }catch(AWTException e){
+            throw new RuntimeException(e);
+        }
+
+        //Drag from center to the outside on left
+        Point from = new Point(list.getLocationOnScreen().x + list.getWidth()/2,
+                               list.getLocationOnScreen().y + list.getHeight()/2);
+        Point to = new Point(list.getLocationOnScreen().x - 30,
+                             from.y);
+
+        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        Util.drag(robot, from, to, InputEvent.BUTTON1_MASK);
+
+        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+
+        //Drag from center to the outside on up
+        to = new Point(from.x,
+                       list.getLocationOnScreen().y - 50);
+
+        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+        Util.drag(robot, from, to, InputEvent.BUTTON1_MASK);
+
+    }//End  init()
+}
--- a/jdk/test/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion.java	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/test/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion.java	Tue May 03 22:13:02 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -50,6 +50,11 @@
 public class InfiniteRecursion {
     final static Robot robot = Util.createRobot();
     final static int MOVE_COUNT = 5;
+
+    //*2 for both rotation directions,
+    //*2 as Java sends the wheel event to every for nested component in hierarchy under cursor
+    final static int EXPECTED_COUNT = MOVE_COUNT * 2 * 2;
+
     static int actualEvents = 0;
 
     public static void main(String []s)
@@ -96,8 +101,10 @@
 
 
         Util.waitForIdle(robot);
-        if (actualEvents != MOVE_COUNT * 2) {
-            AbstractTest.fail("Expected events count: "+ MOVE_COUNT+" Actual events count: "+ actualEvents);
+        //Not fair to check for multiplier 4 as it's not specified actual number of WheelEvents
+        //result in a single wheel rotation.
+        if (actualEvents != EXPECTED_COUNT) {
+            AbstractTest.fail("Expected events count: "+ EXPECTED_COUNT+" Actual events count: "+ actualEvents);
         }
     }
 }
--- a/jdk/test/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_1.java	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/test/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_1.java	Tue May 03 22:13:02 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -50,6 +50,9 @@
 public class InfiniteRecursion_1 {
     final static Robot robot = Util.createRobot();
     final static int MOVE_COUNT = 5;
+    //*2 for both rotation directions,
+    //*2 as Java sends the wheel event to every for nested component in hierarchy under cursor
+    final static int EXPECTED_COUNT = MOVE_COUNT * 2 * 2;
     static int actualEvents = 0;
 
     public static void main(String []s)
@@ -95,8 +98,10 @@
         }
 
         Util.waitForIdle(robot);
-        if (actualEvents != MOVE_COUNT * 2) {
-            AbstractTest.fail("Expected events count: "+ MOVE_COUNT+" Actual events count: "+ actualEvents);
+        //Not fair to check for multiplier 4 as it's not specified actual number of WheelEvents
+        //result in a single wheel rotation.
+        if (actualEvents != EXPECTED_COUNT) {
+            AbstractTest.fail("Expected events count: "+ EXPECTED_COUNT+" Actual events count: "+ actualEvents);
         }
     }
 }
--- a/jdk/test/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_2.java	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/test/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_2.java	Tue May 03 22:13:02 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -56,6 +56,9 @@
 public class InfiniteRecursion_2 extends Applet {
     final static Robot robot = Util.createRobot();
     final static int MOVE_COUNT = 5;
+    //*2 for both rotation directions,
+    //*2 as Java sends the wheel event to every for nested component in hierarchy under cursor
+    final static int EXPECTED_COUNT = MOVE_COUNT * 2 * 2;
     static int actualEvents = 0;
 
     public void init()
@@ -107,8 +110,10 @@
         }
 
         Util.waitForIdle(robot);
-        if (actualEvents != MOVE_COUNT * 2) {
-            AbstractTest.fail("Expected events count: "+ MOVE_COUNT+" Actual events count: "+ actualEvents);
+        //Not fair to check for multiplier 4 as it's not specified actual number of WheelEvents
+        //result in a single wheel rotation.
+        if (actualEvents != EXPECTED_COUNT) {
+            AbstractTest.fail("Expected events count: "+ EXPECTED_COUNT+" Actual events count: "+ actualEvents);
         }
     }// start()
 }
--- a/jdk/test/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_3.java	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/test/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_3.java	Tue May 03 22:13:02 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -50,6 +50,9 @@
 public class InfiniteRecursion_3 extends Applet {
     final static Robot robot = Util.createRobot();
     final static int MOVE_COUNT = 5;
+    //*2 for both rotation directions,
+    //*2 as Java sends the wheel event to every for nested component in hierarchy under cursor
+    final static int EXPECTED_COUNT = MOVE_COUNT * 2 * 2;
     static int actualEvents = 0;
 
     public void init()
@@ -91,8 +94,10 @@
         }
 
         Util.waitForIdle(robot);
-        if (actualEvents != MOVE_COUNT * 2) {
-            AbstractTest.fail("Expected events count: "+ MOVE_COUNT+" Actual events count: "+ actualEvents);
+        //Not fair to check for multiplier 4 as it's not specified actual number of WheelEvents
+        //result in a single wheel rotation.
+        if (actualEvents != EXPECTED_COUNT) {
+            AbstractTest.fail("Expected events count: "+ EXPECTED_COUNT+" Actual events count: "+ actualEvents);
         }
     }// start()
 }
--- a/jdk/test/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_4.java	Tue May 03 22:11:02 2011 -0700
+++ b/jdk/test/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_4.java	Tue May 03 22:13:02 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -47,6 +47,8 @@
 public class InfiniteRecursion_4 {
     final static Robot robot = Util.createRobot();
     final static int MOVE_COUNT = 5;
+    //*2 for both rotation directions over a single frame without any siblings
+    final static int EXPECTED_COUNT = MOVE_COUNT * 2;
     static int actualEvents = 0;
 
     public static void main(String []s)
@@ -80,8 +82,10 @@
         }
 
         Util.waitForIdle(robot);
-        if (actualEvents != MOVE_COUNT * 2) {
-            AbstractTest.fail("Expected events count: "+ MOVE_COUNT+" Actual events count: "+ actualEvents);
+        //Not fair to check for multiplier 4 as it's not specified actual number of WheelEvents
+        //result in a single wheel rotation.
+        if (actualEvents != EXPECTED_COUNT) {
+            AbstractTest.fail("Expected events count: "+ EXPECTED_COUNT+" Actual events count: "+ actualEvents);
         }
     }
 }