1
2 package uk.co.badgersinfoil.cvprof.example;
3
4 /**
5 * The the final, closing brace of a method definition may be unexpectedly
6 * highlighted 'not covered'. This is due to implicit return bytecodes added
7 * to void methods by the java compiler.
8 */
|
9 public class SyntheticReturns {
|
10 public void test() {
|
11 multiReturns();
|
12 //emptyMethod();
|
13 }
|
14
15 /**
16 * Some Java compilers will synthesise 'return' bytecodes that are
17 * actually unreachable bacause the return in a finally block is always
18 * executed to exit the method.
19 */
20 private void multiReturns() {
21 try {
|
22 new Object();
23 } finally {
24 return;
|
25 }
26 // J2SDK1.3's javac, at least, synthesizes a 'return'
27 // at the next line that will not be marked as covered,
|
28 > }
|
29
30 /**
31 * Even if a method is empty, it will still be flagged by the coverage
32 * report if it isn't called. A 'return' bytecode is synthesized by
33 * the Java compiler, and this has not been marked in the coverage
34 * profile.
35 */
36 private void emptyMethod() {
|
37 > }
|
38 }
|