Keep getting "Can't add different class with same name:" error. Please advise

6,276 views
Skip to first unread message

Yaroslav Chinskiy

unread,
Sep 18, 2012, 5:17:05 PM9/18/12
to jac...@googlegroups.com
Hi,

I am switching my F/E application from emma to JaCoCo and need some guidance. With emma we produced instrumented build that would go to QA and later produce code coverage based on the manual/automated test.

I tried to run the same app with jacocoagent but now I can not generate a report.
i am using  report target that keeps failing with "Can't add different class with same name: com/comp/data/MyDataModel$1"

I tried to exclude it  <exclude name="**/*MyDataModel$1*"/> but no luck

For classfiles, I include all jar files from the class path.

What am I doing wrong?

Marc R. Hoffmann

unread,
Sep 19, 2012, 1:31:28 AM9/19/12
to jac...@googlegroups.com
Hi,

for coverage report generation all classes within a group must have
unique names. You get this error during report generation if JaCoCo is
supplied with multiple different class files with the same name. To fix
this remove those duplicate classes or create separate reports or report
groups for each version.

Best regards,
-marc
> --

Yaroslav Chinskiy

unread,
Sep 19, 2012, 9:01:54 AM9/19/12
to jac...@googlegroups.com
In this case, it fails with anonymous class which I have a lot (unfortunately)
I tried add these classes to exclude list but no luck...

Anything else i can try?

thank you.

Marc Hoffmann

unread,
Sep 19, 2012, 11:54:04 AM9/19/12
to jac...@googlegroups.com
JaCoCo works fine for anonymous classes. The problem is that the file

com/comp/data/MyDataModel$1.class

exists twice in your class path.

What you need to do is search your classpath, identify duplicates and
eliminate them.

Cheers,
-marc
> --

abl...@gmail.com

unread,
Dec 16, 2014, 2:49:53 PM12/16/14
to jac...@googlegroups.com
Do you have an example of how to accomplish this task in maven?

Marc Hoffmann

unread,
Dec 17, 2014, 10:34:34 AM12/17/14
to jac...@googlegroups.com
Hm, normaly in Maven all classes are picked from target/classes. I
wonder how it is possible to have a class with the same name twice in
this folder.

Where are your classes located you use for report generation?

Regards,
-marc

bhupendr...@gmail.com

unread,
Dec 21, 2015, 7:04:10 AM12/21/15
to JaCoCo and EclEmma Users
>>I
wonder how it is possible to have a class with the same name twice in
this folder.

Hi Marc,

Below are the class names in the same folder (not sure how they are created like this)

OpBalConfig.28d44622411812a1.class
OpBalConfig.9a774f30a5a69cdb.class

Reports plugin considers these are duplicate and gives the error, is there a workaround for this issue, I am having lots of them in the classes folder and had to go and manually remove one of them to resolve this.

Marc Hoffmann

unread,
Jan 7, 2016, 4:47:58 AM1/7/16
to jac...@googlegroups.com
Hi,

looks like this classes are created with the classdumpdir option of the
JaCoCo agent, right?

If you see a class twize (with different ids in the file name) this
means that the JVM actually loads two different versions of the class.

I would recommend to use your original classes instead.

Regards,
-marc

Bhupendra Mahajan

unread,
Jan 7, 2016, 7:04:20 AM1/7/16
to jac...@googlegroups.com
>>looks like this classes are created with the classdumpdir option of the JaCoCo agent, right?
Yes

>>I would recommend to use your original classes instead.
How am I suppose to do that ?


--
You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/Fe3E0oozCwQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/f864d59ae2d08122e0589a18bcc0d0b7%40mountainminds.com.

For more options, visit https://groups.google.com/d/optout.

Marc Hoffmann

unread,
Jan 7, 2016, 7:21:53 AM1/7/16
to jac...@googlegroups.com
>>> I would recommend to use your original classes instead.
> How am I suppose to do that ?


1) Don't use the classdumpdir option
2) When generating the coverage report point to the compiled class files
(or JARs) which you want to test.

Regards,
-marc
> You received this message because you are subscribed to the Google
> Groups "JaCoCo and EclEmma Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to jacoco+un...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jacoco/CABtqmtH_FD7rdXmBxXAhrnWObf063XtMGh0OTEXbHcXLb3rEjQ%40mail.gmail.com
> [1].
> For more options, visit https://groups.google.com/d/optout.
>
>
> Links:
> ------
> [1]
> https://groups.google.com/d/msgid/jacoco/CABtqmtH_FD7rdXmBxXAhrnWObf063XtMGh0OTEXbHcXLb3rEjQ%40mail.gmail.com?utm_medium=email&utm_source=footer

Bhupendra Mahajan

unread,
Jan 8, 2016, 7:16:06 AM1/8/16
to jac...@googlegroups.com
Hi Marc,

2) When generating the coverage report point to the compiled class files (or JARs) which you want to test
>>How to do this, don't see option on maven report plugin to point to JARS

Also can I use the same jacoco.exec (which was created with classdumpDIR option) for generating a report using above option

Thanks,
Bhupendra

Marc Hoffmann

unread,
Jan 8, 2016, 8:58:09 AM1/8/16
to jac...@googlegroups.com

Bhupendra Mahajan

unread,
Jan 14, 2016, 4:34:32 AM1/14/16
to jac...@googlegroups.com
Hi Mark,

How can I specify the jars to be used during report generation, can you help me with the syntax ?
I am using maven plugin

Thanks,
Bhupendra

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages