java7, XMLEncoder problems

for the last few days i’ve been looking into java7… it surely seems faster. but also some of my old code broke when run under it.

first i’ve done unscientific benchmark to see “what’s in it for me” [what performance improvements does new jvm / new garbage collector bring]. most cpu-intensive part in my code is generation and parsing of xml that gets read from/written to mysql. being a practical person [read: lazy] i googled for few minutes and found this benchmark. i’ve run it few dozen of times on two different servers using identical data set. on each server i executed it using java 1.6.25 and 1.7.0_01. one machine was a 3 years old X5460 based server and another – a brand new box with E3-1270 inside. results:

more data: here and here.

unsurprising conclusion? it’s worth upgrading. my tests run ~10% faster under java7.

but… i’ve stumbled on a problem: XMLEncoder in java7 seems to work differently than in the previous versions. it does not serialize to xml HashSet and possibly other properties of objects. i did not find anything reasonable on the net – just one post about similar issue. fortunately my xmls are short-lived [session data] so i have liberty of changing the data format whenever i need to. which i did – i started using xstream for xml [de]serialization of objects.

i’ve posted my problem at stackoverflow but i did not get reply in the first few minutes, so most probably i’ll never get one.

2 thoughts on “java7, XMLEncoder problems

  1. Hi

    i posted reply to your question on stackoverflow. its very simple solution. you need to follow java convention so that XMLEncoder can properly convert the object into xml. you need to make your data member private and getters/setters should be public and thats it.

    cheers

Leave a Reply to Kashif Khan Cancel reply

Your email address will not be published. Required fields are marked *

(Spamcheck Enabled)