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(KotlinInlineFilter.java:98)
at org.jacoco.core.internal.analysis.filter.KotlinInlineFilter.filter(KotlinInlineFilter.java:44)
at org.jacoco.core.internal.analysis.filter.Filters.filter(Filters.java:59)
at org.jacoco.core.internal.analysis.ClassAnalyzer.addMethodCoverage(ClassAnalyzer.java:119)
at org.jacoco.core.internal.analysis.ClassAnalyzer.access$100(ClassAnalyzer.java:33)
at org.jacoco.core.internal.analysis.ClassAnalyzer$1.accept(ClassAnalyzer.java:108)
at org.jacoco.core.internal.flow.ClassProbesAdapter$2.visitEnd(ClassProbesAdapter.java:91)
at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1492)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:718)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:401)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:116)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:132)
… 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!
6 thoughts on “Kotlin 1.5 and JaCoCo report exception”
This worked for me! thank you
You’re welcome!
Oh wow, this worked for me! Thank you buddy, off al the places I found something on your blog. Small World Online
You’re welcome 🙂
Hey this just saved me, thanks !
Hey Casey, you’re welcome!