Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
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
|