I have a complex case in a switch
statement that (as it happens) always abruptly terminates (with a return, or break or ...). I'd like to put something like lint's /*UNREACHABLE*/
declaration so as to indicate to anyone reading the code that it doesn't fall through to the next case (a common bug in Java). I'm looking for a more formal way to indicate this, ideally something that would cause a compiler warning or error if it was not unreachable. Any ideas?
switch (x) {
case 1:
if (...) {
switch (.) {
...
}
} else {
...
}
/*UNREACHABLE*/
case 2:
...
}
The code is truly unreachable and the Java compiler knows it is, so I can't put any (normal) code there because it would be marked as unreachable code by the compiler.