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

@BeanProperty: some wrong results when getting annotation fields by means of reflection

XMLWordPrintable

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

      please run the attached code; the output will be (Win. 7 + JDK9 b115):

      JLabel: bound = true
      >>> LISTENER: icon changed

      BasicComboBoxRenderer: bound = true
      >>> LISTENER: icon changed

      DefaultListCellRenderer: bound = true

      DefaultTableCellRenderer: bound = true

      DefaultTreeCellRenderer: bound = true


      At a 1st glance this looks confusing (reflection says that 'setIcon' is 'bound' for all the classes, but the listener doesn't receive events for the latter 3 classes); but then, looking into sources more carefully, one can find overriden ("for performance reasons") protected 'firePropertyChange' methods which filter out some chosen properties for the latter classes.

      Shouldn't this JLabel's 'setIcon()' method be overriden explicitly in the child classes (calling the super's one) having the proper '@BeanProperty' annotation (having false 'bound' field)?

      Otherwise we have some contradiction with reflection here.

      (of course the example isn't limited with the icon property only. the same for other bound properties, like 'opaque', 'alignmentX', 'alignmentY' etc. so cleaning that out may be a boring procedure)

        1. BoundTest.java
          3 kB
          Alexander Stepanov

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

              Created:
              Updated: