8030123: java/beans/Introspector/Test8027648.java fails
authoralexsch
Wed, 22 Apr 2015 15:00:50 +0400
changeset 30476 dd563be4f10f
parent 30475 d55fb9992239
child 30477 5b7c6378ce56
8030123: java/beans/Introspector/Test8027648.java fails Reviewed-by: serb, alexsch Contributed-by: Nicholas Cull <run2000@gmail.com>
jdk/src/java.desktop/share/classes/java/beans/IndexedPropertyDescriptor.java
jdk/src/java.desktop/share/classes/java/beans/PropertyDescriptor.java
--- a/jdk/src/java.desktop/share/classes/java/beans/IndexedPropertyDescriptor.java	Wed Apr 22 13:46:03 2015 +0400
+++ b/jdk/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);
-        if (x instanceof IndexedPropertyDescriptor) {
-            IndexedPropertyDescriptor ix = (IndexedPropertyDescriptor)x;
-            try {
-                Method xr = ix.getIndexedReadMethod();
-                if (xr != null) {
-                    setIndexedReadMethod(xr);
-                }
+        Method tr = null;
+        Method tw = null;
 
-                Method xw = ix.getIndexedWriteMethod();
-                if (xw != null) {
-                    setIndexedWriteMethod(xw);
-                }
-            } catch (IntrospectionException ex) {
-                // Should not happen
-                throw new AssertionError(ex);
+        if (x instanceof IndexedPropertyDescriptor) {
+            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 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/jdk/src/java.desktop/share/classes/java/beans/PropertyDescriptor.java	Wed Apr 22 13:46:03 2015 +0400
+++ b/jdk/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
         }