-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
1.4.0
-
sparc
-
solaris_2.6
Name: ooR10001 Date: 04/23/2001
Method readObject() in java.awt.ScrollPane incorrectly deserializes object
from a stream made under previous version of JDK. This is a compatibility
problem.
Following test shows this bug:
This code should be executed under jdk1.3. It makes a stream with serialized
instance of java.awt.ScrollPane.
-----------------
import java.awt.ScrollPane;
public class t {
public static void main(String[] args) {
try {
java.io.FileOutputStream fos =
new java.io.FileOutputStream("test.ser");
java.io.ObjectOutputStream oos = new java.io.ObjectOutputStream(fos);
ScrollPane ex = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
System.out.println("To stream: " + ex.getScrollbarDisplayPolicy());
oos.writeObject(ex);
oos.close();
fos.close();
} catch (java.io.IOException e) {
e.printStackTrace();
}
}
-----------------
Output: (shows value of scrollbarDisplayPolicy)
----------------
To stream: 1
----------------
Following code should be exucuted under jdk1.4. It is deserialize an object from
a stream and shows deserialized scrollbarDisplayPolicy.
---------------------
public class t {
public static void main(String[] args) {
try {
java.io.FileInputStream fis =
new java.io.FileInputStream("test.ser");
java.io.ObjectInputStream ois = new java.io.ObjectInputStream(fis);
ScrollPane x = (ScrollPane)ois.readObject();
System.out.println("From stream: " + x.getScrollbarDisplayPolicy());
ois.close();
fis.close();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (java.io.IOException e) {
e.printStackTrace();
}
}
---------------------
Output:
-------------------
>From stream: 0
-------------------
======================================================================
- duplicates
-
JDK-4427881 ObjectInputStream.GetField.get() broken for primitive fields
- Closed