Why init instead of static
You do not have permission to edit this page, for the following reasons:
You can view and copy the source of this page.
Return to Thread:User talk:Rednaxela/FastTrig/Why init instead of static.
Voidious, you right in common, but there're an issue - robots are loaded in theirs threads, so you can skip turns any way.
IIRC, while there is a limit on the time for a robot's class to load, it is far greater than the time allowed per turn.
If I recall, the static blocks are called when the class is loaded (in order they are in the source code).
I forget if it is loaded at the same time or on first reference. I think in robocode all class files are loaded at load time. Which means it doesn't matter where it is initialized in this case.
It's been a long time, but when first writing FastTrig, I believe I tested this, and found that classes like this were initialized upon first reference.
I debugged initialization order. Looks like everything is initialized before the battle starts thanks to some field cleaning algorithm inside the engine (net.sf.robocode.host.security.RobotClassLoader#cleanStaticReference(java.lang.reflect.Field)).