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

@BeanProperty: Bean info depends on a getter return type / setter argument type

XMLWordPrintable

      Please run:

      import java.beans.*;

      public class Test {

          public static class C {
              private int x;

              @BeanProperty(
                  hidden = true,
                  preferred = true,
                  description = "xxx"
                  )
              public void setX(int i) { x = i; }
              public double getX() { return x; }
          }


          public static void main(String[] args) throws Exception {

              BeanInfo i = Introspector.getBeanInfo(C.class, Object.class);
              PropertyDescriptor d = i.getPropertyDescriptors()[0];

              System.out.println(d.getShortDescription());
              System.out.println(d.isHidden());
              System.out.println(d.isPreferred());
          }
      }


      note: here getX() returns double instead of int.

      Output (JDK9 b73, linux-64):

      x
      false
      false
       - just default values.

      If change "double getX()" to "int getX()" then the output will be as expected:

      xxx
      true
      true

            Unassigned Unassigned
            avstepan Alexander Stepanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: