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

new @BeanProperty annotation: could we specify more than one per bean?

    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 the following code:

      import java.beans.*;

      public class EnumTest {
          
          public class Bean {

              private int a;
              private int b;

              @BeanProperty(
                      description = "A DESCRIPTION",
                      enumerationValues = {
                          "javax.swing.SwingConstants.TOP"}
                      )
              public void setA(int v) { a = v; }
              public int getA() { return a; }

              @BeanProperty(
                      description = "B DESCRIPTION",
                      enumerationValues = {
                          "javax.swing.SwingConstants.BOTTOM"}
                      )
              public void setB(int v) { b = v; }
              public double getB() { return b; }
          }
          
          static void printEnum(PropertyDescriptor d) {
              Object en = d.getValue("enumerationValues");
              if (en == null) {
                  System.out.println("null enumeration");
              } else {
                  Object tmp[] = (Object []) en;
                  for (Object o: tmp) {
                      System.out.print(o + " ");
                  }
                  System.out.println("");
              }
          }


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

              BeanInfo i = Introspector.getBeanInfo(Bean.class, Object.class);
              PropertyDescriptor[] ds = i.getPropertyDescriptors();
              for (PropertyDescriptor d: ds) {
                  System.out.println(d.getShortDescription());
                  printEnum(d);
              }
          }
      }


      Expected (?) output:

      A DESCRIPTION
      TOP 1 javax.swing.SwingConstants.TOP
      B DESCRIPTION
      BOTTOM 3 javax.swing.SwingConstants.BOTTOM


      Actual output:

      A DESCRIPTION
      TOP 1 javax.swing.SwingConstants.TOP
      b
      null enumeration



      Could we use @BeanProperty more than once per bean? If no then how is it decided what property is top-priority?


      Checked with JDK9 b72

        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: