harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Zhou (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-5973) [classlib] [beans] StandardBeanInfo fails to gain correct indexed read and write methods of a indexed property
Date Mon, 08 Sep 2008 09:12:46 GMT
[classlib] [beans] StandardBeanInfo fails to gain correct indexed read and write methods of
a indexed property
--------------------------------------------------------------------------------------------------------------

                 Key: HARMONY-5973
                 URL: https://issues.apache.org/jira/browse/HARMONY-5973
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
    Affects Versions: 5.0M7, 5.0M6
            Reporter: Kevin Zhou
             Fix For: 5.0M8


Consider test case [1] and bean class [2], currect Harmony's beans actually use Introspector.getBeanInfo
method to introspect the IndexedPropertyDescriptor -- "data".
The return type of normal getter method is incompatible with the type of indexed getter method,
which results in the failure of  introspection of this property.
In addition, Consider test case [3] and bean class [4], RI's beans will introspect the "data"
as a normal property while Harmony's beans will incorrectly regard it as an indexed property.

[1]
public void testMockIncompatibleGetterAndIndexedGetterBean() throws Exception {
        Class beanClass = MockIncompatibleGetterAndIndexedGetterBean.class;
        BeanInfo beanInfo = Introspector.getBeanInfo(beanClass);
        PropertyDescriptor pd = null;
        PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors();
        for (int i = 0; i < pds.length; i++) {
            pd = pds[i];
            if (pd.getName().equals("data")) {
                break;
            }
        }
        assertNotNull(pd);
        assertTrue(pd instanceof IndexedPropertyDescriptor);
        IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
        assertNull(ipd.getReadMethod());
        assertNull(ipd.getWriteMethod());
        Method indexedReadMethod = beanClass.getMethod("getData",
                new Class[] { int.class });
        Method indexedWriteMethod = beanClass.getMethod("setData", new Class[] {
                int.class, int.class });
        assertEquals(indexedReadMethod, ipd.getIndexedReadMethod());
        assertEquals(indexedWriteMethod, ipd.getIndexedWriteMethod());
    }
[2]
public class MockIncompatibleGetterAndIndexedGetterBean {
        private int[] datas;
        public int getData() {
            return datas[0];
        }
        public int getData(int index) {
            return datas[index];
        }
       public void setData(int index, int data) {
            this.datas[index] = data;
        }
}
[3]
public void testMockIncompatibleGetterAndIndexedGetterBean() throws Exception {
        Class beanClass = MockIncompatiblePartBean.class;
        BeanInfo beanInfo = Introspector.getBeanInfo(beanClass);
        PropertyDescriptor pd = null;
        PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors();
        for (int i = 0; i < pds.length; i++) {
            pd = pds[i];
            if (pd.getName().equals("data")) {
                break;
            }
        }
        assertNotNull(pd);
        assertFalse(pd instanceof IndexedPropertyDescriptor);
[4]
public class MockIncompatiblePartBean{
        private int[] datas;
        public int getData(){
            return datas[0];
        }
        public void setData(int index, int data) {
            this.datas[index] = data;
        }
        public void setData(int data){
            this.datas[0] = data;
        }
       public void setData(){
            this.datas[0] = 0;
        }
}


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message