This patch makes us pass
gnu/testlet/java/awt/Component/requestFocus.java.  requestFocus was
throwing a NPE unexpectedly.  When looking for our top-level ancestor,
we should start with ourselves if we are Containers, and if not, then
start with getParent().  Before we were just starting with getParent().

Also, if we find no top-level ancestor, we should just return (this is a
standard != null check before continuing).

2005-10-28  Anthony Balkissoon  <[EMAIL PROTECTED]>

        * java/awt/Component.java:
        (requestFocus): If this component is a Container, start here, not at
        its parent when looking for the top-level ancestor.  If no top-level
        ancestor is found (parent == null), return.

--Tony
Index: java/awt/Component.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/Component.java,v
retrieving revision 1.81
diff -u -r1.81 Component.java
--- java/awt/Component.java	19 Oct 2005 16:09:09 -0000	1.81
+++ java/awt/Component.java	28 Oct 2005 16:05:51 -0000
@@ -3808,13 +3808,16 @@
       {
         synchronized (getTreeLock ())
           {
-            // Find this Component's top-level ancestor.
-            Container parent = getParent ();
-
+            // Find this Component's top-level ancestor.            
+            Container parent = (this instanceof Container) ? (Container) this
+                                                          : getParent();            
             while (parent != null
                    && !(parent instanceof Window))
               parent = parent.getParent ();
 
+            if (parent == null)
+              return;
+            
             Window toplevel = (Window) parent;
             if (toplevel.isFocusableWindow ())
               {
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to