title: java.lang.VerifyError when using emma / Cobertura on JDK 1.7
body: <p>I am facing the exact same issue mentioned in the link below when trying to create a build using Apache Buildr. </p>
  
  <p><a href="https://stackoverflow.com/questions/7010665/testng-emma-cobertura-coverage-and-jdk-7-result-in-classformaterror-and-verif">Testng, Emma, Cobertura, coverage and JDK 7 result in ClassFormatError and VerifyError</a></p>
  
  <p>I tried using the -XX:-UseSplitVerifier option(as below) when testing the artifacts but that doesn't resolve my issue.</p>
  
  <pre><code>  test.using( :java_args =&gt; ['-ea','-XX:-UseSplitVerifier'])
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>Instrumenting classes with emma metadata file /test-client/reports/emma/coverage.em
  JavaTestFilter: Unable to load class com.test.activemq.QueueConsumerTest to determine testing ability
  </code></pre>
  
  <p><strong>Update - Solution / Root cause..</strong></p>
  
  <p>Code compiled using Java 1.7 requires stack map frame instructions. If you wish to modify Java 1.7 class files, you need to use ClassWriter.COMPUTE_FRAMES or MethodVisit.visitFrame().</p>
  
  <p><strong>java.lang.VerifyError - Java 7 and Cobertura</strong></p>
  
  <p>I just added Cobertura to a Java 7 project and was disappointed that my unit tests started failing with:</p>
  
  <pre><code> java.lang.VerifyError: Expecting a stackmap frame at branch target blah... 
  </code></pre>
  
  <p>Looks like cobertura's byte code instrumentation is not compatible with Java 7.  Java 7 changed the class format with the addition of a stack map used for verification and cobertura hasn't caught up yet.... They seem to have updated the code and committed it to master now..</p>
  
  <p><a href="https://github.com/cobertura/cobertura/pull/6" rel="nofollow noreferrer">https://github.com/cobertura/cobertura/pull/6</a></p>
  
  <p>How to fix this error?</p>
  
  <p>Oracle does provide a way around the problem by using the -XX:UseSplitVerifier VM option. </p>
  
  <p><strong>Apache Buildr:</strong></p>
  
  <pre><code>ENV['JAVA_OPTS'] ||= "-XX:UseSplitVerifier"
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>ENV['JAVA_OPTS'] ||= "-Xverify:none"
  </code></pre>
  
  <p><strong>For Maven:</strong></p>
  
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
      &lt;version&gt;2.12&lt;/version&gt;
      &lt;configuration&gt;
          &lt;argLine&gt;-XX:-UseSplitVerifier&lt;/argLine&gt;
      &lt;/configuration&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p><strong>For Gradle:</strong></p>
  
  <pre><code>test
   {     
    jvmArgs
  "-XX:-UseSplitVerifier"
  </code></pre>
  
  <p>.....</p>