Exponential compilation time for List.of(Map.entry) expressions

Gavin Bierman gavin.bierman at oracle.com
Tue Jan 21 15:34:01 UTC 2025


FWIW There’s extensive research on the complexity of similar type inference problems. For example, the essence of the ML type inference problem (this is the one that inspired most similar "type inference in the presence of generic types" problems, including Java’s) was shown to be doubly-exponential (yikes!) although in most cases that can be cut down a lot. Here's an interesting survey article if you want to learn more:

http://gallium.inria.fr/~fpottier/publis/emlti-final.pdf

Gavin


On 21 Jan 2025, at 12:38, Dawid Weiss <dawid.weiss at gmail.com> wrote:

This is a performance problem for IntelliJ as well. Highlighting becomes slow on such code. Not sure whether it's slower or faster than javac, but it's definitely slow. So technically, it's 'javac + IntelliJ quirks' :-)

I can add ecj to this: "javac" + "intellij" + "Eclipse ecj" quirks
because I've tried out of curiosity and ecj also grinds to a halt on
this pattern.

Oh well, thanks for the interesting discussion. I've learnt something new.

Dawid

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20250121/486bfaa8/attachment-0001.htm>


More information about the compiler-dev mailing list