Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-1308

WireVariable does not wire a superclass field if a field with the same name is declared in a subclass

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: 6.0.2
    • Fix Version/s: 6.5.1
    • Component/s: None
    • Labels:
      None

      Description

      Example:

      class A {
        @WireVariable private MyClass var;
      }
      
      class B extends A {
        @WireVariable private MyClass var;
      }
      

      When using wiring variables for B, field var in superclass A will not be wired (will be null). This is documented in Reflections.forFields() method which is used in Selectors.Wirer.wireVariables(). But such a solution is counter-object-oriented - subclass B it breaks class's A contract by mere declaration of a field with the same name. That way, class A depends on its subclasses and not the other way around - class A works only if the subclass does not wire a field with the same name. Furthermore, it requires the programmer to know about class's A private member when implementing subclass B, thus breaking class's A encapsulation.

      All fields annotated with @WireVariable should be wired in the whole class hierarchy.

        Attachments

          Activity

            People

            Assignee:
            jumperchen jumperchen
            Reporter:
            hattifnat hattifnat
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: