On 07/17/2012 05:40 AM, Ullrich Hafner wrote:
we can
add a check for final fields and the absence of the corresponding tag in
the serialized XML during XStream processing and issue a warning.

I thought of that, but I am afraid it would give a false warning in case the 
field was really null when serialized; for example

package p;
class MyData {
  final String id;
  MyData(String id) {
    id = Util.fixEmpty(id);
  }
}

would I guess produce

<p.myData/>

after serializing new MyData(""), which is correct.

(This is why automatic, reflection-driven serialization is still a bad idea 
even when you dress it up in XML...)

Reply via email to