Stepan, Vladimir,

About HARMONY-1435.
I have discovered that one of the tests from
org.apache.harmony.beans.tests.java.beans.PropertyDescriptorTest (that
have been removed from the exclude by this commit) still fails on RI.
But after careful examination of the problem I tend to think this is a
bug in RI.
Failed test: org.apache.harmony.beans.tests.java.beans.PropertyDescriptorTest
RI throws IntrospectionException if invalid *write* method name is
specified and throws nothing in case of invalid *read* method name. I
think this is the time for another "Non-bug difference from RI" JIRA"
:)

Thanks,

2006/9/18, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
Author: smishura
Date: Sun Sep 17 22:13:28 2006
New Revision: 447242

URL: http://svn.apache.org/viewvc?view=rev&rev=447242
Log:
Apply patch for HARMONY-1435 ([classlib][beans] no IntrospectionException for 
PropertyDescriptor(a, Class.class))

Remove org/apache/harmony/beans/tests/java/beans/PropertyDescriptorTest.java 
from exclude list

Modified:
   incubator/harmony/enhanced/classlib/trunk/modules/beans/build.xml
   
incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/BeanInfoImpl.java
   
incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyDescriptor.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/build.xml
URL: 
http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/build.xml?view=diff&rev=447242&r1=447241&r2=447242
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/build.xml Sun Sep 
17 22:13:28 2006
@@ -231,7 +231,6 @@
                    <exclude 
name="org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java" />
                    <exclude 
name="org/apache/harmony/beans/tests/java/beans/PersistenceDelegateTest.java" />
                    <exclude 
name="org/apache/harmony/beans/tests/java/beans/PropertyChangeSupportTest.java" />
-                    <exclude 
name="org/apache/harmony/beans/tests/java/beans/PropertyDescriptorTest.java" />
                    <exclude 
name="org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerTest.java" />
                    <exclude 
name="org/apache/harmony/beans/tests/java/beans/VetoableChangeListenerProxyTest.java" 
/>
                    <exclude 
name="org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.java" />

Modified: 
incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/BeanInfoImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/BeanInfoImpl.java?view=diff&rev=447242&r1=447241&r2=447242
==============================================================================
--- 
incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/BeanInfoImpl.java
 (original)
+++ 
incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/BeanInfoImpl.java
 Sun Sep 17 22:13:28 2006
@@ -393,9 +393,33 @@
                try {
                    propertyDescriptor = new PropertyDescriptor(propertyName,
                            beanClass);
-                    hmPropertyDescriptors.put(propertyName, 
propertyDescriptor);
                } catch (IntrospectionException ie) {
-                    System.out.println(ie.getClass() + ": " + 
ie.getMessage()); //$NON-NLS-1$
+                    //no setter or getter
+                    if (methodName.startsWith("set")) {
+                        try {
+                            propertyDescriptor = new PropertyDescriptor(
+                                    propertyName, beanClass, null, methodName);
+                        } catch (IntrospectionException e) {
+                            //no getter
+                        }
+                    } else if (methodName.startsWith("get")
+                            || methodName.startsWith("is")) {
+                        try {
+                            propertyDescriptor = new PropertyDescriptor(
+                                    propertyName, beanClass, methodName, null);
+                        } catch (IntrospectionException e) {
+                            //no setter
+                        }
+                    } else {
+                        try {
+                            propertyDescriptor = new PropertyDescriptor(
+                                    propertyName, beanClass, null, null);
+                        } catch (IntrospectionException e) {
+                        }
+                    }
+                }
+                if (propertyDescriptor != null) {
+                    hmPropertyDescriptors.put(propertyName, 
propertyDescriptor);
                }
            }
        }
@@ -418,7 +442,7 @@
                    hmPropertyDescriptors.put(propertyName,
                            indexedPropertyDescriptor);
                } catch (IntrospectionException ie) {
-                    System.out.println(ie.getClass() + ": " + 
ie.getMessage()); //$NON-NLS-1$
+                    //System.out.println(ie.getClass() + ": " + 
ie.getMessage()); //$NON-NLS-1$
                }
            }
        }

Modified: 
incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyDescriptor.java
URL: 
http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyDescriptor.java?view=diff&rev=447242&r1=447241&r2=447242
==============================================================================
--- 
incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyDescriptor.java
 (original)
+++ 
incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyDescriptor.java
 Sun Sep 17 22:13:28 2006
@@ -64,8 +64,20 @@
        this.setName(propertyName);
        this.setDisplayName(propertyName);

-        setWriteMethod(beanClass, setterName);
-        setReadMethod(beanClass, getterName);
+        if (setterName != null) {
+            if (hasMethod(beanClass, setterName)) {
+                setWriteMethod(beanClass, setterName);
+            } else {
+                throw new 
IntrospectionException(Messages.getString("beans.20"));
+            }
+        }
+        if (getterName != null) {
+            if (hasMethod(beanClass, getterName)) {
+                setReadMethod(beanClass, getterName);
+            } else {
+                throw new 
IntrospectionException(Messages.getString("beans.1F"));
+            }
+        }
    }

    /**
@@ -112,11 +124,15 @@
            getterName = createDefaultMethodName(propertyName, "get"); 
//$NON-NLS-1$
            if(hasMethod(beanClass, getterName)) {
                setReadMethod(beanClass, getterName);
+            } else {
+                throw new 
IntrospectionException(Messages.getString("beans.1F"));
            }
        }
        String setterName = createDefaultMethodName(propertyName, "set"); 
//$NON-NLS-1$
        if(hasMethod(beanClass, setterName)) {
            setWriteMethod(beanClass, setterName);
+        } else {
+            throw new IntrospectionException(Messages.getString("beans.20"));
        }
    }

@@ -166,6 +182,9 @@
            }

            Class<?> returnType = getter.getReturnType();
+            if (returnType.equals(Void.TYPE)) {
+                throw new 
IntrospectionException(Messages.getString("beans.33")); //$NON-NLS-1$
+            }
            Class<?> propertyType = getPropertyType();
            if((propertyType != null) && !returnType.equals(propertyType)) {
                throw new IntrospectionException(


--
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]

Reply via email to