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

Introspector does not get bean info correctly.

    XMLWordPrintable

Details

    • beta
    • generic, x86, sparc
    • generic, solaris_2.6, windows_nt
    • Verified

    Description



      Name: dsR10051 Date: 08/23/2000



      The method java.beans.Introspector.getBeanInfo
      does not get BeanInfo correctly. The IndexedPropertyDescriptor object
      got by this BeanInfo is corrupted. It can contain null indexed reader or writer
      instead valid object.


      Here is a minimized test:
      import java.beans.*;

      public class IntrospectorTest02 {

          public static void main (String args[]) {

            try {
              BeanInfo bi = Introspector.getBeanInfo(Wombat.class);
              PropertyDescriptor[] pds = bi.getPropertyDescriptors();
              for (int i = 0; i < pds.length; i++) {
                  if(pds[i] instanceof IndexedPropertyDescriptor) {
                      System.out.println("IndexedPropertyDescriptor found: " + pds[i].getName());
                      System.out.println("Setter: " + ((IndexedPropertyDescriptor)pds[i]).getIndexedWriteMethod());
                      System.out.println("Getter: " + ((IndexedPropertyDescriptor)pds[i]).getIndexedReadMethod());
                  }
              }
            } catch (Exception e) {
              e.printStackTrace();
            }

          }
      }

      class Wombat {
          public Wombat brother[] = new Wombat[3];

          public void setBrother(int index, Wombat w) {
              brother[index] = w;
          }
          public Wombat getBrother(int index) {
              return brother[index];
          }

      }

      --- Output: ---
      %java -version
      java version "1.4.0beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0beta-b28)
      Java HotSpot(TM) Core VM (build 1.3-internal, interpreted mode)
      %java IntrospectorTest02
      IndexedPropertyDescriptor found: brother
      Setter: public void Wombat.setBrother(int,Wombat)
      Getter: null
      %

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

      Attachments

        Issue Links

          Activity

            People

              mdavidsosunw Mark Davidson (Inactive)
              sdasunw Sda Sda (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: