I have a situation where I have a registry class to which certain classes have to register themselves for the system. Since I'm writing an API I can't necessarily know which these classes are before runtime, so my solution is using a static block within each class for it to register itself.
The problem is of course that the static block isn't run until each class is initialized, and because there are no explicit references to each individual class, they never are initialized. Catch-22.
So, is there any way or annotation to make sure that a class is initialized at startup without referring to it explicitly?