Other |
---|
1.4.0 betaFixed |
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Relates :
|
|
Relates :
|
Name: ooR10001 Date: 01/15/2001 In jdk1.3 and older versions java.io.ObjectInputStream.readObject had allowed eigther dots or slashes to be in the field's class names in the serialized stream. Since jdk1.4 build b46, only slashes are allowed for class names of the fields in the stream but dots are no longer supported. It results in a fact that if the field contains one or more dots in it's class name, then it is not extracted from a stream and initialized with default value after deserialization. It causes compatibility problem. Serialization Grammar described in the Java Object Serialization Spec is more likely to be understood to use dots as class name separators, though it is not defined explicitly. Please, specify class names delimitiers in JOSS grammar more clearly or add support for dots in java.io.ObjectInputStream. This is a sample which shows this bug: ---------------------------------------- public class test { public static void main(String[] args) { try { java.io.FileInputStream fs = new java.io.FileInputStream("test.ser"); java.io.ObjectInputStream ois = new java.io.ObjectInputStream(fs); java.awt.Cursor c = (java.awt.Cursor)ois.readObject(); System.out.println(c.getName()); ois.close(); fs.close(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (java.io.IOException e) { e.printStackTrace(); } } } ---------------------------------------- Lets consider two streams for java.awt.Cursor: First stream is constructed correspond to JOSS Grammar, second is genereated by JDK1.4. First stream is: (Grammar compatible) ---------------------- offset 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef 00000000 ac ed 00 05 73 72 00 0f 6a 61 76 61 2e 61 77 74 .M..sr..java.awt 00000010 2e 43 75 72 73 6f 72 6f 6a 07 77 f7 12 01 a0 02 .Cursoroj.wB.... 00000020 00 02 49 00 04 74 79 79 65 4c 00 04 6e 61 6d 65 ..I..typeL..name 00000030 74 00 12 4c 6a 61 76 61 2e 6c 61 6e 67 2e 53 74 t..Ljava.lang.St 00000040 72 69 6e 67 3b 78 70 00 00 00 00 74 00 0e 44 65 ring;xp....t..De 00000050 66 61 75 6c 74 20 43 75 72 73 6f 72 fault Cursor ---------------------- Second stream is: (formed by JDK) ---------------------- offset 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef 00000000 ac ed 00 05 73 72 00 0f 6a 61 76 61 2e 61 77 74 .M..sr..java.awt 00000010 2e 43 75 72 73 6f 72 6f 6a 07 77 f7 12 01 a0 02 .Cursoroj.wB.... 00000020 00 02 49 00 04 74 79 79 65 4c 00 04 6e 61 6d 65 ..I..typeL..name 00000030 74 00 12 4c 6a 61 76 61 2f 6c 61 6e 67 2f 53 74 t..Ljava/lang/St 00000040 72 69 6e 67 3b 78 70 00 00 00 00 74 00 0e 44 65 ring;xp....t..De 00000050 66 61 75 6c 74 20 43 75 72 73 6f 72 fault Cursor ---------------------- These streams are differents only in two places - dots are replaced by slashes in 'java.lang.String' class name. Under jdk1.3 and older both streams are deserialized correctly, but under jdk1.4 build b46 first stream is not parsed correctly - deserialized object will have incorrect value in field 'name': default value null instead correct 'Default Cursor': test output for the first stream: --------------------------------- null --------------------------------- test output for the second stream: --------------------------------- Default Cursor --------------------------------- It causes many JCK serial test failures since they are using dots in field class names when create serial stream excplicitly using JOSS grammar. ======================================================================
|