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

Introspector - overloaded methods

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Build:
      b17
    • Introduced In Version:
    • CPU:
      x86_64
    • OS:
      windows_7

      Description

      FULL PRODUCT VERSION :
      I tested on java 8 any release

      ADDITIONAL OS VERSION INFORMATION :
      Windows 7

      A DESCRIPTION OF THE PROBLEM :
      The changes made in the Introspector processPropertyDescriptors method are resposible for the following issue:

      An index type property is not detected correctly in a subclass if it is using overloaded methods of the same property defined in a super class.


      REGRESSION. Last worked in version 7u80

      ADDITIONAL REGRESSION INFORMATION:
      any java 8 version, did tests on the 66 and 45 updates

      java version "1.8.0_60"
      Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
      Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      I have the following class structure

      public class SuperClass {

          private String tagTemplate;

          public String getTagTemplate() {
              return tagTemplate;
          }

          public void setTagTemplate(String tagTemplate) {
              this.tagTemplate = tagTemplate;
          }
      }


      public class SubClass extends SuperClass {

          private Hashtable<Integer, Point> tagTemplateType = new Hashtable<Integer, Point>();

          public Point getTagTemplate(int index) {
              return tagTemplateType.get(index);
          }

          public void setTagTemplate(int index, Point tagType) {
              tagTemplateType.put(index, tagType);
          }
      }


      I run the following code

      /**
       * @author Radu Barbos
       */
      public class TestBeans {

          public static void main(String arg[]) {
              new TestBeans().test(SubClass.class);
          }

          private void test(Class<?> beanClass) {
              PropertyDescriptor descriptors[] = null;
              // Introspect the bean and cache the generated descriptors
              BeanInfo beanInfo = null;
              try {
                  beanInfo = Introspector.getBeanInfo(beanClass);
              } catch (IntrospectionException e) {
                  return;
              }
              descriptors = beanInfo.getPropertyDescriptors();
              for(PropertyDescriptor pd: descriptors) {
                  System.out.println("--> " + pd.getName() + " " + (pd instanceof IndexedPropertyDescriptor));
              }
          }
      }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The expected output will be if the 'tagTemplate' property will be reprsented by a 'IndexedPropertyDescriptor' and the read/write methods should be the SubClass methods.

      This behaviour is what happends in java 7
      ACTUAL -
      The 'tagTemplate' property is described by a 'PropertyDescriptor' and is represents the SuperClass methods, this is wrong and I'm extracting the SubClass properties.



      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      - do not use overloaded methods to represent index type properties in subclasses

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              serb Sergey Bylokhov
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: