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

Introspector does not see overridden generic setter method

XMLWordPrintable

    • 9
    • b17
    • x86
    • other

        FULL PRODUCT VERSION :
        java version "9.0.1"
        Java(TM) SE Runtime Environment (build 9.0.1+11)
        Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
         Microsoft Windows [Version 10.0.16299.192]


        A DESCRIPTION OF THE PROBLEM :
        In some configurations, when the public getter and protected setter are defined in a generic abstract parent class, and the setter is overridden with a public method in a concrete subclass, Introspector does not find a write method for the corresponding property.

        This behaviour seems to be dependent on the specific classes (and possibly names) involved.

        REGRESSION. Last worked in version 8u161

        ADDITIONAL REGRESSION INFORMATION:
        java version "1.8.0_161"
        Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
        Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Compile the attached Java file.

        Run the compiled class BeansMain.


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        class
          >> public final native java.lang.Class java.lang.Object.getClass()
          << null
        value
          >> public java.lang.Object Parent.getValue()
          << public void Child.setValue(java.lang.Runnable)


        ACTUAL -
        class
          >> public final native java.lang.Class java.lang.Object.getClass()
          << null
        value
          >> public java.lang.Object Parent.getValue()
          << null

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.beans.*;

        class Parent<T> {
            T value;
            public T getValue() {
                return value;
            }
            protected void setValue(T value) {
                this.value = value;
            }
        }

        class Child extends Parent<Runnable> {
            @Override
            public void setValue(Runnable value) {
                super.setValue(value);
            }
        }

        public class BeansMain {
            public static void main(String[] args) throws IntrospectionException {
                BeanInfo beanInfo = Introspector.getBeanInfo(Child.class);
                for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
                    System.out.println(pd.getName() + "\n >> " + pd.getReadMethod() + "\n << " + pd.getWriteMethod());
                }
            }
        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Override both getter and setter in the subclass.

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

                Created:
                Updated:
                Resolved: