JDK-8131347 : new @BeanProperty annotation: inconsistent behavior for "enumerationValues"
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-07-15
  • Updated: 2017-01-16
  • Resolved: 2016-12-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b151Fixed
Related Reports
Relates :  
Relates :  
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
Comments
http://mail.openjdk.java.net/pipermail/beans-dev/2016-December/000351.html
08-12-2016

looking more carefully at the test: the root cause of the issue is inconsistency of the b's getter return type (double) and setter argument type (int). But anyway, this ambiguity (empty/null) does not allow to classify this issue as a full duplicate for JDK-8132163
29-07-2015

should the enumeration array be empty or null if not specified? (JDK-8130937) e.g., an array of event set descriptors (i.getEventSetDescriptors()) is empty by default, not null.
15-07-2015