Hi all,
Let me disturb you with another boring "RI inconsistency in beans"
–type of message. :) It seems I found a bug in RI. In
java.beans.EventHandler. I think RI incorrectly determines properties
here. According to spec, common sense and even the RI's implementation
of java.beans.Introspector the following bean should not contain any
properties:
public static class MyBean {
public void setProp1() {}
}
because "setProp1()" is not a valid setter method – it does not
contain a new value to set.
However, the following test fails on RI:
<---
import java.beans.*;
public class TestBeanInfo1 {
public static class MyBean {
public void setProp1() {}
}
public static void main(String argv[]) throws Exception {
MyBean bean = new MyBean();
// "prop1" is neither the name of writeable property nor the
name of any public method
Object proxy = EventHandler.create(
PropertyChangeListener.class, bean, "prop1");
// just to show that Introspector doesn't see the property
with name "prop1"
PropertyDescriptor[] pds = Introspector.getBeanInfo(MyBean.class,
Introspector.USE_ALL_BEANINFO).getPropertyDescriptors();
for (int i = 0; i < pds.length; i++) {
System.out.println("Property found: " + pds[i].getName());
}
// should throw exception
try {
((PropertyChangeListener) proxy).propertyChange(
new PropertyChangeEvent(bean, "prop1", "1", "2"));
System.out.println("FAIL");
} catch (Throwable t) {
System.out.println("PASS");
}
}
}
<---
So it determines "prop1" as a valid property. IMHO this behavior is
inconsistent and we should not follow RI. But I like to hear opinions
from the rest of the community.
Thanks,
--
Alexei Zakharov,
Intel Middleware Product Division
---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]