-
Bug
-
Resolution: Unresolved
-
P4
-
9
Please see the spec.: http://download.oracle.com/otndocs/jcp/7224-javabeans-1.01-fr-spec-oth-JSpec/
For indexed properties the accessor type signatures are:
void setter(int index, PropertyType value); // indexed setter
PropertyType getter(int index); // indexed getter
void setter(PropertyType values[]); // array setter
PropertyType[] getter(); // array getter
Consider an example:
import java.beans.*;
import java.util.Arrays;
public class Test {
public static class C {
private double x[] = new double[]{};
@BeanProperty(description = "TEST_INDEXED", hidden = true, expert = false)
public double getX(int i) throws IndexOutOfBoundsException {
if (i >0 && i < x.length) { return x[i]; }
else { throw new IndexOutOfBoundsException(); }
}
public void setX(int i, double v) throws IndexOutOfBoundsException {
if (i >0 && i < x.length) { x[i] = v; }
else { throw new IndexOutOfBoundsException(); }
}
@BeanProperty(description = "TEST", hidden = false, expert = true)
public double[] getX() { return x; }
public void setX(double a[]) { x = Arrays.copyOf(a, a.length); }
}
public static void main(String[] args) throws Exception {
BeanInfo i = Introspector.getBeanInfo(C.class, Object.class);
PropertyDescriptor pd[] = i.getPropertyDescriptors();
for (PropertyDescriptor d: pd) {
System.out.println(d.getShortDescription());
System.out.println("hidden = " + d.isHidden());
System.out.println("expert = " + d.isExpert());
System.out.println("");
}
}
}
Output (Win 7, JDK9 b72):
TEST
hidden = true
expert = true
so,
1. the "hidden" value is seemingly invalid
2. how is it decided which property info should be used? could the info be somehow stored for both the alternatives?
For indexed properties the accessor type signatures are:
void setter(int index, PropertyType value); // indexed setter
PropertyType getter(int index); // indexed getter
void setter(PropertyType values[]); // array setter
PropertyType[] getter(); // array getter
Consider an example:
import java.beans.*;
import java.util.Arrays;
public class Test {
public static class C {
private double x[] = new double[]{};
@BeanProperty(description = "TEST_INDEXED", hidden = true, expert = false)
public double getX(int i) throws IndexOutOfBoundsException {
if (i >0 && i < x.length) { return x[i]; }
else { throw new IndexOutOfBoundsException(); }
}
public void setX(int i, double v) throws IndexOutOfBoundsException {
if (i >0 && i < x.length) { x[i] = v; }
else { throw new IndexOutOfBoundsException(); }
}
@BeanProperty(description = "TEST", hidden = false, expert = true)
public double[] getX() { return x; }
public void setX(double a[]) { x = Arrays.copyOf(a, a.length); }
}
public static void main(String[] args) throws Exception {
BeanInfo i = Introspector.getBeanInfo(C.class, Object.class);
PropertyDescriptor pd[] = i.getPropertyDescriptors();
for (PropertyDescriptor d: pd) {
System.out.println(d.getShortDescription());
System.out.println("hidden = " + d.isHidden());
System.out.println("expert = " + d.isExpert());
System.out.println("");
}
}
}
Output (Win 7, JDK9 b72):
TEST
hidden = true
expert = true
so,
1. the "hidden" value is seemingly invalid
2. how is it decided which property info should be used? could the info be somehow stored for both the alternatives?
- relates to
-
JDK-8133182 [TESTBUG] Add regression test for JDK-8132732
-
- Closed
-