You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Mikhail Markov (JIRA)" <ji...@apache.org> on 2006/10/19 16:22:34 UTC
[jira] Created: (HARMONY-1920) [classlib][luni] class replacement
in ObjectInputStream.resolveClass() should not work for different class
names
[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
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
[jira] Resolved: (HARMONY-1920) [classlib][luni] class replacement
in ObjectInputStream.resolveClass() should not work for different class
names
Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/HARMONY-1920?page=all ]
Alexei Zakharov resolved HARMONY-1920.
--------------------------------------
Resolution: Fixed
> [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
[jira] Closed: (HARMONY-1920) [classlib][luni] class replacement in
ObjectInputStream.resolveClass() should not work for different class names
Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
[ 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
[jira] Commented: (HARMONY-1920) [classlib][luni] class replacement
in ObjectInputStream.resolveClass() should not work for different class
names
Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/HARMONY-1920?page=comments#action_12446992 ]
Alexei Zakharov commented on HARMONY-1920:
------------------------------------------
Patches were applied at revision 470861. Mikhail, please verify that it fully resolves the issue.
> [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
[jira] Assigned: (HARMONY-1920) [classlib][luni] class replacement
in ObjectInputStream.resolveClass() should not work for different class
names
Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/HARMONY-1920?page=all ]
Alexei Zakharov reassigned HARMONY-1920:
----------------------------------------
Assignee: Alexei Zakharov
> [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
[jira] Commented: (HARMONY-1920) [classlib][luni] class replacement
in ObjectInputStream.resolveClass() should not work for different class
names
Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/HARMONY-1920?page=comments#action_12447015 ]
Mikhail Markov commented on HARMONY-1920:
-----------------------------------------
Everything is ok. Thanks!
> [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
[jira] Commented: (HARMONY-1920) [classlib][luni] class replacement
in ObjectInputStream.resolveClass() should not work for different class
names
Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/HARMONY-1920?page=comments#action_12443543 ]
Mikhail Markov commented on HARMONY-1920:
-----------------------------------------
Error in JDK version: should be JDK1.1.6 :-)
> [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
>
> 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