JEP proposed to target JDK 17: 406: Pattern Matching for switch (Preview)
Brian Goetz
brian.goetz at oracle.com
Tue Jun 1 19:32:57 UTC 2021
We try very hard to stay away from this technique, for several reasons.
First, the language *has* a definition; compilers should, in general,
implement that, not second-guess it. And second, it doesn't scale; the
endgame of that approach is that we end up with an ever-growing set of
flags (possibly interacting!) for enforcing the top 10,000 most popular
coding styles. This is something better handled by IDEs or static
analysis tools, where you can configure them to bark on the patterns you
find problematic.
But, you do have the option of using -Werror, which offers
zero-tolerance for warnings, and then can turn on the lint warning
categories of your choice.
On 6/1/2021 2:48 PM, Mike Rettig wrote:
> From the JEP:
>> It may be the case that future compilers of the Java language will emit
> warnings for legacy switch statements that are not complete.
>
> It would be ideal to add a compiler switch to make it an error instead of a
> warning on incomplete switches.
>
> Mike
More information about the jdk-dev
mailing list