Affects PMD Version:
6.16.0, 6.17.0
Rule:
MissingOverride
Description:
False positive for package-private method triggered by class extended in another package.
A package-private method cannot
be directly overridden by a method in a different package JLS 8.4.8.1.
The method in the derived class is not the inherited method and thus the rule should not flag it as needing an @OverRide annotation. Package-private methods can only be overridden by classes defined in the same package as the base class.
Code Sample demonstrating the issue:
package click; public class CodeTalk { public void doIt() { printMessage(); } void printMessage() { System.out.println("Click"); } } package hack; import click.CodeTalk; public class TypeIt { private static class ClickIt extends CodeTalk { void printMessage() { System.out.println("Hack"); } } public static void main(String[] args) { ClickIt clickit = new ClickIt(); clickit.doIt(); } }
Running PMD through: *[CLI | Ant] *
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4