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: could not handle javax.annotation #6627
UnusedPrivateMethod incorrectly flags private methods annotated with @javax.annotation.PostConstruct and @javax.annotation.PreDestroy as unused. These methods are invoked reflectively by the container (e.g., CDI / Spring) during the application lifecycle and should therefore not be considered unused.
Expected outcome: Private methods annotated with @javax.annotation.PostConstruct or @javax.annotation.PreDestroy should be treated as used (invoked reflectively by the container), and UnusedPrivateMethod should not report a violation.
Actual outcome: PMD reports UnusedPrivateMethod on methods annotated with @javax.annotation.PostConstruct and @javax.annotation.PreDestroy, resulting in a false positive.
Activity
UncleOwen commentedon Apr 27, 2026
Have you tried setting the
ignoredAnnotationsproperty?Emilyaxe commentedon Apr 28, 2026
Thank you, I will carefully study the rule configuration.
[java] Fix #6627: UnusedPrivateMethod: add javax to ignored annotatio…
Fix pmd#6627: Add javax.annotation.PostConstruct/PreDestroy to defaul…
@javax.annotation.PostConstruct/@PreDestroywhile the equivalentjakarta.annotation.*annotations are correctly ignored #7221 as a duplicate of this issue