changeset 11809:be4d1f1a6d53

8030123: java/beans/Introspector/Test8027648.java fails Reviewed-by: serb, alexsch Contributed-by: Nicholas Cull <run2000@gmail.com>
author alexsch
date Wed, 22 Apr 2015 15:00:50 +0400
parents 661136704d07
children 51b4175e8035
files src/java.desktop/share/classes/java/beans/IndexedPropertyDescriptor.java src/java.desktop/share/classes/java/beans/PropertyDescriptor.java
diffstat 2 files changed, 27 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.desktop/share/classes/java/beans/IndexedPropertyDescriptor.java	Wed Apr 22 13:46:03 2015 +0400
+++ b/src/java.desktop/share/classes/java/beans/IndexedPropertyDescriptor.java	Wed Apr 22 15:00:50 2015 +0400
@@ -431,7 +431,7 @@
     /**
      * Package-private constructor.
      * Merge two property descriptors.  Where they conflict, give the
-     * second argument (y) priority over the first argumnnt (x).
+     * second argument (y) priority over the first argument (x).
      *
      * @param x  The first (lower priority) PropertyDescriptor
      * @param y  The second (higher priority) PropertyDescriptor
@@ -439,39 +439,37 @@
 
     IndexedPropertyDescriptor(PropertyDescriptor x, PropertyDescriptor y) {
         super(x,y);
+        Method tr = null;
+        Method tw = null;
+
         if (x instanceof IndexedPropertyDescriptor) {
-            IndexedPropertyDescriptor ix = (IndexedPropertyDescriptor)x;
-            try {
-                Method xr = ix.getIndexedReadMethod();
-                if (xr != null) {
-                    setIndexedReadMethod(xr);
-                }
+            IndexedPropertyDescriptor ix = (IndexedPropertyDescriptor) x;
+            tr = ix.getIndexedReadMethod();
+            tw = ix.getIndexedWriteMethod();
+        }
+        if (y instanceof IndexedPropertyDescriptor) {
+            IndexedPropertyDescriptor iy = (IndexedPropertyDescriptor) y;
+            Method yr = iy.getIndexedReadMethod();
+            if (isAssignable(tr, yr)) {
+                tr = yr;
+            }
 
-                Method xw = ix.getIndexedWriteMethod();
-                if (xw != null) {
-                    setIndexedWriteMethod(xw);
-                }
-            } catch (IntrospectionException ex) {
-                // Should not happen
-                throw new AssertionError(ex);
+            Method yw = iy.getIndexedWriteMethod();
+            if (isAssignable(tw, yw)) {
+                tw = yw;
             }
         }
-        if (y instanceof IndexedPropertyDescriptor) {
-            IndexedPropertyDescriptor iy = (IndexedPropertyDescriptor)y;
-            try {
-                Method yr = iy.getIndexedReadMethod();
-                if (yr != null && yr.getDeclaringClass() == getClass0()) {
-                    setIndexedReadMethod(yr);
-                }
 
-                Method yw = iy.getIndexedWriteMethod();
-                if (yw != null && yw.getDeclaringClass() == getClass0()) {
-                    setIndexedWriteMethod(yw);
-                }
-            } catch (IntrospectionException ex) {
-                // Should not happen
-                throw new AssertionError(ex);
+        try {
+            if(tr != null) {
+                setIndexedReadMethod(tr);
             }
+            if(tw != null) {
+                setIndexedWriteMethod(tw);
+            }
+        } catch(IntrospectionException ex) {
+            // Should not happen
+            throw new AssertionError(ex);
         }
     }
 
--- a/src/java.desktop/share/classes/java/beans/PropertyDescriptor.java	Wed Apr 22 13:46:03 2015 +0400
+++ b/src/java.desktop/share/classes/java/beans/PropertyDescriptor.java	Wed Apr 22 15:00:50 2015 +0400
@@ -748,7 +748,7 @@
         appendTo(sb, "writeMethod", this.writeMethodRef.get());
     }
 
-    private boolean isAssignable(Method m1, Method m2) {
+    boolean isAssignable(Method m1, Method m2) {
         if (m1 == null) {
             return true; // choose second method
         }