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] UnnecessaryCast: False positive with package private methods #5732
The Test class must cast the Bar to a Foo to access the package private method getAThing(), otherwise it is package private in the B package, not the A package.
PMD reports PMD Failure: A.Test:8 Rule:UnnecessaryCast Priority:3 Unnecessary cast (Foo). for the line with the cast.
Expected outcome:
PMD should realize that, for a package private method, the cast is necessary to bring the object into the right package for package private access.
PMD reports a violation at line 8, but that's wrong. That's a false positive.
changed the title [-][java] UnnecessaryCast false positive with package private methods[/-][+][java] UnnecessaryCast: False positive with package private methods[/+]on Aug 30, 2026
Activity
[java] Fix pmd#5732: UnnecessaryCast false positive for package-priva…
[java] Fix pmd#5732: Clarify package-private visibility in Unnecessar…
[java] Fix pmd#5732: UnnecessaryCast false positive for package-priva…
[-][java] UnnecessaryCast false positive with package private methods[/-][+][java] UnnecessaryCast: False positive with package private methods[/+]