-
Bug
-
Resolution: Fixed
-
P3
-
1.1.6
-
b01
-
generic
-
generic, solaris_2.5
-
Not verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2021241 | 1.2.0 | Joe Fialli | P3 | Resolved | Fixed | 1.2fcs |
Name: tb29552 Date: 06/16/98
//(company - Athena Design, Inc. , email - ###@###.###)
/* There's a bug in the 1.1.6 Object Serialization routines.
* Specifically, the ObjectStreamClass holds information
* about classes that have been included in a given stream.
* This information includes whether the class has a
* writeObject method, the SC_WRITE_METHOD bit. in 1.1.6, a
* flag, SC_BLOCK_DATA was added to the ObjectStreamClass.
* This is apparently in anticipation of some future
* extensions to the way that objects are serialized without
* breaking serialization streams written with versions
* prior to 1.1.6.
*
* Unfortunately, the SC_BLOCK_DATA flag is the same as the
* SC_WRITE_METHOD flag and thus, all classes that have
* writeObject() methods are marked as BLOCK_DATA. It seems
* that this was an over-sight but it hoses many of
* Integer's classes.
* */
import java.io.*;
public class SerTest implements Externalizable
{
private transient long v1 = 2;
private transient long v2 = 4;
private static final int numTest = 100;
public static void outputMessage(){
System.out.println("java.version = " +
System.getProperty("java.version"));
System.out.println("O/S Name = " +
System.getProperty("os.name"));
System.out.println("O/S architecture = " +
System.getProperty("os.arch"));
System.out.println("O/S version = " +
System.getProperty("os.version"));
}
public static void main(String argv[])
{
outputMessage();
SerTest[] sers = new SerTest[numTest];
int x;
for (x = 0; x < numTest; x++)
sers[x] = new SerTest(x);
try {
FileOutputStream fos = new FileOutputStream("/tmp/fruitbat");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeInt(numTest);
for (x = 0; x < numTest; x++)
oos.writeObject(sers[x]);
oos.flush();
oos.close();
fos.flush();
fos.close();
FileInputStream fis = new FileInputStream("/tmp/fruitbat");
ObjectInputStream ois = new ObjectInputStream(fis);
int n = ois.readInt();
for (x = 0; x < n; x++) {
sers[x] = (SerTest) ois.readObject();
}
} catch (Exception e) {
e.printStackTrace();
}
System.err.println("Done");
System.exit(0);
}
public SerTest()
{
}
public SerTest(int v)
{
v1 = v;
v2 = v * 2;
}
public void readExternal(ObjectInput in)
throws java.io.IOException
{
v1 = in.readLong();
v2 = in.readLong();
}
public void writeExternal(ObjectOutput out)
throws java.io.IOException
{
out.writeLong(v1);
out.writeLong(v2);
}
private void readObject(ObjectInputStream ois)
throws IOException
{
readExternal(ois);
}
private void writeObject(ObjectOutputStream oos)
throws IOException
{
writeExternal(oos);
}
}
(Review ID: 32760)
======================================================================
- backported by
-
JDK-2021241 Incompatibility: fail read instance of Externalizable class defining writeObject
-
- Resolved
-
- duplicates
-
JDK-4146078 Incompatibility: fail read instance of Externalizable class defining writeObject
-
- Closed
-