In the statement:
fooFunc().barFunc(bazFunc());
barFunc() can obviously not execute until both bazFunc() and fooFunc() have completed.
But is the order of execution of fooFunc() and bazFunc() guaranteed?
Related (but different!) question: Order of execution of parameters guarantees in Java?
The documentation for this is 15.12.4. Run-time Evaluation of Method Invocation
It says “At run-time, method invocation requires five steps. First, a target reference may be computed. Second, the argument expressions are evaluated. Third, the accessibility of the method to be invoked is checked. Fourth, the actual code for the method to be executed is located. Fifth, a new activation frame is created, synchronization is performed if necessary, and control is transferred to the method code.”
In the example,
fooFunc()is called as part of computing the target reference, andbazFunc()is one of the argument expressions, sofooFunc()must be called first.