Issue
I am getting an error while running my blackbox test code. I am using latest 0.8.2 jacoco jars but it throws below errors:
BUILD FAILED
C:\project\build-continous-integration.xml:71: The following error occurred while executing this line:
C:\project\build-continous-integration.xml:94: The following error occurred while executing this line:
C:\project\build-continous-integration.xml:152: Error while creating report
at org.jacoco.ant.ReportTask.execute(ReportTask.java:501)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
at org.apache.tools.ant.Task.perform(Task.java:350)
at org.apache.tools.ant.Target.execute(Target.java:449)
at org.apache.tools.ant.Target.performTasks(Target.java:470)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:36)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:437)
at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
at org.apache.tools.ant.Task.perform(Task.java:350)
at org.apache.tools.ant.Target.execute(Target.java:449)
at org.apache.tools.ant.Target.performTasks(Target.java:470)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:36)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:437)
at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
at org.apache.tools.ant.Task.perform(Task.java:350)
at org.apache.tools.ant.Target.execute(Target.java:449)
at org.apache.tools.ant.Target.performTasks(Target.java:470)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
at org.apache.tools.ant.Project.executeTarget(Project.java:1361)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.Main.runBuild(Main.java:834)
at org.apache.tools.ant.Main.startAnt(Main.java:223)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)
Caused by: java.io.IOException: Error while analyzing
project\bc\infra\commands\AbstractCommand.class.
at org.jacoco.core.analysis.Analyzer.analyzerError(Analyzer.java:170)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:142)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:165)
at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:201)
at org.jacoco.ant.ReportTask.createBundle(ReportTask.java:570)
at org.jacoco.ant.ReportTask.createReport(ReportTask.java:542)
at org.jacoco.ant.ReportTask.execute(ReportTask.java:495)
... 42 more
Caused by: java.lang.IllegalArgumentException
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:118)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:140)
... 47 more
I've checked plenty of topics but most of the issues are about instrumented class but here I do not see this error. Do someone has any idea how to fix it? If you need more information please let me know.
Thank you in advance.
Solution
Caused by: java.lang.IllegalArgumentException
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
The only known to me case of Unknown Source
in stack traces from ASM library - is usage of its JARs that do not contain debug information and which were removed in ASM version 6.0. So you're probably using ASM version < 6.0.
However according to presence of module names in your stack trace
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
you're using Java >= 9.
ASM versions < 6.0 can not handle Java >= 9 classes and in this case throw exactly IllegalArgumentException
at org.objectweb.asm.ClassReader.<init>
.
Furthermore JaCoCo 0.8.2 requires usage of ASM 6.2.1 and depends exactly on this version.
at org.jacoco.ant.ReportTask.execute(ReportTask.java:501)
for Ant you must use lib/jacocoant.jar
and not lib/org.jacoco.ant-0.8.2.201808211720.jar
from JaCoCo distribution, because first one contains all required dependencies, while last one does not. According to https://www.jacoco.org/jacoco/trunk/doc/repo.html it corresponds to artifact from Maven central repository whose groupId
is org.jacoco
, artifactId
is org.jacoco.ant
and most importantly classifier
is nodeps
.
Answered By - Godin
Answer Checked By - Cary Denson (JavaFixing Admin)