-
Bug
-
Resolution: Duplicate
-
P3
-
9
-
None
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
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
- duplicates
-
JDK-8132163 @BeanProperty: Bean info depends on a getter return type / setter argument type
- Open
- relates to
-
JDK-8131347 new @BeanProperty annotation: inconsistent behavior for "enumerationValues"
- Resolved
-
JDK-8131055 [TEST] bean annotations: add a test checking if a separate user-defined BeanInfo class is top-priority as compared with the annotations.
- Resolved
-
JDK-8132237 [TEST] Add regression test for JDK-8131342, JDK-8131939, JDK-8132153
- Closed