Affects PMD Version:
6.14.0
Rule:
MissingStaticMethodInNonInstantiatableClass
Description:
When using dependency injection like CDI, Spring or similar, a "non instantiable class" is not necessarily really "non instantiable" as long as the private constructor does not also throw an exception.
When there are dependency injection annotations like @Inject
, @Produces
, @Observes
, @Autowire
, and so on or bean defining annotations on the class like @ApplicationScoped
, @Dependent
, @RequestScoped
and so on, the class should not be considered "non instantiable", except if it was determined that the constructor also always throws an exception.
It is pretty common practice to make those classes have a private constructor to ensure they are instaniated by the DI framework and not manually (except through reflection of course).
Running PMD through: Gradle
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