Once a class is loaded is there a way to invoke static initializers again?
public class Foo { static { System.out.println('bar'); } }
Edit:
I need to invoke the static initializer because I didn’t write the original class and the logic I need to invoke is implemented in the static initializer.
One circumstance in which the logic would be run more than once is if the class is loaded multiple times by different ClassLoaders. Note that in this instance, they are essentially different classes.
Generally, though, these are one-shot deals. If you want to be able to invoke the logic multiple times, do as others have suggested and put it in a static method.