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

@BeanProperty: what is the correct output in case of repeating annotations?

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b124

      Description

      What is the correct behavior in the following case?


      import java.beans.*;

      public class PropertyAccessLevelTest {
          
          public static class C1 {
              private boolean x;
              @BeanProperty(hidden = true, expert = true, description = "xxx")
              public void setX(boolean b) { x = b; }
              @BeanProperty(hidden = false, expert = false, description = "yyy")
              public boolean getX() { return x; }
          }

          public static class C2 {
              private boolean x;
              @BeanProperty(hidden = false, expert = false, description = "yyy")
              public void setX(boolean b) { x = b; }
              @BeanProperty(hidden = true, expert = true, description = "xxx")
              public boolean getX() { return x; }
          }

          private static void runTest(Class<?> c) throws Exception {

              BeanInfo i = Introspector.getBeanInfo(c, Object.class);
              PropertyDescriptor pd[] = i.getPropertyDescriptors();
              for (PropertyDescriptor d: pd) {
                  System.out.print(d.getShortDescription());
                  System.out.print(", hidden = " + d.isHidden());
                  System.out.println(", expert = " + d.isExpert());
              }
          }
          
          public static void main(String[] args) throws Exception {
              runTest(C1.class);
              runTest(C2.class);
          }
      }

      Output (Win 7, JDK9 b72):
      yyy, hidden = true, expert = true
      xxx, hidden = true, expert = true

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              serb Sergey Bylokhov
              Reporter:
              avstepan Alexander Stepanov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: