jacoco
jacoco copied to clipboard
Improve FinallyFilter
class Example {
private static String example(int i) {
try {
switch (i) {
case 0:
return "case 0";
case 1:
return "case 1";
}
} finally {
System.out.println(i == 0); // currently 1 of 4 branches missed
}
return "";
}
public static void main(String[] args) {
example(0);
example(1);
example(2);
}
}
switch
- is last inside try-finally
- without
default -
returnin allcases
class Example {
public static void main(String[] args) {
loop: for (int i = 0; i <= 5; i++) {
try {
switch (i) {
case 1:
System.out.println("case 1");
break;
case 5:
break loop;
default:
System.out.println("default");
break;
}
System.out.println();
} finally {
System.out.println(i == 0); // currently 1 of 4 branches missed
}
}
}
}