Quarkus @Startup Method Signature
ID |
java.quarkus_startup_method_signature |
Severity |
high |
Remediation Complexity |
trivial |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Reliability |
Language |
Java |
Tags |
quarkus, reliability |
Description
Reports a method annotated @Startup that is static, takes one or more arguments, or is also a producer method (@Produces). A method violating more than one of these at once is reported once per violated requirement — a static method that also takes a parameter yields two findings.
Rationale
The CDI container invokes a @Startup method as part of bringing up a managed bean instance, generating the initialization hook at build time. That mechanism only works for an instance method with no parameters that is not also a producer: a static method belongs to the class rather than to the managed instance, a parameter has no value the container can supply, and a producer method exists to hand out other components, not to run initialization logic. Any of the three means the method is simply never called the way @Startup promises, with no build-time warning.
@ApplicationScoped
class EagerServiceBean {
@Startup
static void primeCache() { // never invoked: static methods are not called by the container
}
}