-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta
-
sparc
-
solaris_2.6
Name: dsR10051 Date: 03/16/2001
Method
protected void writeObject(Object o) of class java.beans.XMLEncoder
does not write java.lang.Character object to the output stream.
Here is minimized test:
import java.io.*;
import java.beans.*;
public class Test0006 {
public static void main(String[] args) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
Object[] objects = {new Character('a')};
XMLEncoder xmlEnc = new XMLEncoder(os);
for (int i = 0; i < objects.length; i++) {
xmlEnc.writeObject(objects[i]);
}
xmlEnc.flush();
xmlEnc.close();
ByteArrayInputStream in = new ByteArrayInputStream(os.toByteArray());
XMLDecoder xmlDec = new XMLDecoder(in);
System.out.println("OutputStream");
System.out.println(os.toString());
for (int i = 0; i < objects.length; i++) {
Object res = xmlDec.readObject();
if (!objects[i].equals(res)) {
System.out.println("FAILED");
System.out.println("Object type: " + objects[i].getClass());
System.out.println("Result : " + res);
System.out.println("Expected: " + objects[i]);
}
}
}
}
--- Output ---
%java -version
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b55)
Java HotSpot(TM) Client VM (build 1.4beta-B55, mixed mode)
%java Test0006
Warning:
Cannot allocate colormap entry for default background
java.lang.InstantiationException: java.lang.Character
Continuing ...
java.lang.Exception: discarding statement XMLEncoder0.writeObject(Character0);
Continuing ...
OutputStream
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.4.0-beta" class="java.beans.XMLDecoder">
</java>
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
at java.beans.ObjectHandler.dequeueResult(XMLDecoder.java:270)
at java.beans.XMLDecoder.readObject(XMLDecoder.java:148)
at Test0006.main(Test0006.java:20)
%
======================================================================