Is there a way to disable short circuit evaluation in Java?

Viewed 3528

Say I have code like this:

boolean ret = a() && b() && c() && d() && e();

Usually e() is only called if all other calls a()-d() return true. Is there maybe some compiler or JVM option to disable short circuit evaluation, so e() would be called always, regardless of other functions' results?

Basically I am doing UAT of huge system and need to test e(), however setting up environment and scenario that assures all a(), b() etc. return true is extremely painful...

EDIT: ok, I guess using bit AND instead of logical one could provide SOME sort of workaround, however ideally I am looking for a solution that does not require ANY CHANGES in the source code. Both due to formal and technical reason (as i mentioned system is big and we have whole process of promoting and deploying code between staging areas and getting sign-offs). And this is for testing only, production version needs to have lazy evaluation enabled (i.e. use &&)

POST-MORTEM:

  • "Correct" answer is: No, there is not.
  • "Useful" answer: you can change && to &
  • "What I did in the end" answer: debug system remotely, put breakpoint on expression and told eclipse to run e() -_-
3 Answers
Related