cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Neil (London)" <neillat...@hotmail.com>
Subject Problem in JAXBContextInitializer.addType
Date Wed, 12 Sep 2007 15:59:06 GMT

I have tried to update from 2.0 to 2.0.1 and have come across an issue when
the service is being initialized using JAXBDatabinding.initialize(service),
and is searching through all the Class types used in the code.

One of my method parameters which in a object that extends ArrayList and
only overrides “public boolean add(Object o)”, results in a class cast
exception.

The problem occurs when it tries to add the class type for the return type
of the method:

public java.lang.Object[] java.util.ArrayList.toArray(java.lang.Object[])

java.lang.Object[] has a type of  GenericArrayTypeImpl, and therefore the
code executes the following lines of code in JAXBContextInitializer.addType:

else if (cls instanceof GenericArrayType) {
           	GenericArrayType gt = (GenericArrayType)cls;
Class ct = (Class) gt.getGenericComponentType();
            ct = Array.newInstance(ct, 0).getClass();
            
addClass(ct);
}

The genericComponentType of  GenericArrayType is TypeVariableImpl which can
not be cast to a Class, and therefore I get the following exception:

java.lang.ClassCastException:
sun.reflect.generics.reflectiveObjects.TypeVariableImpl cannot be cast to
java.lang.Class

It seems that in CXF 2.0.1, the walkReferences method was added to getClass
which causes all the classes in the method parameters to be initialized –
previously this was not the case, and therefore my code worked with CXF 2.0.

Do you have any ideas? I am unfamiliar with TypeVariableImpl – is this not a
Class?

-- 
View this message in context: http://www.nabble.com/Problem-in-JAXBContextInitializer.addType-tf4430244.html#a12638435
Sent from the cxf-issues mailing list archive at Nabble.com.


Mime
View raw message