Escape analysis

If a language supports first-class continuations (as do Scheme and Standard ML of New Jersey), portions of the call stack may also escape.

[1] The popularity of the Java programming language has made escape analysis a target of interest.

Java's combination of heap-only object allocation, built-in threading, the Sun HotSpot dynamic compiler, and OpenJ9's just-in-time compiler (JIT) creates a candidate platform for escape analysis related optimizations (see Escape analysis in Java).

The method setFoo() stores a reference to a received Foo object.

As a result, the reference to Foo cannot escape either, and the compiler can safely allocate both objects on the stack.