What is the correct behavior in the following case?
import java.beans.*;
public class PropertyAccessLevelTest {
public static class C1 {
private boolean x;
@BeanProperty(hidden = true, expert = true, description = "xxx")
public void setX(boolean b) { x = b; }
@BeanProperty(hidden = false, expert = false, description = "yyy")
public boolean getX() { return x; }
}
public static class C2 {
private boolean x;
@BeanProperty(hidden = false, expert = false, description = "yyy")
public void setX(boolean b) { x = b; }
@BeanProperty(hidden = true, expert = true, description = "xxx")
public boolean getX() { return x; }
}
private static void runTest(Class<?> c) throws Exception {
BeanInfo i = Introspector.getBeanInfo(c, 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());
}
}
public static void main(String[] args) throws Exception {
runTest(C1.class);
runTest(C2.class);
}
}
Output (Win 7, JDK9 b72):
yyy, hidden = true, expert = true
xxx, hidden = true, expert = true