Keeping AdvancedRobot instance in static field
The highlighted comment was created in this revision.
When keeping AdvancedRobot instance in static field, robot will show warning:
Static references to robots can cause unwanted behaviour with the robot using these.
However I've been using this pattern (the way robocode can't detect, and I cannot avoid as well) since the first day I write robocode. However, robocode did not mention what's wrong with this pattern. Do anyone know what's the exact meaning of this warning?
I think the risk is that the static robot reference is not guaranteed to be valid after a given round, so if you don’t update the reference things may not work as expected.
Yes, that's also what I guess, and since I'm updating the reference every round, I guess it would not be a problem. However, since robocode did not say what unwanted behavior it is, I'm worrying about more problems: race condition (since each round you have a new thread), GC problem (no longer a problem since robocode cleans static field each battle) and more