Monosoul's Dev Blog A blog to write down dev-related stuff I face
Java Code Coverage

Kotlin 1.5 and JaCoCo report exception

Kotlin 1.5 came out not so long ago and recently we decided to give it a go in our team. Upgrade mostly went smoothly, but our JaCoCo report task in Gradle started to throw an exception.

Surprisingly the task just failed without any output whatsoever.

Luckily, there is a way to make Gradle a bit more verbose. So, to troubleshoot the issue I ran it with --info and --stacktrace arguments like this:

./gradlew jacocoTestReport --info --stacktrace
Code language: Bash (bash)

The root cause in the stacktrace I got as the output was this:

Caused by: java.lang.IllegalStateException: Unexpected SMAP line: *S KotlinDebug at org.jacoco.core.internal.analysis.filter.KotlinInlineFilter.getFirstGeneratedLineNumber( at org.jacoco.core.internal.analysis.filter.KotlinInlineFilter.filter( at org.jacoco.core.internal.analysis.filter.Filters.filter( at org.jacoco.core.internal.analysis.ClassAnalyzer.addMethodCoverage( at org.jacoco.core.internal.analysis.ClassAnalyzer.access$100( at org.jacoco.core.internal.analysis.ClassAnalyzer$1.accept( at org.jacoco.core.internal.flow.ClassProbesAdapter$2.visitEnd( at org.objectweb.asm.ClassReader.readMethod( at org.objectweb.asm.ClassReader.accept( at org.objectweb.asm.ClassReader.accept( at org.jacoco.core.analysis.Analyzer.analyzeClass( at org.jacoco.core.analysis.Analyzer.analyzeClass( 161 more
Code language: Properties (properties)

I did a quick research and it turns out that by that time it was a known issue. And the solution to it is rather simple: just update your JaCoCo agent to version 0.8.7 or later.

Here’s how to do that with Gradle:

jacoco { toolVersion = "0.8.7" }
Code language: Gradle (gradle)

And with Maven you just have to change the plugin version like this:

<plugin>   <groupId>org.jacoco</groupId>   <artifactId>jacoco-maven-plugin</artifactId>   <version>0.8.7</version> </plugin>
Code language: HTML, XML (xml)

Luckily this was a rather easy change. Happy coding!

Like it? Share it!

Leave a comment

Your email address will not be published.

6 thoughts on “Kotlin 1.5 and JaCoCo report exception”