When I use something like the following in my Quarkus application:
@Path("v1")
@Produces(APPLICATION_JSON)
public class HelloWorldResource {
@Inject
private SomeBean someBean;
}
then I get a warning the following during the build process.
[INFO] [io.quarkus.arc.processor.BeanProcessor] Found unrecommended usage of private members (use package-private instead) in application beans:
- @Inject field acme.jaxrs.v1.HelloWorldResource#someBean
Everything seems to work just fine so why is Quarkus suggesting that change private
to package-private
?
If a property is package-private
, Quarkus can inject it directly without requiring any reflection to come into play.
That is why Quarkus recommends package-private
members for injection as it tries to avoid reflection as much as possible (the reason for this being that less reflection means better performance which is something Quarkus strives to achieve).
See section 2 of this guide for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With