<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">I’m experiencing a change in behavior compiling a particular file.<div><br></div><div>The compiler is trying to match an invocation to one of two constructors for a static class defined in the same file.</div><div><br></div><div>The second constructor has a parameter of type Builder. In the past, this was interpreted as my Builder class, which is imported into this file.</div><div>That matches the invocation.</div><div><br></div><div>Now, however, the constructor parameter type is interpreted as java.lang.Thread.Builder, presumably because the static class extends Thread.</div><div>That causes a mismatch to be reported.</div><div><br></div><div>This interpretation appears to be limited to the resolution of the constructor invocation. Within the constructor, I do not get an error when the parameter</div><div>is used as an instance of my Builder class.</div><div><br></div><div>This happens in JDK 20, JDK 21, and the latest build of JDK 22.</div><div>It does not happen in JDK 17.</div><div><br></div><div>The error message:</div><div><br></div><div><div> [javac] constructor Worker.Worker(@org.jetbrains.annotations.NotNull String,@org.jetbrains.annotations.NotNull SeverityLevel,@org.jetbrains.annotations.NotNull java.lang.Thread.Builder,@org.jetbrains.annotations.Nullable TaskStatusListener,@org.jetbrains.annotations.NotNull SimpleTaskReceiver<BuildResult>) is not applicable</div><div> [javac] (argument mismatch; @org.jetbrains.annotations.NotNull com.cbfiddle.releases.Builder cannot be converted to @org.jetbrains.annotations.NotNull java.lang.Thread.Builder)</div><div><br></div></div><div><br></div><div>The constructor:</div><div><br></div><div><div style="background-color: rgb(255, 255, 255); color: rgb(74, 92, 110);"><pre style="font-family: Menlo, monospace; font-size: 9pt;"><span style="color: rgb(133, 107, 70);">public </span><span style="color: rgb(167, 95, 0);">Worker</span>(<span style="color: rgb(184, 185, 111);">@NotNull </span><span style="color: rgb(73, 84, 94);">String </span><span style="color: rgb(81, 81, 81);">taskName</span><span style="color: rgb(102, 79, 61);">,<br></span><span style="color: rgb(102, 79, 61);"> </span><span style="color: rgb(184, 185, 111);">@NotNull </span><span style="color: rgb(73, 84, 94);">SeverityLevel </span><span style="color: rgb(81, 81, 81);">level</span><span style="color: rgb(102, 79, 61);">,<br></span><span style="color: rgb(102, 79, 61);"> </span><span style="color: rgb(184, 185, 111);">@NotNull </span><span style="color: rgb(81, 81, 81);">Builder builder</span><span style="color: rgb(102, 79, 61);">,<br></span><span style="color: rgb(102, 79, 61);"> </span><span style="color: rgb(184, 185, 111);">@Nullable </span><span style="color: rgb(81, 81, 81);">TaskStatusListener tsl</span><span style="color: rgb(102, 79, 61);">,<br></span><span style="color: rgb(102, 79, 61);"> </span><span style="color: rgb(184, 185, 111);">@NotNull </span><span style="color: rgb(81, 81, 81);">SimpleTaskReceiver</span><<span style="color: rgb(73, 84, 94);">BuildResult</span>> <span style="color: rgb(81, 81, 81);">r</span>)<br>{<br> <span style="color: rgb(133, 107, 70);">this</span>.<span style="color: rgb(99, 82, 107);">taskName </span>= <span style="color: rgb(81, 81, 81);">taskName</span><span style="color: rgb(96, 76, 61);">;<br></span><span style="color: rgb(96, 76, 61);"> </span><span style="color: rgb(133, 107, 70);">this</span>.<span style="color: rgb(99, 82, 107);">level </span>= <span style="color: rgb(81, 81, 81);">level</span><span style="color: rgb(96, 76, 61);">;<br></span><span style="color: rgb(96, 76, 61);"> </span><span style="color: rgb(133, 107, 70);">this</span>.<span style="color: rgb(99, 82, 107);">r </span>= <span style="color: rgb(81, 81, 81);">r</span><span style="color: rgb(96, 76, 61);">;<br></span><span style="color: rgb(96, 76, 61);"> </span><span style="color: rgb(133, 107, 70);">this</span>.<span style="color: rgb(99, 82, 107);">bl </span>= createBuildListener(<span style="color: rgb(81, 81, 81);">tsl</span>)<span style="color: rgb(96, 76, 61);">;<br></span><span style="color: rgb(96, 76, 61);"> </span><span style="color: rgb(133, 107, 70);">this</span>.<span style="color: rgb(99, 82, 107);">op </span>= () -> <span style="color: rgb(179, 141, 196);">builder</span>.perform(<span style="color: rgb(99, 82, 107);">bl</span>)<span style="color: rgb(96, 76, 61);">;<br></span><span style="color: rgb(96, 76, 61);"><br></span><span style="color: rgb(96, 76, 61);"> </span>setPriority(<span style="color: rgb(73, 84, 94);">Thread</span>.<span style="color: rgb(134, 109, 143); font-style: italic;">MIN_PRIORITY</span>)<span style="color: rgb(96, 76, 61);">;<br></span>}<br></pre><pre style="font-family: Menlo, monospace; font-size: 9pt;"><br></pre></div></div></body></html>