I have an enum switch more or less like this:
public static enum MyEnum {A, B}
public int foo(MyEnum value) {
switch(value) {
case(A):
Rather than using some radical bytecode manipulation to enable a test to hit the last line in foo
, I would remove it and rely on static code analysis instead. For example, IntelliJ IDEA has the "Enum switch
statement that misses case" code inspection, which would produce a warning for the foo
method if it lacked a case
.