Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4489050

JDK regression: java.beans.Introspector.getBeanInfo(Class) works incorrectly

    XMLWordPrintable

Details

    • sparc
    • solaris_2.6

    Description



      Name: dsR10051 Date: 08/07/2001


      This bug is JDK regression that has been introduced in merlin-beta2.
      The method of class java.beans.Introspector:
      public static BeanInfo getBeanInfo(Class beanClass)
                                  throws IntrospectionException
      could incorrectly find out the IndexedPropertyDescriptors
      of the bean under introspection. This happens when
      the bean declares indexed the read/write-only property access method
      and super class of the bean declares non-indexed property access methods.

      Here is minimized test:
      --- Argle.java ---
      public class Argle {

          public String[] getFred() {
              return null;
          }
      }
      --- Bargle.java ---
      public class Bargle extends Argle {

          public String getFred(int index) {
              return null;
          }
      }
      --- IntrospectorTest04.java ---
      import java.beans.*;

      public class IntrospectorTest04 {

          public static void main (String[] args) {
            try {
              BeanInfo bi = Introspector.getBeanInfo(Bargle.class);
              PropertyDescriptor[] pds = bi.getPropertyDescriptors();
              for (int i = 0; i < pds.length; i++) {
                  String name = pds[i].getName();
                  System.out.println(name + " instanceof IndexedPropertyDescriptor = " +
                      (pds[i] instanceof IndexedPropertyDescriptor));
                  System.out.println(name + " propertyType = " + pds[i].getPropertyType());
                  System.out.println(name + " setter = " + pds[i].getWriteMethod());
                  System.out.println(name + " getter = " + pds[i].getReadMethod());
                  if (pds[i] instanceof IndexedPropertyDescriptor) {
                      IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor)pds[i];
                      System.out.println(name + " indxed setter = " + ipd.getIndexedWriteMethod());
                      System.out.println(name + " indxed getter = " + ipd.getIndexedReadMethod());
                  } else {
                      if (name.equals("fred")) {
                          System.out.println("FAILED: fred should be indexed property");
                      }
                  }
              }
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
      }
      --- Output ---
      %/set/jdk-builds/JDK1.4.0beta-b74/solaris/bin/java IntrospectorTest04
      class instanceof IndexedPropertyDescriptor = false
      class propertyType = class java.lang.Class
      class setter = null
      class getter = public final native java.lang.Class java.lang.Object.getClass()
      fred instanceof IndexedPropertyDescriptor = false
      fred propertyType = class [Ljava.lang.String;
      fred setter = null
      fred getter = public java.lang.String[] Argle.getFred()
      FAILED: fred should be indexed property

      --- Output for JDK1.4.0beta-b65 ---
      %/set/jdk-builds/JDK1.4.0beta-b65/solaris/bin/java IntrospectorTest04
      class instanceof IndexedPropertyDescriptor = false
      class propertyType = class java.lang.Class
      class setter = null
      class getter = public final native java.lang.Class java.lang.Object.getClass()
      fred instanceof IndexedPropertyDescriptor = true
      fred propertyType = class [Ljava.lang.String;
      fred setter = null
      fred getter = public java.lang.String[] Argle.getFred()
      fred indxed setter = null
      fred indxed getter = public java.lang.String Bargle.getFred(int)

      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              sdasunw Sda Sda (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: