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

@BeanProperty: invalid info in case of incomplete (or arbitrary) getter / setter name

XMLWordPrintable

      (sorry, the initial bug was fully rewritten)


      This is some boundary case. As it follows from the bean spec (not sure if it is the latest one: http://download.oracle.com/otndocs/jcp/7224-javabeans-1.01-fr-spec-oth-JSpec/ ), "accessor methods can have arbitrary names", but it is recommended to use something like "getXxx", where "xxx" is a property name.

      Here is some degenerate case:

          public static class C {
              private final int x = 42;
              @BeanProperty(expert = true, description = "TEST")
              public int get() { return x; }
          }
          
          public static void main(String[] args) throws Exception {
              
              BeanInfo i = Introspector.getBeanInfo(C.class, Object.class);
              
              if (i.getPropertyDescriptors().length > 0) {
                  PropertyDescriptor d = i.getPropertyDescriptors()[0];
                  System.out.println(d.getShortDescription());
                  System.out.println(d.isExpert());
              } else {
                  System.out.println("no properties!");
              }
          }

      Output (Win 7, JDK9 b72):
      no properties!

      please try to change "get" to "get_" -> the output is as expected:
      TEST
      true

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

              Created:
              Updated: