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

@BeanProperty: Bean info depends on an order of setters declaration

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: client-libs
    • Labels:
      None

      Description

      Please run:

      import java.beans.*;

      public class Test {


          public static class C1 {
              private Object x;
              @BeanProperty(expert = true, description = "xxx")
              public void setX(Object i) { x = i; }
              public void setX(int i) { x = i; }
              public Object getX() { return x; }
          }

          public static class C2 {
              private Object x;
              @BeanProperty(expert = true, description = "xxx")
              public void setX(int i) { x = i; }
              public void setX(Object i) { x = i; }
              public Object getX() { return x; }
          }


          public static void main(String[] args) throws Exception {
              PropertyDescriptor d;
              d = Introspector.getBeanInfo(C1.class, Object.class).getPropertyDescriptors()[0];
              System.out.println(d.getShortDescription() + " " + d.isExpert());
              d = Introspector.getBeanInfo(C2.class, Object.class).getPropertyDescriptors()[0];
              System.out.println(d.getShortDescription() + " " + d.isExpert());
          }
      }


      Please note: C1 and C2 are equal in fact; the only difference is an order of setters (in the 2nd case the annotation precedes the setter whose type differs from the field 'x' type)

      Output (JDK9 b73, Ubuntu 14.04 Linux):

      xxx true
      x false

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              serb Sergey Bylokhov
              Reporter:
              avstepan Alexander Stepanov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: