Bean introspection fails for annotation-valued properties
---------------------------------------------------------

         Key: BEEHIVE-149
         URL: http://nagoya.apache.org/jira/browse/BEEHIVE-149
     Project: Beehive
        Type: Bug
  Components: Controls  
    Versions: V1Alpha    
    Reporter: Kyle Marvin
 Assigned to: Kyle Marvin 
    Priority: Minor
     Fix For: V1Beta


BeanInfo introspection of a Control type that has a property that is based upon 
a JSR-175 annotation type will fail w/ an Introspection exception.   The 
following is a sample exception, based upon the 
org.apache.beehive.controls.test.controls.basic.Hello test control included in 
the checkin tests:

Caused by: java.beans.IntrospectionException: Method not found: setGender
        at java.beans.PropertyDescriptor.<init>(PropertyDescriptor.java:93)
        at java.beans.PropertyDescriptor.<init>(PropertyDescriptor.java:53)
        at 
org.apache.beehive.controls.test.controls.basic.HelloBeanBeanInfo.initPropertyDescriptors(HelloBeanBeanInfo.java:137)
        at 
org.apache.beehive.controls.test.controls.basic.HelloBeanBeanInfo.getPropertyDescriptors(HelloBeanBeanInfo.java:149)
        at java.beans.Introspector.getTargetPropertyInfo(Introspector.java:475)
        at java.beans.Introspector.getBeanInfo(Introspector.java:385)
        at java.beans.Introspector.getBeanInfo(Introspector.java:155)

The rub is that the java.beans.PropertyDescriptor class expects to find a 
method with the following signature:

        public void setGender(Gender gender);

while bean exposes the following instead:

        public void setGender(PropertyMap genderMap);

This is because it is impossible to 'new' a JSR-175 annotation type and 
initialize its values, so the PropertyMap interface (and the corresponsing 
concrete impl, BeanPropertyMap) exists to abstract a collection of annotation 
type property values.  You can create a BeanPropertyMap, push values into it, 
and then use it to set the (annotation-typed) property.

The fix is to modify the BeanInfo codegen to use the 
java.beans.PropertyDescriptor constructor that takes actual 
java.lang.reflect.Methods as arguments, to explicitly specify the specific 
setter method on the bean class instead of allowing PropertyDescriptor to use 
the default algorithm.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira

Reply via email to