On Tue, 9 Aug 2022 10:28:02 GMT, Jan Lahoda <jlah...@openjdk.org> wrote:
> > Would it be possible to add a special case where the labels are all the > > same type? Like all labels are Class.class or Object.class? While testing > > out the pattern matching, I've found myself doing the following > > ```java > > switch (o) { > > case Class<?> c when c == Object.class -> {} > > case Class<?> c when c == Integer.class -> {} > > case Class<?> c when c == String.class -> {} > > case Class<?> c when c == Double.class -> {} > > // ... > > } > > ``` > > I think that there may eventually be some improvements, although the current > round of patches is not intended to improve this pattern, sorry. Also, I > would not expect better behavior that a sequence of ifs. If it eventually gets the same speed as a sequence of ifs, it would be great for me. Right now it is much slower. However, do you think it would be good to track this pattern or should the javac simplify the code generation to not use `SwitchBootstrap.typeSwitch` in this case? ------------- PR: https://git.openjdk.org/jdk/pull/9779