jdk/src/share/classes/java/beans/Introspector.java

Print this page

        

@@ -682,12 +682,11 @@
                 pd = list.get(i);
                 if (pd instanceof IndexedPropertyDescriptor) {
                     ipd = (IndexedPropertyDescriptor)pd;
                     if (ipd.getIndexedWriteMethod() != null) {
                         if (igpd != null) {
-                            if (igpd.getIndexedPropertyType()
-                                == ipd.getIndexedPropertyType()) {
+                            if (isAssignable(igpd.getIndexedPropertyType(), ipd.getIndexedPropertyType())) {
                                 if (ispd != null) {
                                     ispd = new IndexedPropertyDescriptor(ispd, ipd);
                                 } else {
                                     ispd = ipd;
                                 }

@@ -701,11 +700,11 @@
                         }
                     }
                 } else {
                     if (pd.getWriteMethod() != null) {
                         if (gpd != null) {
-                            if (gpd.getPropertyType() == pd.getPropertyType()) {
+                            if (isAssignable(gpd.getPropertyType(), pd.getPropertyType())) {
                                 if (spd != null) {
                                     spd = new PropertyDescriptor(spd, pd);
                                 } else {
                                     spd = pd;
                                 }

@@ -804,10 +803,14 @@
                 properties.put(pd.getName(), pd);
             }
         }
     }
 
+    private static boolean isAssignable(Class<?> current, Class<?> candidate) {
+        return current == null ? candidate == null : current.isAssignableFrom(candidate);
+    }
+
     /**
      * Adds the property descriptor to the indexedproperty descriptor only if the
      * types are the same.
      *
      * The most specific property descriptor will take precedence.