Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
Please run the following code: import java.beans.*; public class EnumTest { public class Bean { private int a; private int b; @BeanProperty( description = "A DESCRIPTION", enumerationValues = { "javax.swing.SwingConstants.TOP"} ) public void setA(int v) { a = v; } public int getA() { return a; } @BeanProperty( description = "B DESCRIPTION", enumerationValues = { "javax.swing.SwingConstants.BOTTOM"} ) public void setB(int v) { b = v; } public double getB() { return b; } } static void printEnum(PropertyDescriptor d) { Object en = d.getValue("enumerationValues"); if (en == null) { System.out.println("null enumeration"); } else { Object tmp[] = (Object []) en; for (Object o: tmp) { System.out.print(o + " "); } System.out.println(""); } } public static void main(String[] args) throws Exception { BeanInfo i = Introspector.getBeanInfo(Bean.class, Object.class); PropertyDescriptor[] ds = i.getPropertyDescriptors(); for (PropertyDescriptor d: ds) { System.out.println(d.getShortDescription()); printEnum(d); } } } Expected (?) output: A DESCRIPTION TOP 1 javax.swing.SwingConstants.TOP B DESCRIPTION BOTTOM 3 javax.swing.SwingConstants.BOTTOM Actual output: A DESCRIPTION TOP 1 javax.swing.SwingConstants.TOP b null enumeration Could we use @BeanProperty more than once per bean? If no then how is it decided what property is top-priority? Checked with JDK9 b72
|