This content has been marked as final.
Show 4 replies
-
1. Re: PropertyInfo type creation
starksm64 Aug 8, 2007 2:07 PM (in response to alesj)We should be restrictive on the type so if the setter is more specific use that. If its parameterized you have to assume somewhere SimpleBean bean = beans.get(0) is being used, and allowing a list for which this would not work would cause a CCE.
-
2. Re: PropertyInfo type creation
alesj Aug 9, 2007 10:22 AM (in response to alesj)"scott.stark@jboss.org" wrote:
We should be restrictive on the type so if the setter is more specific use that.
Any general rules on what is more restrictive?
Or how to write AbstractBeanInfoFactory.getPropertyType()? ;-) -
3. Re: PropertyInfo type creation
alesj Aug 9, 2007 10:28 AM (in response to alesj)"alesj" wrote:
Or how to write AbstractBeanInfoFactory.getPropertyType()? ;-)
Simple instructions would do ... -
4. Re: PropertyInfo type creation
starksm64 Aug 9, 2007 2:43 PM (in response to alesj)"alesj" wrote:
"scott.stark@jboss.org" wrote:
We should be restrictive on the type so if the setter is more specific use that.
Any general rules on what is more restrictive?
Or how to write AbstractBeanInfoFactory.getPropertyType()? ;-)
It has to be some compiler problem solution. It seems you have to have a type tree for the non-parameterized type and find the most derived type, and then the most derived parameterized type. For these two examples of property accessors, List would be determined for both.public List getBeans() { return beans; } public void setBeans(Iterable<SimpleBean> beans) { this.beans = beans; }
public Iterable<SimpleBean> getBeans() { return beans; } public void setBeans(List beans) { this.beans = beans; }
public Iterable<SimpleBean> getBeans() { return beans; } public void setBeans(List beans) { this.beans = beans; }
It gets more complicated if a concrete type vs an interface is used though, as in this crazy example:public Iterable<SimpleBean> getBeans() { return beans; } public void setBeans(javax.management.AttributeList beans) { this.beans = beans; }
where AttributeList is a non-parameterized List with overloaded methods for adding/setting elements of type javax.management.Attribute, a non-interface type. If SimpleBean is a class its impossible to reconcile all expected uses. Its possible if SimpleBean is an interface, but that is a crazy type graph to figure out.
I guess the main question is how much trouble do we want to go to at this point? What does the java.beans.Introspector return for the BeanInfo.PropertyDescriptor for such examples? Does it match up these as the same property with a common type, or does it see these as the same property with different accessors, or a conflict?