beehive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kyle Marvin (JIRA)" <>
Subject [jira] Commented: (BEEHIVE-149) Bean introspection fails for annotation-valued properties
Date Mon, 03 Jan 2005 19:23:50 GMT
     [ ]
Kyle Marvin commented on BEEHIVE-149:

Unfortunately, the fix isn't as simple as I'd like... Apparently, the java beans introspection
code *requires* that the arg type of the setter and the return type of the getter must match
up, or you'll get an exception like:

java.beans.IntrospectionException: type mismatch between read and write methods
        at java.beans.PropertyDescriptor.findPropertyType(
        at java.beans.PropertyDescriptor.setWriteMethod(
        at java.beans.PropertyDescriptor.<init>(

even if you explicitly give it the read/write methods in the PropertyDescriptor constructor.

The implication is that annotation type-valued property setters or getters must either a)
use a PropertyMap as both the return and set value types, or b) use the original annotation
type as the return and set value types.

I'm leaning towards b) because it provides better typed accessors (you just call the anotation
type member methods), at least for the property reading cases.   It also means standards dot-style
defering to access property values will work for annotation-typed properties, which seems
like a very key use case.

This means I'll also have to provide a mechanism to go from a PropertyMap to a typed proxy
instance, so setting an annotation valued property value would look something like:

         PropertyMap<AnnotType> propMap = new BeanPropertyMap<AnnotType>();

where PropertyMap.getProperty returns a PropertySetProxy instance that wraps the original
map.  Doing this cleanly also adds a need for using generic formal type parameters on the
PropertyMap interface and some of the associated impl classes.

> Bean introspection fails for annotation-valued properties
> ---------------------------------------------------------
>          Key: BEEHIVE-149
>          URL:
>      Project: Beehive
>         Type: Bug
>   Components: Controls
>     Versions: V1Alpha
>     Reporter: Kyle Marvin
>     Assignee: 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>(
>         at java.beans.PropertyDescriptor.<init>(
>         at org.apache.beehive.controls.test.controls.basic.HelloBeanBeanInfo.initPropertyDescriptors(
>         at org.apache.beehive.controls.test.controls.basic.HelloBeanBeanInfo.getPropertyDescriptors(
>         at java.beans.Introspector.getTargetPropertyInfo(
>         at java.beans.Introspector.getBeanInfo(
>         at java.beans.Introspector.getBeanInfo(
> 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

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
If you want more information on JIRA, or have a bug to report see:

View raw message