<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    Thanks for the details, we'll try to fix it on IDEA side.<br>
    <br>
    Egor<br>
    <br>
    <div class="moz-cite-prefix">On 7/14/2025 11:32 PM, Maurizio
      Cimadamore wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:07750800-6bca-46c4-b480-f360dc06d650@oracle.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <p>Hi Egor,<br>
        I confirm that this change is deliberate. There were several
        changes required to make JEP 513 (Flexible Constructor Bodies)
        work. Some of these changes resulted in significant rewrites of
        the compiler backend (to move lambda translation ahead of inner
        class translation). The bulk of the work (and some history) is
        here:</p>
      <p><a class="moz-txt-link-freetext"
          href="https://github.com/openjdk/jdk/pull/19836"
          moz-do-not-send="true">https://github.com/openjdk/jdk/pull/19836</a></p>
      <p>This change created some compatibility issues for serializable
        lambdas, which were later addressed here:</p>
      <p><a class="moz-txt-link-freetext"
          href="https://github.com/openjdk/jdk/pull/20349"
          moz-do-not-send="true">https://github.com/openjdk/jdk/pull/20349</a></p>
      <p>This latter change dropped a lot of accidental complexity from
        the javac LambdaToInner pass, and that meant making the logic
        for computing the names serializable and non-serializable
        lambdas more robust.</p>
      <p>This meant that, unfortunately, the (unspecified) name of some
        non-serializable lambda changed. This compatibility issue is
        described in the associated CSR:</p>
      <p><a class="moz-txt-link-freetext"
          href="https://bugs.openjdk.org/browse/JDK-8337558"
          moz-do-not-send="true">https://bugs.openjdk.org/browse/JDK-8337558</a></p>
      <p>The difference you see is caused by when the name of the
        translated lambda method is generated -- it used to be computed
        _after_ the end of the lambda body, now it is computed
        _before_.  This means that as soon as we see the outermost
        lambda for `r3` we give it the first number -- then the nested
        lambda for `r4` gets the second number.</p>
      <p>This allows us to avoid having to "patch" the names of the
        translated symbols, which minimizes the amount of mutation in
        our code, making it less brittle. So, unless there's a big
        reason as to why these names should go back the way they were,
        we'd like to keep the code the way it is :-)<br>
      </p>
      <p>Cheers<br>
        Maurizio<br>
      </p>
      <div class="moz-cite-prefix">On 11/07/2025 16:08, Egor Ushakov
        wrote:<br>
      </div>
      <blockquote type="cite"
        cite="mid:71f259c7-a64e-4550-ae4d-b28b8ed0c792@jetbrains.com">
        Hi everyone!<br>
        <br>
        it looks like in jdk 24 compiler started naming lambda methods
        slightly differently,<br>
        consider the code:<br>
        <div style="background-color:#ffffff;color:#080808">
          <pre
style="font-family:'Source Code Pro',monospace;font-size:12,0pt;"><span
          style="color:#0033b3;">public class </span><span
          style="color:#000000;">Lambdas1 </span>{
    <span style="color:#0033b3;">public static void </span><span
          style="color:#00627a;">main</span>(<span
          style="color:#000000;">String</span>[] <span
          style="color:#000000;">args</span>) {
        <span style="color:#000000;">Runnable r3 </span>= () -> {
            <span style="color:#000000;">Runnable r4 </span>= () -> <span
          style="color:#000000;">System</span>.<span
          style="color:#871094;font-style:italic;">out</span>.println(<span
          style="color:#0033b3;">new </span>Exception().getStackTrace()[<span
          style="color:#1750eb;">0</span>]);
            <span style="color:#000000;">r4</span>.run();
            <span style="color:#000000;">System</span>.<span
          style="color:#871094;font-style:italic;">out</span>.println(<span
          style="color:#0033b3;">new </span>Exception().getStackTrace()[<span
          style="color:#1750eb;">0</span>]);
        };
        <span style="color:#000000;">r3</span>.run();
    }
}

</pre>
          with jdk 23 the output is:<br>
          Lambdas1.lambda$main$<b>0</b>(Lambdas1.java:7)<br>
          Lambdas1.lambda$main$<b>1</b>(Lambdas1.java:9)<br>
          <br>
        </div>
        with jdk 24:<br>
        Lambdas1.lambda$main$<b>1</b>(Lambdas1.java:4)<br>
        Lambdas1.lambda$main$<b>0</b>(Lambdas1.java:6)<br>
        <br>
        I know that this is not specified anywhere, but Intellij IDEA
        relied on this and it caused issues with debugger features:<br>
        <a class="moz-txt-link-freetext"
          href="https://youtrack.jetbrains.com/issue/IDEA-375811"
          moz-do-not-send="true">https://youtrack.jetbrains.com/issue/IDEA-375811</a><br>
        <br>
        Was this change really intended? Could anyone please point me to
        the fix that caused this?<br>
        <br>
        Thanks!<br>
        Egor<br>
      </blockquote>
    </blockquote>
    <br>
  </body>
</html>