harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r953360 - in /harmony/enhanced/java/trunk/classlib/modules/swing/src: main/java/common/javax/swing/tree/DefaultMutableTreeNode.java test/api/java.injected/javax/swing/JTree_DynamicUtilTreeNodeTest.java
Date Thu, 10 Jun 2010 15:50:25 GMT
Author: tellison
Date: Thu Jun 10 15:50:25 2010
New Revision: 953360

URL: http://svn.apache.org/viewvc?rev=953360&view=rev
Log:
Apply fix for HARMONY-2419 ([classlib][swing] JTree.DynamicUtilTreeNode.clone() returns DefaultMutableTreeNode
object)

Modified:
    harmony/enhanced/java/trunk/classlib/modules/swing/src/main/java/common/javax/swing/tree/DefaultMutableTreeNode.java
    harmony/enhanced/java/trunk/classlib/modules/swing/src/test/api/java.injected/javax/swing/JTree_DynamicUtilTreeNodeTest.java

Modified: harmony/enhanced/java/trunk/classlib/modules/swing/src/main/java/common/javax/swing/tree/DefaultMutableTreeNode.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/swing/src/main/java/common/javax/swing/tree/DefaultMutableTreeNode.java?rev=953360&r1=953359&r2=953360&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/swing/src/main/java/common/javax/swing/tree/DefaultMutableTreeNode.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/swing/src/main/java/common/javax/swing/tree/DefaultMutableTreeNode.java
Thu Jun 10 15:50:25 2010
@@ -505,8 +505,17 @@ public class DefaultMutableTreeNode impl
         return getUserObject() != null ? getUserObject().toString() : null;
     }
 
+    @Override
     public Object clone() {
-        return new DefaultMutableTreeNode(getUserObject());
+        try {
+            DefaultMutableTreeNode clone = (DefaultMutableTreeNode) super.clone();
+            // Spec says the new node must have no parent or children
+            clone.parent = null;
+            clone.children = null;
+            return clone;
+        } catch (CloneNotSupportedException e) {
+            throw new RuntimeException(e);
+        }
     }
 
 

Modified: harmony/enhanced/java/trunk/classlib/modules/swing/src/test/api/java.injected/javax/swing/JTree_DynamicUtilTreeNodeTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/swing/src/test/api/java.injected/javax/swing/JTree_DynamicUtilTreeNodeTest.java?rev=953360&r1=953359&r2=953360&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/swing/src/test/api/java.injected/javax/swing/JTree_DynamicUtilTreeNodeTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/swing/src/test/api/java.injected/javax/swing/JTree_DynamicUtilTreeNodeTest.java
Thu Jun 10 15:50:25 2010
@@ -148,6 +148,13 @@ public class JTree_DynamicUtilTreeNodeTe
         assertTrue(node.loadedChildren);
     }
 
+    public void testClone() {
+        Object obj = new Object();
+        DynamicUtilTreeNode t = new DynamicUtilTreeNode(obj, obj);
+        Object cl = t.clone();
+        assertEquals(t.getClass(), cl.getClass());
+    }
+
     public void testChildren() throws Exception {
         DynamicUtilTreeNode node = new DynamicUtilTreeNode("value", new Object[] { "1", "2"
});
         assertFalse(node.loadedChildren);



Mime
View raw message