-
Bug
-
Resolution: Fixed
-
P2
-
jt2.1.4, 1.4.0
-
beta
-
x86, sparc
-
linux, solaris_2.6, solaris_7, windows_nt, windows_2000
-
Verified
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.
======================================================================
- duplicates
-
JDK-4402240 api/java_beans/PropertyChangeEvent/serial/index.html#InputTests,JCK13, MerlinB46
- Closed
-
JDK-4402251 api/java_net/URL/serial/index.html#InputTests, Merlin, b46, x86, Sparc
- Closed
-
JDK-4402297 api/java_util, Merlin, x86, Sparc, b46, JCK13
- Closed
-
JDK-4402419 api/java_text , merlin, B46, Sparc, x86, JCK13
- Closed
-
JDK-4402748 api/java_lang/, Merlin, x86, Sparc, B46, JCK13,
- Closed
-
JDK-4402754 api/java_lang/Throwable/serial/index.html#InputTests, Merlin, x86, Sparc, B46
- Closed
-
JDK-4407005 JCK13a 7 api/java_beans/beancontext/ Merlin b48 sparc, x86
- Closed
-
JDK-4407269 JCK13a :api/java_util/PropertyPermission/serial,Merlin-b48,sol-sparc,X86
- Closed
-
JDK-4407314 JCK13a :Permission failure ,Merlin-b48,sol-sparc,X86
- Closed
-
JDK-4407975 JCK13a : api/java_rmi/activation/ActivationDesc/serial,Merlin-b48,sol-x86,sparc
- Closed
-
JDK-4408038 JCK13a: api/java_rmi/RemoteException/serial,Merlin-b48,solaris-sparc,x86
- Closed
-
JDK-4408350 JCK13a:api/java_rmi/activation/ActivationGroupDesc/serial,Merlin-b48,sol-x86,spa
- Closed
- relates to
-
JDK-4404755 serialization spec doesn't explicitly specify format of field type strings
- Closed
-
JDK-4415578 JCK1.3a: Convert.streamObjectToObject does not work correctly
- Closed