Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8155013

@BeanProperty: PropertyDescriptor's getValue("enumerationValues") returns null enumeration values in case of indexed property

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 9
    • client-libs

      please use AnonymousClassBeanPropertyTest from http://cr.openjdk.java.net/~avstepan/8154962/webrev.00/index.html to reproduce

      tests affected: testGetArray, testSetArray, testGetBoth_2, testSetBoth_2, testGetSetBoth_1, testGetSetBoth_2 - the output for them will be "null enumerationValues"

      is that what expected? Please note that, e.g., cases testGetBoth_1 and testSetBoth_1 do not fail.

      JDK9 b114 + Win. 7


      Please note also that at the same time the indexed getter could be annotated in such a way that the enumerationValues will be non-null (using SimpleBeanInfo extension instead of the annotation):

      import java.beans.*;

      public class IndexedPropTest {

          private final static double X = java.lang.Math.PI;
          private final static String X_NAME = "java.lang.Math.PI", X_SHORT = "PI";

          public static class C {
              public double[] getX() { return new double[]{X, X}; }
          }

          public static class CBeanInfo extends SimpleBeanInfo {

              @Override
              public PropertyDescriptor[] getPropertyDescriptors() {
                  PropertyDescriptor[] p = new PropertyDescriptor[1];

                  try {
                      p[0] = new PropertyDescriptor ("x", C.class, "getX", null);
                      p[0].setValue("enumerationValues", new Object[]{X_SHORT, X, X_NAME});
                  } catch(IntrospectionException e) { throw new RuntimeException(e); }
                  return p;
              }
          }

          public static void main(String[] args) throws Exception {

              BeanInfo i = Introspector.getBeanInfo(C.class, Object.class);
              PropertyDescriptor d[] = i.getPropertyDescriptors();
              if (d.length < 1) { System.out.println("no descriptors"); }
              else {
                  Object vals[] = (Object[]) d[0].getValue("enumerationValues");
                  for (Object v: vals) { System.out.println(v); }
              }
          }
      }

      ////// Output:
      PI
      3.141592653589793
      java.lang.Math.PI

            Unassigned Unassigned
            avstepan Alexander Stepanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: