All examples for annotated methods like postConstruct() or preDestroy() always have a public visibility. But the DI mechanism still works if I reduce the visibility to protected or private.
As those methojds only get called by the framework, what should be their visibility?
I never call those methods myself and I don't want anyone other than the framework invoking them - so they should not be public. But they are an external interface to my class.
What is the preferred method here?
Method.setAccessible(true)
which makes it public for that call. – greg-449 Dec 6 '18 at 15:43