I have this very simple piece of code in java:
anyMoreDelayedExplosion |= performEffect(getPanelMap(), getGameState(), this, x, y, effect, true);
anyMoreDelayedExplosion is a boolean field of the class that contains this statement. performEffect is a static method that returns either true or false.
Now, I debugged this (with Android-studio debugger), and I made sure that before executing the =| operation, anyMoreDelayedExplosion is "true". Then, after the operation, it becomes "false".
If I change the code to:
boolean res = performEffect(getPanelMap(), getGameState(), this, x, y, effect, true);
anyMoreDelayedExplosion |= res;
And check again, it correctly stays "true".
How is this possible?
My guesses:
- The debugger is not reliable. Still, this results in an evident bug in the application, that unbelievably gets FIXED by the above correction.
- There is an optimization issue of some kind with the compiler.
- I am totally, completely and utterly missing some truth here.
If anyone has any guess or ideas about how to isolate this kind of behavior, I would be happy to hear them out. Thanks.
EDIT: Here are the declarations, for type completeness:
boolean anyMoreDelayedExplosion;
public static boolean performEffect(PanelMap pm, GameState state, GameSceneHittable scene, int x, int y, SpecialEffect effect, boolean playFX)