JDK-8132888 : @BeanProperty: access level of the property accessors must be 'public'?
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 9
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2015-08-03
  • 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
Not sure if that's a bug, but just in case. Does the annotation affect only the public accessors?


Please run the following example:

import java.beans.*;

public class Test {
    
   public static class C {
        private boolean prop = false;
        @BeanProperty(hidden = true, expert = true, description = "xxx")
        void setX(boolean b) { prop = b; }
        public boolean getX() { return prop; }
    }
    
    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.print(d.getShortDescription());
            System.out.print(", hidden = " + d.isHidden());
            System.out.println(", expert = " + d.isExpert());
        }
    }
}

Here the setter for the base class do not have "public" modifier. Output (Win 7, JDK9 b72):
"x, hidden = false, expert = false"
(so it seems we have some default values here generated just because of presence of the public setter)

Then please move the annotation to set it in front of the public getter. Then the output is as expected:
"xxx, hidden = true, expert = true"

Comments
Targeted to 10 as an issue introduced in 8u or 9
17-02-2017

Approved by component triage team to defer
12-08-2016

9-client-defer-candidate: There is no resource to fix it in jdk9. The bug is not critical.
12-08-2016

SQE: OK to defer
12-08-2016

please update test/java/beans/Introspector/BeanPropertyTest.java after the bug fix
21-04-2016