Java.lang.VerifyError when using emma / Cobertura on JDK 1.7

I am facing the same problem that was mentioned in the link below when trying to create an assembly using Apache Buildr.

Testng, Emma, ​​Cobertura, coverage, and JDK 7 lead to ClassFormatError and VerifyError

I tried using the -XX: -UseSplitVerifier parameter (as shown below) when testing artifacts, but this did not solve my problem.

test.using( :java_args => ['-ea','-XX:-UseSplitVerifier']) 

Error:

 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 

Update is the solution / reason for the root.

Code compiled using Java 1.7 requires stack frame card instructions. If you want to modify Java 1.7 class files, you need to use ClassWriter.COMPUTE_FRAMES or MethodVisit.visitFrame ().

java.lang.VerifyError - Java 7 and Cobertura

I just added Cobertura to my Java 7 project and was disappointed that my unit tests started crashing:

  java.lang.VerifyError: Expecting a stackmap frame at branch target blah... 

It seems that the coberture drum code is not compatible with Java 7. Java 7 changed the class format with the addition of the stack map used for verification, and cobertura has not yet caught up ... They seem to have updated the code and instructed him to learn it now.

https://github.com/cobertura/cobertura/pull/6

How to fix this error?

Oracle provides a way to fix the problem with the -XX: UseSplitVerifier VM option.

Apache Buildr:

 ENV['JAVA_OPTS'] ||= "-XX:UseSplitVerifier" 

OR

 ENV['JAVA_OPTS'] ||= "-Xverify:none" 

For Maven:

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.12</version> <configuration> <argLine>-XX:-UseSplitVerifier</argLine> </configuration> </plugin> 

For Gradle:

 test { jvmArgs "-XX:-UseSplitVerifier" 

.....

+4
source share
1 answer

Buildr launches the built-in JVM (usually using Ruby-Java Bridge (RJB) when not using JRuby) and selects a test from this JVM, so I suggest passing the test parameters after disconnection through JAVA_OPTIONS before running buildr

 $ export JAVA_OPTIONS="-Xverify:none" # or other verification-disabling options 
+3
source

Source: https://habr.com/ru/post/1484293/


All Articles