Does Java 8 have tail call optimization?

2020-02-09 07:43发布

I tried digging on the web to get my question answered. I found some documents related to Project DaVinci. This is tagged to the JSR 292 which is related to including closures in the JVM. Did this project get realized and is it a part of Java 8?

2条回答
你好瞎i
2楼-- · 2020-02-09 08:40

As far as I know Java 8 does not have tail call optimization. Afaik it isn't related to the actual compiler trick, because that one is simple, but to preserve a callstack for security purposes. But I guess it would be possible with a bytecode rewriter.

查看更多
等我变得足够好
3楼-- · 2020-02-09 08:45

Java does not support TCO at compiler level but it is possible to implement it with Java 8 using lambda expressions. It is described by Venkat Subramaniamin in "Functional Programming in Java".

查看更多
登录 后发表回答