I was curious, so I experimented, and discovered that static initialize block in some class is executed at first creation of this classes object or first call of static method of this class. I checked this on Groovy 2.2.1 by creating class with static initialize block printing one thing, and method and constructor that did nothing. In another script I tried doing nothing (to see if existence on classpath would be enough), just importing that class, instantiating it and calling its static method (I modified that script on every test), and static code was executed only on two last cases.
I know it may depend on Groovy implementation, JVM and JRE implementations, maybe even some systemwide config. Or maybe it is defined somewhere, at what point should static code of a class be executed? Best case scenario is that it is defined in JVM Reference (because it would apply to all JVM-based languages), but if not, then maybe it is enforced in language reference? If so, which langauge?
As my code was dirty (I mean, it was REALLY ad-hoc), I won't post it here, unless asked to (I'll reproduce it and format it nicely).
PS. Sorry for duplicate, didn't mean to (tried searching wrong phrases).