On Sep 26, 2011, at 2:28 AM, Fredrik Jonson wrote:

> In <[email protected]> David Blevins wrote:
> 
>> # JAXB Accessors
>> 
>> One of the biggest polluters of the class space is JAXB as it generates
>> accessors for all the fields.  First thought is, gee, I wonder if we can do
>> that at build time and keep the class definitions.  If there's some way we
>> could write down those classes, it could save us a lot of trouble at
>> runtime.
> 
> I'm sure I misunderstand you. Are you saying that openejb is generating
> class-files from jaxb schemas in runtime?

The JAXB RI itself generates byte code internally to eliminate the need for 
reflection by creating non-static inner classes that can get/set the private 
state (Foo$JaxbAccessor..).

  people.apache.org/~dblevins/jaxb-accessors.png

Unfortunately, heavy reflection is used in the process of creating these 
classes so it ends up being a "slow start, faster afterwards" kind of a 
trade-off.  If we could simply keep these classes and pack them in the jar at 
build time, we could eliminate the slow start part and just get straight to the 
"fast" part.

Not sure if there is already some special flag to do that or if we'd need to 
hack something up.  But where there's a will there's a way.

Worst case scenario is we find whatever class it is in the RI that calls 
'Unsafe.defineClass(...)' and replace it with a version that also writes the 
bytes to disk.  We then put that class in the endorsed dir and wrap it up as 
some kind of maven plugin or command-line tool.

Couple days of hacking for an awesome return.


-David

Reply via email to