You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[java] UnusedPrivateMethod: False positive with overloaded private methods called with values returned from methods defined in other classes #6393
Description:
I have an overloaded private method called by default methods in an interface. If I call these methods with literals, then the rule does not fail, however, when calling them with the return value from a method I see a false-positive.
Also, if the class with the getLong method is an inner-class, I don't see the violation. So, I assume there's some failure to get the return type of the method that only happens with top-level classes.
changed the title [-][java] UnusedPrivateMethod with overloaded private method in interfacr[/-][+][java] UnusedPrivateMethod with overloaded private method in interface[/+]on Jan 8, 2026
I've just found another instance of this problem in a class, so it's not specific to interfaces but just any overloaded private method that is called with a value returned from a method defined outside of the current class.
changed the title [-][java] UnusedPrivateMethod with overloaded private method in interface[/-][+][java] UnusedPrivateMethod false-positive with overloaded private methods called with values returned from methods defined in other classes[/+]on Jan 8, 2026
That said, UnusedPrivateMethod has checks in place to avoid false positives in that case, and here they are not working. So there is something we can fix here.
But fixing your configuration is the only thing that will make the rule work accurately and properly. Since you run the rule in Maven, make sure you are running PMD only after the compile phase has run, so that compiled classes are found by PMD.
changed the title [-][java] UnusedPrivateMethod false-positive with overloaded private methods called with values returned from methods defined in other classes[/-][+][java] UnusedPrivateMethod: False positive with overloaded private methods called with values returned from methods defined in other classes[/+]on Jan 16, 2026
Activity
[-][java] UnusedPrivateMethod with overloaded private method in interfacr[/-][+][java] UnusedPrivateMethod with overloaded private method in interface[/+]jjlharrison commentedon Jan 8, 2026
I've just found another instance of this problem in a class, so it's not specific to interfaces but just any overloaded private method that is called with a value returned from a method defined outside of the current class.
[-][java] UnusedPrivateMethod with overloaded private method in interface[/-][+][java] UnusedPrivateMethod false-positive with overloaded private methods called with values returned from methods defined in other classes[/+]oowekyala commentedon Jan 8, 2026
The problem is that you are not including compiled class files for the classes that define the called method (eg here, your
Thingclass) on the auxclasspath. Otherwise PMD would be able to resolve the method call to one or the other overload. See https://pmd.github.io/pmd/pmd_languages_java.html#providing-the-auxiliary-classpathThat said, UnusedPrivateMethod has checks in place to avoid false positives in that case, and here they are not working. So there is something we can fix here.
But fixing your configuration is the only thing that will make the rule work accurately and properly. Since you run the rule in Maven, make sure you are running PMD only after the
compilephase has run, so that compiled classes are found by PMD.jjlharrison commentedon Jan 8, 2026
@oowekyala : Thank you. I can confirm that changing the Maven phase has resolved the issue for me.
[-][java] UnusedPrivateMethod false-positive with overloaded private methods called with values returned from methods defined in other classes[/-][+][java] UnusedPrivateMethod: False positive with overloaded private methods called with values returned from methods defined in other classes[/+][java] Fix pmd#6393: UnusedPrivateMethod FP on overloaded methods whe…