-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
6
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
JRE 1.3.1 throws the following exception when deserializing a DecimalFormat instance serialized by JRE 1.6.0. This does not occur for instances serialized by JRE 1.5.0.
java.io.StreamCorruptedException: Type code out of range, is 126
at java.io.ObjectInputStream.peekCode(ObjectInputStream.java:1551)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:287)
at java.io.ObjectInputStream.inputClassFields(ObjectInputStream.java:2258)
at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:514)
at java.text.DecimalFormat.readObject(DecimalFormat.java:2017)
at java.lang.reflect.Method.invoke(Native Method)
at java.io.ObjectInputStream.invokeObjectReader(ObjectInputStream.java:2209)
at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1406)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:381)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:231)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the following classes.
2. Run SerializeTest using JRE 1.6.0
3. Run DeserializeTest using 1.3.1
-----------------------------------------------------------------------
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.text.DecimalFormat;
public class SerializeTest {
public static void main(String[] args) throws Exception {
ObjectOutputStream out = new ObjectOutputStream(
new FileOutputStream("DecimalFormatSerialized"));
out.writeObject(new DecimalFormat("#,###"));
out.close();
}
}
-----------------------------------------------------------------------
import java.io.FileInputStream;
import java.io.ObjectInputStream;
public class DeserializeTest {
public static void main(String[] args) throws Exception {
ObjectInputStream in = new ObjectInputStream(
new FileInputStream("DecimalFormatSerialized"));
in.readObject();
in.close();
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Excpected DecimalFormat to be deserialized correctly.
ACTUAL -
DeserializeTest, when run using JRE 1.3.1, throws the exception above.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
See above
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
See above
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Don't serialize DecimalFormat. Instead, serialize a format pattern and recreate the DecimalFormat instance when needed.
Release Regression From : 5
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
JRE 1.3.1 throws the following exception when deserializing a DecimalFormat instance serialized by JRE 1.6.0. This does not occur for instances serialized by JRE 1.5.0.
java.io.StreamCorruptedException: Type code out of range, is 126
at java.io.ObjectInputStream.peekCode(ObjectInputStream.java:1551)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:287)
at java.io.ObjectInputStream.inputClassFields(ObjectInputStream.java:2258)
at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:514)
at java.text.DecimalFormat.readObject(DecimalFormat.java:2017)
at java.lang.reflect.Method.invoke(Native Method)
at java.io.ObjectInputStream.invokeObjectReader(ObjectInputStream.java:2209)
at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1406)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:381)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:231)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the following classes.
2. Run SerializeTest using JRE 1.6.0
3. Run DeserializeTest using 1.3.1
-----------------------------------------------------------------------
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.text.DecimalFormat;
public class SerializeTest {
public static void main(String[] args) throws Exception {
ObjectOutputStream out = new ObjectOutputStream(
new FileOutputStream("DecimalFormatSerialized"));
out.writeObject(new DecimalFormat("#,###"));
out.close();
}
}
-----------------------------------------------------------------------
import java.io.FileInputStream;
import java.io.ObjectInputStream;
public class DeserializeTest {
public static void main(String[] args) throws Exception {
ObjectInputStream in = new ObjectInputStream(
new FileInputStream("DecimalFormatSerialized"));
in.readObject();
in.close();
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Excpected DecimalFormat to be deserialized correctly.
ACTUAL -
DeserializeTest, when run using JRE 1.3.1, throws the exception above.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
See above
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
See above
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Don't serialize DecimalFormat. Instead, serialize a format pattern and recreate the DecimalFormat instance when needed.
Release Regression From : 5
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
- duplicates
-
JDK-6240271 Deserializing an object with a new field throws java.io.StreamCorruptedException
-
- Closed
-