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

Introspecting returns incorrect PropertyDescriptor for overriden getter.

    XMLWordPrintable

Details

    • x86
    • windows_xp

    Description

      FULL PRODUCT VERSION :
      java version "1.6.0_05"
      Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
      Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Introspecting returns incorrect PropertyDescriptor for overriden getter in case when child getter has more specific return type. In this case PropertyDescriptor of parent class is returned instead.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See source code attached bellow.




      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      App$FooChild
      ACTUAL -
      App$FooParent

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.beans.BeanInfo;
      import java.beans.Introspector;
      import java.beans.PropertyDescriptor;

      public class App {

      public static class FooParent { }
      public static class FooChild extends FooParent { }

      public static class HierarchyParent {
      public FooParent getFoo() { return new FooParent(); }
      }
      public static class HierarchyChild extends HierarchyParent {
      @Override
      public FooChild getFoo() { return new FooChild(); }
      }

      public static void main(String[] args) throws Exception {
      BeanInfo info = Introspector.getBeanInfo(HierarchyChild.class);
      for (PropertyDescriptor desc : info.getPropertyDescriptors()) {
      if ("foo".equals(desc.getName())) {
      //result should be App$FooChild
      System.out.println(desc.getPropertyType());
      break;
      }
      }
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use simple reflection instead BeanInfo.

      Attachments

        Issue Links

          Activity

            People

              malenkov Sergey Malenkov (Inactive)
              igor Igor Nekrestyanov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: