harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r447242 - in /incubator/harmony/enhanced/classlib/trunk/modules/beans: build.xml src/main/java/java/beans/BeanInfoImpl.java src/main/java/java/beans/PropertyDescriptor.java
Date Mon, 18 Sep 2006 05:13:28 GMT
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(



Mime
View raw message