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

new @BeanProperty annotation: inconsistent behavior for "enumerationValues"

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 9
    • 9
    • client-libs
    • b151

    Description

      That's closely related to JDK-8131342 (just a sub-issue).

      Please run:

      public class EnumTest {

          public class Bean {

              private int a;
              private int b;

              @BeanProperty(description = "A DESCRIPTION")
              public void setA(int v) { a = v; }
              public int getA() { return a; }

              @BeanProperty(description = "B DESCRIPTION")
              public void setB(int v) { b = v; }
              public double getB() { return b; }
          }

          static void printSz(PropertyDescriptor d) {
              Object en = d.getValue("enumerationValues");
              if (en == null) { System.out.println("null enumeration"); } else {
                  Object tmp[] = (Object []) en;
                  System.out.println("enumeration array size: " + tmp.length);
              }
          }


          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.getName());
                  printSz(d);
              }
          }
      }


      Output:
      a
      enumeration array size: 0
      b
      null enumeration


      then please comment out @BeanProperty for "a"; the output:
      a
      null enumeration
      b
      null enumeration


      if comment out @BeanProperty for "b" (and uncomment for "a"), then the output again looks like as in the initial case:
      a
      enumeration array size: 0
      b
      null enumeration


      if case of absent annotations:
      a
      null enumeration
      b
      null enumeration




      Checked with JDK9 b72; Win 7

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: