You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Alexei Zakharov (JIRA)" <ji...@apache.org> on 2006/10/16 19:09:46 UTC
[jira] Created: (HARMONY-1884) [classlib][beans] RI inconsistency
in EventHandler
[classlib][beans] RI inconsistency in EventHandler
----------------------------------------------------
Key: HARMONY-1884
URL: http://issues.apache.org/jira/browse/HARMONY-1884
Project: Harmony
Issue Type: Bug
Components: Non-bug differences from RI
Environment: winXP
Reporter: Alexei Zakharov
It seems to be 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. It was decided in the list [1] that we should file "Non-bug differences from RI" JIRA here.
[1] http://mail-archives.apache.org/mod_mbox/incubator-harmony-dev/200610.mbox/%3c2c9597b90610160811h3ce01126i2359285429ac4e52@mail.gmail.com%3e
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (HARMONY-1884) [classlib][beans] RI inconsistency
in EventHandler
Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/HARMONY-1884?page=comments#action_12449447 ]
Alexei Zakharov commented on HARMONY-1884:
------------------------------------------
"testInvalidProperties_HY1884" was added to EventHandlerTest at r474437.
> [classlib][beans] RI inconsistency in EventHandler
> --------------------------------------------------
>
> Key: HARMONY-1884
> URL: http://issues.apache.org/jira/browse/HARMONY-1884
> Project: Harmony
> Issue Type: Bug
> Components: Non-bug differences from RI
> Environment: winXP
> Reporter: Alexei Zakharov
>
> It seems to be 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. It was decided in the list [1] that we should file "Non-bug differences from RI" JIRA here.
> [1] http://mail-archives.apache.org/mod_mbox/incubator-harmony-dev/200610.mbox/%3c2c9597b90610160811h3ce01126i2359285429ac4e52@mail.gmail.com%3e
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (HARMONY-1884) [classlib][beans] RI inconsistency
in EventHandler
Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/HARMONY-1884?page=comments#action_12449439 ]
Alexei Zakharov commented on HARMONY-1884:
------------------------------------------
The test case to illustrate another aspect of above problem. I'm going to add the corresponding regression test to EventHanlderTest.
public void testInvalidProperties_HY1884() {
BeanWithInvalidProps bean = new BeanWithInvalidProps();
Object proxy;
// "prop2" is neither the name of valid property nor the
// name of any public method
// "is" prefix for big Boolean
proxy = EventHandler.create(
PropertyChangeListener.class, bean, "goodProp3", "source.prop2");
try {
((PropertyChangeListener) proxy).propertyChange(
new PropertyChangeEvent(bean, "goodProp3", true, false));
fail();
} catch (Exception e) {
// expected
}
}
public static class BeanWithInvalidProps {
// Introspector doesn't support "is" prefix for big Boolean
public Boolean isProp2() {
return new Boolean(true);
}
// needed to test prop2
public void setGoodProp3(boolean value) {}
}
> [classlib][beans] RI inconsistency in EventHandler
> --------------------------------------------------
>
> Key: HARMONY-1884
> URL: http://issues.apache.org/jira/browse/HARMONY-1884
> Project: Harmony
> Issue Type: Bug
> Components: Non-bug differences from RI
> Environment: winXP
> Reporter: Alexei Zakharov
>
> It seems to be 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. It was decided in the list [1] that we should file "Non-bug differences from RI" JIRA here.
> [1] http://mail-archives.apache.org/mod_mbox/incubator-harmony-dev/200610.mbox/%3c2c9597b90610160811h3ce01126i2359285429ac4e52@mail.gmail.com%3e
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira