JDK-8132732 : @BeanInfo: invalid info when annotating both indexed and non-indexed properties.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 9
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2015-07-30
  • Updated: 2021-07-13
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.
Other
tbdUnresolved
Related Reports
Relates :  
Description
Please see the spec.: http://download.oracle.com/otndocs/jcp/7224-javabeans-1.01-fr-spec-oth-JSpec/

For indexed properties the accessor type signatures are:
  void setter(int index, PropertyType value);  // indexed setter
  PropertyType getter(int index); // indexed getter
  void setter(PropertyType values[]); // array setter
  PropertyType[] getter(); // array getter


Consider an example:

import java.beans.*;
import java.util.Arrays;

public class Test {

    public static class C {

        private double x[] = new double[]{};

        @BeanProperty(description = "TEST_INDEXED", hidden = true, expert = false)
        public double getX(int i) throws IndexOutOfBoundsException {
            if (i >0 && i < x.length) { return x[i]; }
            else { throw new IndexOutOfBoundsException(); }
        }
        public void setX(int i, double v) throws IndexOutOfBoundsException {
            if (i >0 && i < x.length) { x[i] = v; }
            else { throw new IndexOutOfBoundsException(); }
        }
        
        @BeanProperty(description = "TEST", hidden = false, expert = true)
        public double[] getX() { return x; }
        public void setX(double a[]) { x = Arrays.copyOf(a, a.length); }
    }
    

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

        BeanInfo i = Introspector.getBeanInfo(C.class, Object.class);
        PropertyDescriptor pd[] = i.getPropertyDescriptors();
        
        for (PropertyDescriptor d: pd) {
            System.out.println(d.getShortDescription());
            System.out.println("hidden = " + d.isHidden());
            System.out.println("expert = " + d.isExpert());
            System.out.println("");
        }
    }
}


Output (Win 7, JDK9 b72):

TEST
hidden = true
expert = true

so,
1. the "hidden" value is seemingly invalid
2. how is it decided which property info should be used? could the info be somehow stored for both the alternatives?
Comments
please update test/java/beans/Introspector/BeanPropertyTest.java test/java/beans/Introspector/AnonymousClassBeanPropertyTest.java after the bug fix
26-04-2016

A couple of additional test cases (some combination of JDK-8132565 and the above example): import java.beans.*; import java.util.Arrays; public class Test1 { public static class C extends CBase { @BeanProperty(description = "TEST_INDEXED", hidden = true, expert = false) public double getX(int i) throws IndexOutOfBoundsException { if (i >0 && i < x.length) { return x[i]; } else { throw new IndexOutOfBoundsException(); } } public void setX(int i, double v) throws IndexOutOfBoundsException { if (i >0 && i < x.length) { x[i] = v; } else { throw new IndexOutOfBoundsException(); } } } public static class CBase { protected double x[] = new double[]{}; @BeanProperty(description = "TEST", hidden = false, expert = true) public double[] getX() { return x; } public void setX(double a[]) { x = Arrays.copyOf(a, a.length); } } public static void main(String[] args) throws Exception { /* the same as above */ } } import java.beans.*; import java.util.Arrays; public class Test2 { public static class C extends CBase { @BeanProperty(description = "TEST", hidden = false, expert = true) public double[] getX() { return x; } public void setX(double a[]) { x = Arrays.copyOf(a, a.length); } } public static class CBase { protected double x[] = new double[]{}; @BeanProperty(description = "TEST_INDEXED", hidden = true, expert = false) public double getX(int i) throws IndexOutOfBoundsException { if (i >0 && i < x.length) { return x[i]; } else { throw new IndexOutOfBoundsException(); } } public void setX(int i, double v) throws IndexOutOfBoundsException { if (i >0 && i < x.length) { x[i] = v; } else { throw new IndexOutOfBoundsException(); } } } public static void main(String[] args) throws Exception { /* the same as above */ } } Output (Win 7, JDK9 b72) Test1: TEST_INDEXED hidden = true expert = true Test2: TEST_INDEXED hidden = true expert = true
18-04-2016

if comment one of the annotations, then the output for other should be correct
30-07-2015