You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Tim Ellison (JIRA)" <ji...@apache.org> on 2009/06/22 11:14:07 UTC

[jira] Closed: (HARMONY-5973) [classlib] [beans] StandardBeanInfo fails to gain correct indexed read and write methods of a indexed property

     [ https://issues.apache.org/jira/browse/HARMONY-5973?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tim Ellison closed HARMONY-5973.
--------------------------------


No response, assuming ok.

> [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.0M6, 5.0M7
>            Reporter: Kevin Zhou
>            Assignee: Tim Ellison
>             Fix For: 5.0M8
>
>         Attachments: HARMONY-5973.diff
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> 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.