Closed Gold856 closed 1 month ago
apparently none of the linters can handle an exhaustive switch expression with no default
Are you handling the case of null
? (Or otherwise proving it's not null)
Are you handling the case of
null
? (Or otherwise proving it's not null)
That's not available until Java 21. Switch expressions/statements have historically thrown NPEs until Java 21. And some of the tools say they won't warn on switch expressions because javac will check switch exhaustiveness, but they still warn anyways.
Apparently switch expressions are separate from arrow labels, so when the linters were warning about missing switch defaults on switch statements, they were, in fact, warning about missing switch defaults on switch statements. Defaults have been put back in, matching whatever previous logic was present.
Did you do this by hand, or did you use a tool?
I cherry-picked @SamCarlberg's commit that refactored a bunch of code to use Java 21 features, removed the Java 21 parts to make it Java 17 compatible, and refactored any remaining code, mostly by using VS Code's search feature with the regexes case .*:
to convert case labels, else if
to search for places where a switch would be better, and instanceof
to convert instanceof usages.
Uses enhanced instanceof (and simplify
equals
methods) Uses switch expressions and arrow labels Seal and finalize some Shuffleboard classes