<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">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">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>