JDK-8132240 : @BeanProperty: Bean info depends on an order of setters declaration
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2015-07-23
  • Updated: 2016-04-26
  • Resolved: 2016-04-26
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
9Resolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
Please run:

import java.beans.*;

public class Test {


    public static class C1 {
        private Object x;
        @BeanProperty(expert = true, description = "xxx")
        public void   setX(Object i) { x = i; }
        public void   setX(int i)    { x = i; }
        public Object getX()         { return x; }
    }

    public static class C2 {
        private Object x;
        @BeanProperty(expert = true, description = "xxx")
        public void   setX(int i)    { x = i; }
        public void   setX(Object i) { x = i; }
        public Object getX()         { return x; }
    }


    public static void main(String[] args) throws Exception {
        PropertyDescriptor d;
        d = Introspector.getBeanInfo(C1.class, Object.class).getPropertyDescriptors()[0];
        System.out.println(d.getShortDescription() + " " + d.isExpert());
        d = Introspector.getBeanInfo(C2.class, Object.class).getPropertyDescriptors()[0];
        System.out.println(d.getShortDescription() + " " + d.isExpert());
    }
}


Please note: C1 and C2 are equal in fact; the only difference is an order of setters (in the 2nd case the annotation precedes the setter whose type differs from the field 'x' type)

Output (JDK9 b73, Ubuntu 14.04 Linux):

xxx true
x false
Comments
that seems to be just a duplicate for JDK-8132163
26-04-2016

the uncertain "Object" in the test could be replaced with more specific "Integer" (with the same result)
23-07-2015

I'm not sure if the presence of two setters contradicts the JavaBean conventions, but that's the evident inconsistency
23-07-2015