Branch: refs/heads/main
Home: https://github.com/pmd/pmd
Commit: 6dcf9f1660ee731d8c85ca3eec0f6d7ee642a8d7
https://github.com/pmd/pmd/commit/6dcf9f1660ee731d8c85ca3eec0f6d7ee642a8d7
Author: fudian <[email protected]>
Date: 2026-08-14 (Fri, 14 Aug 2026)
Changed paths:
M docs/pages/release_notes.md
M
pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedPrivateMethodRule.java
M
pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/UnusedPrivateMethod.xml
Log Message:
-----------
[java] Fix #6393: UnusedPrivateMethod FP on overloaded methods when overload
resolution fails (#6947)
What:
UnusedPrivateMethod reported a false positive on one of several overloaded
private methods when a call's argument is the return value of a method
declared in a type that is not on the auxiliary classpath (unresolved
receiver/return type), causing overload resolution to fail.
Root cause:
When overload resolution fails (OverloadSelectionResult#isFailed()), the
selected method symbol is an arbitrary fallback, not the actually-called
overload. The rule only branched into the conservative "whitelist all
same-named candidates" path when the symbol was unresolved
(JExecutableSymbol#isUnresolved()). A failed-but-resolved fallback
therefore caused only that one overload to be marked used, flagging the
remaining overload(s) as unused.
Fix:
Treat a failed overload selection like an unresolved call, so all
same-named private method candidates are whitelisted when the receiver
may be an instance of the analysed class (existing handleUnresolvedCall
logic). This is consistent with the rule's existing false-positive-avoiding
trade-off for unresolved calls.
Testing:
New test case in UnusedPrivateMethod.xml reproducing the issue (expects 0
violations). Full UnusedPrivateMethodTest: 111 tests, 0 failures, 0 errors
(2 pre-existing skipped).
Signed-off-by: 付典 <[email protected]>
Co-authored-by: Sören Glimm <[email protected]>
To unsubscribe from these emails, change your notification settings at
https://github.com/pmd/pmd/settings/notifications
_______________________________________________
Pmd-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pmd-commits