harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhouke...@apache.org
Subject svn commit: r932296 - in /harmony/enhanced/java/trunk/classlib/modules/beans/src: main/java/java/beans/ArrayPersistenceDelegate.java test/java-internal/java/beans/ArrayPersistenceDelegateTest.java
Date Fri, 09 Apr 2010 08:27:07 GMT
Author: zhoukevin
Date: Fri Apr  9 08:27:07 2010
New Revision: 932296

URL: http://svn.apache.org/viewvc?rev=932296&view=rev
Log:
Refine the patch for HARMONY-6340: remove XMLEncoderTest from the exclude list and add a test
case for recreation.

Modified:
    harmony/enhanced/java/trunk/classlib/modules/beans/src/main/java/java/beans/ArrayPersistenceDelegate.java
    harmony/enhanced/java/trunk/classlib/modules/beans/src/test/java-internal/java/beans/ArrayPersistenceDelegateTest.java

Modified: harmony/enhanced/java/trunk/classlib/modules/beans/src/main/java/java/beans/ArrayPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/beans/src/main/java/java/beans/ArrayPersistenceDelegate.java?rev=932296&r1=932295&r2=932296&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/beans/src/main/java/java/beans/ArrayPersistenceDelegate.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/beans/src/main/java/java/beans/ArrayPersistenceDelegate.java
Fri Apr  9 08:27:07 2010
@@ -49,11 +49,8 @@ class ArrayPersistenceDelegate extends P
         assert newInstance != null && newInstance.getClass().isArray() : newInstance;
 
         int length = Array.getLength(oldInstance);
-        Class<?> componentType = type.getComponentType();
-        Object nullValue = Array.get(Array.newInstance(componentType, 1), 0);
 
         for (int i = 0; i < length; ++i) {
-
             Object oldValue = Array.get(oldInstance, i);
             Object newValue = Array.get(newInstance, i);
             if (!deepEquals(oldValue, newValue)) {
@@ -72,11 +69,17 @@ class ArrayPersistenceDelegate extends P
             return false;
         }
         // oldInstnace != newInstance
-        if (oldInstance.equals(newInstance)) {
+        if (oldInstance.getClass().isAssignableFrom(newInstance.getClass())
+                && oldInstance.equals(newInstance)) {
             return true;
-        } else if (oldInstance.getClass().isArray() && newInstance.getClass().isArray())
{
-            int length = Array.getLength(oldInstance);
-            for (int i = 0; i < length; ++i) {
+        } else if (oldInstance.getClass().isArray()
+                && newInstance.getClass().isArray()) {
+            int length1 = Array.getLength(oldInstance);
+            int length2 = Array.getLength(newInstance);
+            if (length1 != length2) {
+                return false;
+            }
+            for (int i = 0; i < length1; i++) {
                 Object oldValue = Array.get(oldInstance, i);
                 Object newValue = Array.get(newInstance, i);
                 if (!deepEquals(oldValue, newValue)) {

Modified: harmony/enhanced/java/trunk/classlib/modules/beans/src/test/java-internal/java/beans/ArrayPersistenceDelegateTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/beans/src/test/java-internal/java/beans/ArrayPersistenceDelegateTest.java?rev=932296&r1=932295&r2=932296&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/beans/src/test/java-internal/java/beans/ArrayPersistenceDelegateTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/beans/src/test/java-internal/java/beans/ArrayPersistenceDelegateTest.java
Fri Apr  9 08:27:07 2010
@@ -17,9 +17,7 @@
 
 package java.beans;
 
-import java.beans.ArrayPersistenceDelegate;
-import java.beans.Encoder;
-import java.beans.Expression;
+import java.io.ByteArrayOutputStream;
 import java.lang.reflect.Array;
 
 import junit.framework.TestCase;
@@ -166,4 +164,39 @@ public class ArrayPersistenceDelegateTes
         }
     }
 
+    public static class ParentClass {
+
+        String multiArray[][][] = { { { "1", "2" } }, { { "3", "4", "5" } },
+                { { "1", "2" }, { "3", "4", "5" } } };
+
+        public ParentClass() {
+        }
+
+        public String[][][] getMultiArray() {
+            return multiArray;
+        }
+
+        public void setMultiArray(String[][][] array) {
+            multiArray = array;
+        }
+
+    }
+
+    public static class ChildClass extends ParentClass {
+
+        public ChildClass() {
+
+        }
+
+    }
+
+    public void testInitialize_MultiArray() throws Exception {
+        ChildClass child = new ChildClass();
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        XMLEncoder xmlEncoder = new XMLEncoder(bos);
+        xmlEncoder.writeObject(child);
+        xmlEncoder.close();
+        assertFalse(bos.toString("UTF-8").contains("multiArray"));
+    }
+
 }



Mime
View raw message