title: Howto activate eclipse java warning "unnecessary declaration of thrown exception" without getting false positives?
body: <p>I hate functions that declare to throw exceptions that are not thrown by this functions in any case. This happens in refactorings if <code>throw</code> statements are removed in the function body without removing it from the <code>throws</code> definitions.</p>
  
  <p>Thats why I activated the setting Java -> Compiler -> Errors/Warnings -> Unnecessary code -> Unnecessary declaration of thrown exception.</p>
  
  <p><img src="https://i.stack.imgur.com/kt1Rj.png" alt="enter image description here"></p>
  
  <p>This leads to false positive warnings if exceptions are defined in interfaces or super methods. If implementation A of the interface does not throw one exception type, but implementation B does, eclipse warns about the unnecessary declaration in implemantation A. Thats equally for super and overriden methods. Thats why I activate the suboption "Ignore in overriding and implementing methods".</p>
  
  <p>Perfeclty fine till here. But I have the oposite case. The overridden method throws a exception type, that is not used in the super method. See this minimal example:</p>
  
  <pre class="lang-java prettyprint-override"><code>class Vehicle {
      protected int getStatus() throws GeneralException, StatusException {
          throw new GeneralException("One exception type in super type only");
      }
  }
  
  class Car extends Vehicle {
      @Override
      protected int getStatus() throws GeneralException, StatusException {
          throw new StatusException("Special case, that gets special handling");
      }
  }
  </code></pre>
  
  <p>Now StatusException in Vehicle is warned in eclipse. </p>
  
  <p><img src="https://i.stack.imgur.com/F1ShD.png" alt="enter image description here"></p>
  
  <p>Of course one could argue that this is bad design etc., but from a pragmatic point of view this will happen again and most probably one can accept to not change the architecture, but to simply add the new exception type to the super type. <strong>But howto get rid of the false positive warning in this case?</strong> Of course one could use the suboption with the javadoc, but this would also ignore most real positive hits. Another option is to add the SuppressWarning annotation "unused", but other users could get unneeded warnings for that suppression.</p>