Cobertura doesn't work with Java 7

Noam picture Noam · Jun 16, 2013 · Viewed 7.9k times · Source

I am using maven 3.0.4, JRE 1.7.0_09. When I use mvn clean install all my tests passes and everything looks good - here is my surefire plugin configuration:

<plugin>
    <version>2.12.4</version>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <!-- -XX:-UseSplitVerifier is for java 7 -->
        <argLine>-XX:-UseSplitVerifier</argLine>
    </configuration>
</plugin> 

Now, when I mvn cobertura:cobertura some of my tests have errors like this one:

Expecting a stackmap frame at branch target .... And some more errors that made me understand that it is not running using JRE7 (for example, Encountered " "|" "| "" at line...)

Here is my cobertura plugin configuration:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>cobertura-maven-plugin</artifactId>
    <version>2.5.1</version>
    <configuration>
       <formats>
          <format>html</format>
          <format>xml</format>
       </formats>
       </configuration>
  </plugin>

And the reporting is:

<reporting>
    <plugins>
        <plugin>
           <groupId>org.codehaus.mojo</groupId>
           <artifactId>cobertura-maven-plugin</artifactId>
           <version>2.5.1</version>
           <configuration>
               <formats>
                   <format>html</format>
                   <format>xml</format>
               </formats>
            </configuration>
        </plugin>
    </plugins>
</reporting>

I saw a lot of threads that talk about this issue and the solution is to add this line <argLine>-XX:-UseSplitVerifier</argLine> but it does not help.

What am I doing wrong here?

Answer

Spencer picture Spencer · Feb 27, 2014

We are using Cobertura plugin version 2.6 with Java 7 with no problems. This includes some files with Java 7 syntax (multi-catch, e.g.) which used to fail with the earlier plugin version. Nor do I need to use -XX:-UseSplitVerifier in the SureFire plugin any longer.

<properties>
    <coberturaMavenPlugin>2.6</coberturaMavenPlugin>
    <mavenSurefirePlugin>2.12</mavenSurefirePlugin>
</properties>
<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${mavenSurefirePlugin}</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
<reporting>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <version>${coberturaMavenPlugin}</version>
            <configuration>
                <aggregate>true</aggregate>
            </configuration>
        </plugin>
    </plugins>
</reporting>