Exponential compilation time for List.of(Map.entry) expressions
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Fri Jan 17 10:12:57 UTC 2025
On 17/01/2025 08:00, Tagir Valeev wrote:
> There's a simpler workaround. No need to declare a method, you can
> just add explicit type arguments to Arrays.asList call:
>
> List<Map.Entry<String, String>> value =
> Arrays.<Map.Entry<String, String>>asList(
> Map.entry("key", "value"),
> Map.entry("key", "value"),
> ...
> Map.entry("key", "value"),
> Map.entry("key", "value")
> );
Of course (blush) :-)
> This problem is old and well-known. IntelliJ IDEA even has an
> inspection for it since ages. It's called "Javac quirks" [1], and we
> provide a quick-fix that adds explicit type arguments when the number
> of inference variables exceeds some threshold. Probably thanks to
> this, the OpenJDK project receives much fewer complaints about this
> problem than it could be :-)
Didn't know about "javac quirks" :-)
Question: is intellij able to figure out the correct types w/o ending up
with combinatorial explosion -- or is it using some heuristic to "guess"
what the likely type arguments are going to be?
Maurizio
More information about the compiler-dev
mailing list