Closing It looks like it’s related to the IDE (Eclipse). I built a separate class with the same code and different name and it works fine. Tried cleaning, restarting etc. Ugh.
Updated test code I’m stumped here and I’m guessing it’s something stupid. I’ve whittled my code down to this which reproduces the issue.
This executes mMemberVar = 2; and then causes the return now.add(Calendar.DAY_OF_YEAR, 1); to be skipped. It then skips to return null;
Is this caused by it being Serializable and something strange with modifying it’s own member variables? I can’t find anything on it.
public class Alarm implements Serializable {
int mMemberVar = 0;
public Calendar nextTime() {
Calendar now = Calendar.getInstance();
if (true) {
if (true) {
if (true) {
mMemberVar = 2;
// return is skipped
now.add(Calendar.DAY_OF_YEAR, 1);
return now;
}
}
now.add(Calendar.DAY_OF_YEAR, 2);
return now;
}
return null;
}
}
Probably your IDE didn’t even recompile the code you wrote here. I’m guessing that because Calendar.add does not return anything, so the code you are showing can not be compiled at all.
So basically, you are running an old version of code which always returns null. Try doing “clean” then “rebuild” or similar action in your IDE.