harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r399946 - in /incubator/harmony/enhanced/classlib/trunk/modules: auth/make/common/build.xml luni/src/main/java/java/io/ObjectInputStream.java luni/src/test/java/tests/api/java/io/ObjectInputStreamTest.java
Date Fri, 05 May 2006 04:17:20 GMT
Author: smishura
Date: Thu May  4 21:17:19 2006
New Revision: 399946

URL: http://svn.apache.org/viewcvs?rev=399946&view=rev
Log:
Apply updated patch for HARMONY-91 (Serialization: fails to deserialize stream in case of
added class to hierarchy). All serialization tests passed.

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/auth/make/common/build.xml
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectInputStreamTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/make/common/build.xml
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/auth/make/common/build.xml?rev=399946&r1=399945&r2=399946&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/make/common/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/make/common/build.xml Thu May 
4 21:17:19 2006
@@ -133,8 +133,6 @@
                     <exclude name="org/apache/harmony/auth/internal/SecurityTest.java"/>
 
                     <!-- Harmony exclude list -->
-                    <exclude name="javax/security/auth/login/serialization/SerAccountExpiredExceptionTest.java"/>
-                    <exclude name="javax/security/auth/login/serialization/SerCredentialExpiredExceptionTest.java"/>
                     <exclude name="javax/security/auth/x500/X500PrincipalTest.java" />
                     <exclude name="tests/api/javax/security/auth/x500/X500PrincipalTest.java"
/>
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java?rev=399946&r1=399945&r2=399946&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java
Thu May  4 21:17:19 2006
@@ -1265,8 +1265,8 @@
 						readObjectForClass(object,
 								(ObjectStreamClass) streamClassList.get(j));
 					}
+					lastIndex = index + 1;
 				}
-				lastIndex = index + 1;
 			}
 		}
 	}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectInputStreamTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectInputStreamTest.java?rev=399946&r1=399945&r2=399946&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectInputStreamTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectInputStreamTest.java
Thu May  4 21:17:19 2006
@@ -530,7 +530,7 @@
 	/**
 	 * @tests java.io.ObjectInputStream#readObject()
 	 */
-	public void test_readObject() {
+	public void test_readObject() throws Exception {
 		// Test for method java.lang.Object
 		// java.io.ObjectInputStream.readObject()
 		try {
@@ -547,7 +547,93 @@
 		} catch (ClassNotFoundException e) {
 			fail("Exception serializing data : " + e.getMessage());
 		}
+        
+        // Regression for HARMONY-91
+        // dynamically create serialization byte array for the next hierarchy:
+        // - class A implements Serializable
+        // - class C extends A
+
+        byte[] cName = C.class.getName().getBytes();
+        byte[] aName = A.class.getName().getBytes();
+
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+        byte[] begStream = new byte[] { (byte) 0xac, (byte) 0xed, // STREAM_MAGIC
+                (byte) 0x00, (byte) 0x05, // STREAM_VERSION
+                (byte) 0x73, // TC_OBJECT
+                (byte) 0x72, // TC_CLASSDESC
+                (byte) 0x00, // only first byte for C class name length
+        };
+
+        out.write(begStream, 0, begStream.length);
+        out.write(cName.length); // second byte for C class name length
+        out.write(cName, 0, cName.length); // C class name
+
+        byte[] midStream = new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00,
+                (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+                (byte) 0x21, // serialVersionUID = 33L
+                (byte) 0x02, // flags
+                (byte) 0x00, (byte) 0x00, // fields : none
+                (byte) 0x78, // TC_ENDBLOCKDATA
+                (byte) 0x72, // Super class for C: TC_CLASSDESC for A class
+                (byte) 0x00, // only first byte for A class name length
+        };
+
+        out.write(midStream, 0, midStream.length);
+        out.write(aName.length); // second byte for A class name length
+        out.write(aName, 0, aName.length); // A class name
+
+        byte[] endStream = new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00,
+                (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+                (byte) 0x0b, // serialVersionUID = 11L
+                (byte) 0x02, // flags
+                (byte) 0x00, (byte) 0x01, // fields
+
+                (byte) 0x4c, // field description: type L (object)
+                (byte) 0x00, (byte) 0x04, // length
+                // field = 'name'
+                (byte) 0x6e, (byte) 0x61, (byte) 0x6d, (byte) 0x65,
+
+                (byte) 0x74, // className1: TC_STRING
+                (byte) 0x00, (byte) 0x12, // length
+                //
+                (byte) 0x4c, (byte) 0x6a, (byte) 0x61, (byte) 0x76,
+                (byte) 0x61, (byte) 0x2f, (byte) 0x6c, (byte) 0x61,
+                (byte) 0x6e, (byte) 0x67, (byte) 0x2f, (byte) 0x53,
+                (byte) 0x74, (byte) 0x72, (byte) 0x69, (byte) 0x6e,
+                (byte) 0x67, (byte) 0x3b,
+
+                (byte) 0x78, // TC_ENDBLOCKDATA
+                (byte) 0x70, // NULL super class for A class
+
+                // classdata
+                (byte) 0x74, // TC_STRING
+                (byte) 0x00, (byte) 0x04, // length
+                (byte) 0x6e, (byte) 0x61, (byte) 0x6d, (byte) 0x65, // value
+        };
+
+        out.write(endStream, 0, endStream.length);
+        out.flush();
+
+        // read created serial. form
+        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(
+                out.toByteArray()));
+        Object o = ois.readObject();
+        assertEquals(C.class, o.getClass());
 	}
+
+    public static class A implements Serializable {
+        private static final long serialVersionUID = 11L;
+
+        public String name = "name";
+    }
+
+    public static class B extends A {
+    }
+
+    public static class C extends B {
+        private static final long serialVersionUID = 33L;
+    }
 
 	/**
 	 * @tests java.io.ObjectInputStream#readObject()



Mime
View raw message