Java cvprof Coverage Report for
OptimisationArtifacts.java

    1   
    2   package uk.co.badgersinfoil.cvprof.example;
    3   
    4   /**
    5    * Compile-time optimisation effects the coverage profile, usually be removing
    6    * code before it's even executed.
    7    */
    8   public class OptimisationArtifacts {
    9   	private int someField;
   10   	public void test() {
   11   		int a = accessField();
   12   
   13   		switch (a) {
   14   		    case 0:
   15   			// Bytecode must be generated for this break statement
   16   			break;
   17   		    case 1:
   18   			// Because this break statement is the last thing in
   19   			// the enclosing switch, it can be optimised away, and
   20   			// isn't marked as 'executable' when this class is
   21   			// compiled by many compilers
   22   			break;
   23   		}
   24   
   25   		// This if-statement may be completely optimised away at
   26   		// compilation time.  The report doesn't mark it 'not covered'
   27   		// because it's never seen by the profiler.
   28   		if (false) {
   29   			new Object();
   30   		}
   31   	}
   32   
   33   	public int accessField() {
   34   		return someField;
   35   	}
   36   }