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

Ctor PropertyDescripor(String, Class) sets wrong reader merthod.

XMLWordPrintable

    • beta
    • sparc
    • solaris_2.5



      Name: dsC58869 Date: 06/29/99



      This bug was introduced in Kestrel.

      The constructor PropertyDescriptor(String propName, Class beanClass)
      sets "setFoo" method instead "isFoo" for boolean property
      if beanClass contains both.


      ---- Here is an example to demonstrate this bug ----

      import java.beans.*;

      public class Test02 {
          public static void main (String[] args) {
      PropertyDescriptor pd;
      try {
      pd = new
      PropertyDescriptor("booleanType",WrongBean.class);
      } catch (IntrospectionException e) {
      e.printStackTrace();
      System.out.println("Failed");
      return;
      }
      System.out.println(pd.getReadMethod().getName());
      if (pd.getReadMethod().getName().startsWith("is")) {
      System.out.println("OKAY");
      return;
      } else if (pd.getReadMethod().getName().startsWith("getBooleanType")) {
      System.out.println("Failed: Reader is getBooleanType");
      return;
      }
      System.out.println("Failed: no Reader method");
      return;
          }
      }

      class WrongBean {
          boolean booleanType;
          public void setBooleanType (boolean booleanType) {
      this.booleanType = booleanType;
          }
          public boolean getBooleanType () {
      return booleanType;
          }
          public boolean isBooleanType () {
      return booleanType;
          }
      }

      ---- Here is output: ----
      %java -fullversion
      java full version "JDK-1.3-I"
      %java Test02
      getBooleanType
      Failed: Reader is getBooleanType
      %
      %java -fullversion
      java full version "JDK-1.2.2-U"
      %java Test02
      isBooleanType
      OKAY

      ------------------------------------------------------------
      ======================================================================

            jkoenigsunw Janet Koenig (Inactive)
            sdasunw Sda Sda (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: