<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p>Yes, you are correct. The underlying bootstrap is already capable
      to handle enum constants:</p>
    <p><a class="moz-txt-link-freetext" href="https://download.java.net/java/early_access/jdk20/docs/api/java.base/java/lang/runtime/SwitchBootstraps.html#enumSwitch(java.lang.invoke.MethodHandles.Lookup,java.lang.String,java.lang.invoke.MethodType,java.lang.Object...)">https://download.java.net/java/early_access/jdk20/docs/api/java.base/java/lang/runtime/SwitchBootstraps.html#enumSwitch(java.lang.invoke.MethodHandles.Lookup,java.lang.String,java.lang.invoke.MethodType,java.lang.Object...)</a></p>
    <p>I also agree that the right time to make the refactoring is when
      patterns in switch is finalized (as SwitchBootstraps is a preview
      class).</p>
    <p>Cheers<br>
      Maurizio<br>
    </p>
    <div class="moz-cite-prefix">On 10/01/2023 18:44, Archie Cobbs
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CANSoFxtwmZkchTy3KTKLM7FR=bywj8ThTBy+RNK0msSfJeo3PA@mail.gmail.com">
      
      <div dir="ltr">
        <div>Following up on this...</div>
        <div><br>
        </div>
        <div>It looks to me like this is pretty much implemented already
          as part of the JEP 433 "Pattern Matching for switch" preview
          feature.</div>
        <div><br>
        </div>
        <div>It appears that <span style="font-family:monospace">TransPatterns.handleSwitch()</span>
          would DTRT. Currently it's only used if the switch has one or
          more patterns, but since it's written to handle switches with
          a combination of patterns and constants, simply feeding it a
          "traditional" enum switch should accomplish what we want.</div>
        <div><br>
        </div>
        <div>So that makes this primarily a refactoring task, but one
          that should probably wait until JEP 433 is out of preview.<br>
        </div>
        <div><br>
        </div>
        <div>-Archie<br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Mon, Jan 9, 2023 at 10:20
          AM Archie Cobbs <<a href="mailto:archie.cobbs@gmail.com" moz-do-not-send="true" class="moz-txt-link-freetext">archie.cobbs@gmail.com</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div dir="ltr">
            <div dir="ltr">
              <div>Thanks for the comments. Using invokedynamic makes
                perfect sense! (and I'm disappointed I didn't think of
                it :)</div>
              <div><br>
              </div>
              <div>I'll take a look into it and report back.</div>
              <div><br>
              </div>
              <div>-Archie<br>
              </div>
              <br>
            </div>
            <div class="gmail_quote">
              <div dir="ltr" class="gmail_attr">On Mon, Jan 9, 2023 at
                9:54 AM Maurizio Cimadamore <<a href="mailto:maurizio.cimadamore@oracle.com" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">maurizio.cimadamore@oracle.com</a>>
                wrote:<br>
              </div>
              <blockquote class="gmail_quote" style="margin:0px 0px 0px
                0.8ex;border-left:1px solid
                rgb(204,204,204);padding-left:1ex">
                <div>
                  <p>I agree with Brian. If we want to fix this and put
                    our hands in the enum switch classification, I think
                    the best use of our time would be to tweak enum
                    switches to adopt the superior indy-based
                    classification approach, which should be immune to
                    the issue you present.</p>
                  <p>Thanks<br>
                    Maurizio<br>
                  </p>
                  <div>On 09/01/2023 15:35, Brian Goetz wrote:<br>
                  </div>
                  <blockquote type="cite"> <font face="Menlo">Another
                      strategy is to use an `invokedynamic` as a switch
                      classifier.  (I believe there is even a bootstrap
                      for this implemented somewhere.)<br>
                    </font></blockquote>
                </div>
              </blockquote>
            </div>
            <br>
            -- <br>
            <div dir="ltr">Archie L. Cobbs<br>
            </div>
          </div>
        </blockquote>
      </div>
      <br clear="all">
      <br>
      -- <br>
      <div dir="ltr" class="gmail_signature">Archie L. Cobbs<br>
      </div>
    </blockquote>
  </body>
</html>