XMLEncoder and Non-XML Characters
XMLEncoder does not appear to properly handle Strings containing certain characters which are invalid in XML documents. It can handle quotes and whatnot just fine, but the following code
PipedInputStream pis =new PipedInputStream();
PipedOutputStream pos =new PipedOutputStream(pis);
XMLEncoder encoder =new XMLEncoder(pos);
encoder.writeObject("test" + (char) 0);
encoder.close();
XMLDecoder decoder =new XMLDecoder(pis);
System.out.println(decoder.readObject());
produces this exception
org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x0) was found in the element content of the document.
Continuing ...
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
and thus the string is lost.
I was considering using XMLEncoder/XMLDecoder as an alternative to object stream serialization because the latter has trouble handling field renames and whatnot (it explodes quite violently if you deserialize a stream containing an enum value you have since removed). XMLEncoder/XMLDecoder seemed to have better error handling in that errors didn't fatalize the stream; you could recover, be notified and so on. However, discovering it can't handle a very fundamental class makes me a bit more than nervous about using it.
Any suggestions?

