Tail Call Optimisation in Java

Why can’t Java use the same approach ?

I can’t say which approach will be used, but it’s better-explained in Project Loom’s proposal:

As adding the ability to manipulate call stacks to the JVM will undoubtedly be required, it is also the goal of this project to add an even lighter-weight construct that will allow unwinding the stack to some point and then invoke a method with given arguments (basically, a generalization of efficient tail-calls). We will call that feature unwind-and-invoke, or UAI. It is not the goal of this project to add an automatic tail-call optimization to the JVM.

As far as I’ve heard, work has not yet begun on tail calls, as Fibers and Continuations seem to currently be a higher priority.

Leave a Comment