You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[java] ExhaustiveSwitchHasDefault/NonExhaustiveSwitch Support future-proofing switch statements against added enum members #6879
Even if you have an a classical switch statement with all cases for an enum plus a default case, the rule mentioned here should not throw if the default case is just throwing an exception.
Maybe even the NonEhaustiveSwitch rule should be enhanced to have a finding if you have an exhaustive switch statement without throwing default case.
If you have a switch statement over an enum that you compile along with the switch statement, you can ensure the branches at compile time.
But if you for example switch over an enum from a different artifact, then at runtime that other artifact could be of a different version and thus there can be more enum constants available, so a default case that throws makes sense to detect this.
If this is added, it would also be questionable whether the NonEhaustiveSwitch should consider a switch statement with not all constants but a throwing default as excaustive already or not.
Maybe it should not be "default case that throws" but "default case that throws AssertionError", so that you can identify the runtime-exhaustiveness-protection default branch from a default branch that intentionally throws an excepetion for other enum-cases.
changed the title [-][java] ExhaustiveSwitchHasDefault/NonEhaustiveSwitch Support future-proofing switch statements against added enum members[/-][+][java] ExhaustiveSwitchHasDefault/NonExhaustiveSwitch Support future-proofing switch statements against added enum members[/+]on Aug 21, 2026
Activity
[-][java] ExhaustiveSwitchHasDefault/NonEhaustiveSwitch Support future-proofing switch statements against added enum members[/-][+][java] ExhaustiveSwitchHasDefault/NonExhaustiveSwitch Support future-proofing switch statements against added enum members[/+]