users@jaxb.java.net

fix for possible bug in reflection library

From: Hunor Bartha <hunor.bartha_at_ambo.ro>
Date: Fri, 08 Jun 2007 09:56:03 +0300

Hello,

i'm using the reflection library and i had an exception when i tried to
access the runtime information from the jaxb pojos. I've posted a
message on this list with the error:

Exception in thread "main" java.lang.NullPointerException
    at
org.jvnet.jaxb.reflection.runtime.reflect.Accessor$FieldReflection.optimize(Unknown

Source)
    at
org.jvnet.jaxb.reflection.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.<init>(Unknown

Source)
    at
org.jvnet.jaxb.reflection.runtime.reflect.TransducedAccessor.get(Unknown
Source)
    at
org.jvnet.jaxb.reflection.model.impl.RuntimeClassInfoImpl.calcTransducer(Unknown

Source)
    at
org.jvnet.jaxb.reflection.model.impl.RuntimeClassInfoImpl.getTransducer(Unknown

Source)
    at
org.jvnet.jaxb.reflection.model.impl.RuntimeClassInfoImpl.link(Unknown
Source)
    at org.jvnet.jaxb.reflection.model.impl.ModelBuilder.link(Unknown
Source)
    at
org.jvnet.jaxb.reflection.model.impl.RuntimeModelBuilder.link(Unknown
Source)
    at org.jvnet.jaxb.reflection.JAXBModelFactory.create(Unknown Source)
    at org.jvnet.jaxb.reflection.JAXBModelFactory.create(Unknown Source)
    at org.jvnet.jaxb.reflection.JAXBModelFactory.create(Unknown Source)


The fix is an additional condition in the
org.jvnet.jaxb.reflection.runtime.reflect.Accessor.java (line 200)

        @Override
        public Accessor<BeanT,ValueT> optimize(JAXBContextImpl context) {
            if(*context!=null *&& context.fastBoot)
                // let's not waste time on doing this for the sake of
faster boot.
                return this;
            Accessor<BeanT,ValueT> acc = OptimizedAccessorFactory.get(f);
            if(acc!=null)
                return acc;
            else
                return this;
        }

I don't know it the exception is caused by improper usage of the library
or nut but i think the NPE guard won't do any harm, so would it be
possible to include it in the next release, or the nightly builds? Right
now with this fix i was able to solve our problems but it would be nice
if we could just use the official release not the one compiled by us.

Thanks,

hunor