Get the latest tech news
Tail Call Recursion in Java with ASM (2023)
One kind of optimization offered by some compilers is tail call optimization. This optimization does not bring much, since the programmer can always tailor his code without recursion, especially in an imperative language.
In this article I will present a neat way to implement tail call optimization in Java using byte code manipulation with ASM. ASM is a wonderfull and neat library which allows one to analyze, transform and generate byte code at compile time or at runtime. The next stage is to remove the recursive call and the return instruction after it, altogether with preparing the local variables and stack for next use.
Or read this on Hacker News