users@jaxb.java.net

Re: Making JAXBContextImpl serializable

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Mon, 06 Nov 2006 10:38:12 -0800

Kenny MacLeod wrote:
> A have a slightly unusual request here, but what would be involved in
> making com.sun.xml.bind.v2.runtime.JaxbContextImpl serializable?
>
> I ask because I'm playing with writing a mechanism which can serialize
> the context to a disk file in order to improve application startup time
> (JAXBContext construction for a complex schema is *very* expensive).
>
> I could just use an alternative serialization mechanism which doesn't
> require java.iot.Serializable (e.g. JBoss Serialization or XStream), but
> I'd rather just use vanilla java.

Making JAXBContext serializable is an interesting idea. I'll go ahead
and implement it.

However, because the serialization has to be compatible with future
changes, and due to the nature of what JAXBRIContext holds on to
(synthesized classes, etc), it is unlikely that you'll gain any
performance improvement out of it, compared to JAXBContext.newInstance()
--- in fact, in all likelihood what I'll implement in
readObject/writeObject would be just to invoke JAXBContext.newInstance()
again.

Now, we do realize that the start-up performance of the RI has a
problem. This has been mostly because our benchmark metric is usually
driven by web service folks, where they care a lot more about the
sustained performance, so in a way our goal was skewed.

Your post is very timely because I was actually thinking about
improvements in this area. Would you be interested in helping me? Like
if you can a benchmark and see which part of JAXBContext.newInstance()
is hot, that would really help me.

I can do this on my own, by using some random schema, but I thought you
might like the idea that we are optimizing toward your schema!



-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com