title: Overriding Interface Default Methods
body: <p>I am having some trouble getting the following code to work:</p>
  
  <p>Interface:</p>
  
  <pre><code>public interface UOWProcessor {
    public default Integer countUOW(Object args) {
      return 1;
    }
  }
  </code></pre>
  
  <p>Implementation:</p>
  
  <pre><code>public class ListUOWProcessor implements UOWProcessor {
  private Integer total;
  
  @Autowired
  private UOWProcessor uowProcessor;
  
  @Override
  public Integer countUOW(List&lt;?&gt; args) {
      for (Object arg : args) {
          total += uowProcessor.countUOW(arg);
      }
  
      return total;
    }
  }
  </code></pre>
  
  <p>Edit: Adding second implementation to clarify intention</p>
  
  <pre><code>public class MapUOWProcessor implements UOWProcessor {
      private Integer total;
  
      @Autowired
      private UOWProcessor uowProcessor;
  
      @Override
      public Integer countUOW(Map&lt;?, ?&gt; args) {
          for (Object item : args.values()) {
              total += uowProcessor.countUOW(item);
          }
  
          return total;
      }
  }
  </code></pre>
  
  <p>The trouble is the @Override annotation is giving an error that says <code>the method does not override a method from its superclass</code>. This is Java 11. What is the correct syntax for this?</p>
  
  <p>Here is what I am trying to do in English if it is not clear from above:</p>
  
  <p>Another class will call the interface method countUOW(Object of unknown type).</p>
  
  <p>If there exists an implementation of this interface for the type of object (for example, ListUOWProcessor for Lists, MapProcessor for Maps) the implementation will then be called and will iterate and return a total (basically a count of objects). This is called recursively to account for nested arrays/lists. </p>
  
  <p>If there exists no implementation, we can assume the Object being passed is some non-specific Object which then has a count of 1. </p>
  
  <p>To the original call of the method we should then return a count of all the Objects in the parent Object that was passed, including those in nested arrays or maps.</p>
  
  <p>I could also remove this word "default" from the Interface and just create an ObjectUOWProcessor which does the same thing - however I am worried it might take precedence over every other implementation because List, Array, Map are all extensions of Object.</p>
  
  <p><strong>Edit:</strong> I understand that this is not an Override, now, but an Overload. Will the code without the @Override annotation achieve the described functionality?</p>