harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexei Zakharov (JIRA)" <j...@apache.org>
Subject [jira] Closed: (HARMONY-1920) [classlib][luni] class replacement in ObjectInputStream.resolveClass() should not work for different class names
Date Wed, 08 Nov 2006 12:44:56 GMT
     [ http://issues.apache.org/jira/browse/HARMONY-1920?page=all ]

Alexei Zakharov closed HARMONY-1920.
------------------------------------


verified by Mikhail

> [classlib][luni] class replacement in ObjectInputStream.resolveClass() should not work
for different class names
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1920
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1920
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: IA32, Win XP
>            Reporter: Mikhail Markov
>         Assigned To: Alexei Zakharov
>         Attachments: HY1920-ObjectInputStream.patch, HY1920-ObjectInputStreamTest.patch
>
>
> Object serialization specification states that starting from JDK 1.6 method resolveClass
in ObjectInputStream class should to return a class with at least the same *base* class name
and SerialVersionUID as the class provided for replacement. The following test passes on RI
but fails on Harmony:
> ------------------------- Test.java -----------------------------
> import java.io.*;
> public class Test {
>     public static void main(String[] args) throws Exception {
>         TestClass1 to1 = new TestClass1();
>         to1.i = 555;
>         ByteArrayOutputStream baos = new ByteArrayOutputStream();
>         ObjectOutputStream oos = new ObjectOutputStream(baos);
>         oos.writeObject(to1);
>         oos.flush();
>         byte[] bytes = baos.toByteArray();
>         ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
>         ObjectInputStream ois = new TestObjectInputStream(bais);
>         try {
>             TestClass2 to2 = (TestClass2) ois.readObject();
>             System.out.println("Test failed.");
>         } catch (InvalidClassException ice) {
>             System.out.println("Test passed.");
>         }
>     }
>     static class TestObjectInputStream extends ObjectInputStream {
>         public TestObjectInputStream(InputStream in) throws IOException {
>             super(in);
>         }
>  
>         protected Class resolveClass(ObjectStreamClass desc)
>                 throws IOException, ClassNotFoundException {
>             if (desc.getName().equals("Test$TestClass1")) {
>                 return TestClass2.class;
>             }
>             return super.resolveClass(desc);
>         }
>     }
>     static class TestClass1 implements Serializable {
>         private static final long serialVersionUID = 11111L;
>         int i = 0;
>     }
>     static class TestClass2 implements Serializable {
>         private static final long serialVersionUID = 11111L;
>         int i = 0;
>     }
> }
> -----------------------------------------------------------------

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message