-
Bug
-
Resolution: Unresolved
-
P4
-
9
Related to JDK-8154756.
Not sure if an issue, but just in case.
Please run the following code:
import java.beans.*;
public class Test {
public static class X {
@BeanProperty(
description = "test",
bound = true,
expert = false,
hidden = true,
preferred = false,
required = true,
visualUpdate = false)
public void setX(Object ... u) { }
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
}
public static void main(String[] args) throws Exception {
BeanInfo i = Introspector.getBeanInfo(X.class, Object.class);
if (i == null) {
System.out.println("null bean info");
return;
}
PropertyDescriptor descriptors[] = i.getPropertyDescriptors();
if (descriptors.length < 1) {
System.out.println("no descriptors found");
return;
}
PropertyDescriptor d = descriptors[0];
System.out.println(
d.getShortDescription() + ", " +
d.isBound() + ", " + d.isExpert() + ", " +
d.isHidden() + ", " + d.isPreferred() + ", " +
(boolean) d.getValue("required") + ", " + (boolean) d.getValue("visualUpdate"));
}
}
Output:
test, true, false, true, false, true, false
Should the vararg be considered as a valid argument type?
for
public void setX(Object o, Object ... u) { }
the output is as expected ("no descriptors found")
So that may be some imbalance here.
Plus in principle the user can pass the empty varargs list: (new X()).setX();
It is also unclear how to interpret vararg setter: as indexed? non-indexed? and how, e.g., it should coexist with indexed and/or non-indexed seeters
Not sure if an issue, but just in case.
Please run the following code:
import java.beans.*;
public class Test {
public static class X {
@BeanProperty(
description = "test",
bound = true,
expert = false,
hidden = true,
preferred = false,
required = true,
visualUpdate = false)
public void setX(Object ... u) { }
public void addPropertyChangeListener(PropertyChangeListener l) {}
public void removePropertyChangeListener(PropertyChangeListener l) {}
}
public static void main(String[] args) throws Exception {
BeanInfo i = Introspector.getBeanInfo(X.class, Object.class);
if (i == null) {
System.out.println("null bean info");
return;
}
PropertyDescriptor descriptors[] = i.getPropertyDescriptors();
if (descriptors.length < 1) {
System.out.println("no descriptors found");
return;
}
PropertyDescriptor d = descriptors[0];
System.out.println(
d.getShortDescription() + ", " +
d.isBound() + ", " + d.isExpert() + ", " +
d.isHidden() + ", " + d.isPreferred() + ", " +
(boolean) d.getValue("required") + ", " + (boolean) d.getValue("visualUpdate"));
}
}
Output:
test, true, false, true, false, true, false
Should the vararg be considered as a valid argument type?
for
public void setX(Object o, Object ... u) { }
the output is as expected ("no descriptors found")
So that may be some imbalance here.
Plus in principle the user can pass the empty varargs list: (new X()).setX();
It is also unclear how to interpret vararg setter: as indexed? non-indexed? and how, e.g., it should coexist with indexed and/or non-indexed seeters
- relates to
-
JDK-8154756 @BeanProperty: invalid bean info in case of overloaded setter (varargs) - unstable behavior
-
- Closed
-