[JSR308] a problem with beans and annotations

David Goodenough david.goodenough at linkchoose.co.uk
Tue Sep 23 04:50:48 EDT 2008

Currently the Introspector code that fetches the Class object for a 
property (as expressed in PropertyDescriptor) picks up the Type from
the return type of the getter. 

In the old days (before annotations) this was fine, as the type returned
by the getter was the same as the type of the arguement to the setter
and was also the same as the underlying property.  But with annotations
this changes.  

Obtaining the value for the return type of the getter and the arguement
type for the setter can be achieved from the getReadMethod and 
getWriteMethod method so any annotations on those are accesible.  But
the annotations on the underlying field are not available.

So either a new method needs to be added to the PropertyDescriptor class
which returns the field type (where there is a corresponding field, null if 
there is no underlying field) or the definition of getPropertyType needs to be 
changed and it should return the field type.


More information about the JSR308 mailing list