com.sun classes are included in coverage report

43 views
Skip to first unread message

krisha...@gmail.com

unread,
Apr 29, 2015, 1:25:20 PM4/29/15
to jac...@googlegroups.com
Hi All,

I'm trying to generate coverage by excluding com.sun.* classes. Only one jar containing com.sum.* packages is there in the server. I've excluded that jar from coverage report by filter out all jar files and passing the jar names to analyzeAll method though a loop when generating the report.

Note that I'm using modified version of ReportGenerator at [1]

analyzer.analyzeAll(file);

Also excluded that particular patten from -javaagent option.

-javaagent:/Users/krishantha/git/wso2/product-as/modules/integration/tests-integration/tests/target/jacoco/agent/jacocoagent.jar=destfile=/Users/krishantha/git/wso2/product-as/modules/integration/tests-integration/tests/target/jacoco.exec,append=true,includes=org.test.myapp*:org.addressing*:org.test.application.deployer*:,excludes=com.sun**:org.eclipse.*:*.equinox.*,classdumpdir=/Users/krishantha/Desktop/test \

Also I have dump all classes to a directory and no com.sun classes are there.

However still my report contain com.sun packages.

Any help to exclude the classes properly will be appreciated.

Sample report is given below
=============================

Element Missed Instructions Cov. Missed Branches Cov. Missed Cxty Missed Lines Missed Methods Missed Classes
\
com.sun.activation.registries 3,976 0% 516 0% 368 368 492 492 104 104 14 14
com.sun.activation.viewers 1,054 0% 0% 62 62 149 149 44 44 8 8
com.sun.codemodel 10,994 0% 1,042 0% 1,246 1,246 2,325 2,325 724 724 80 80
com.sun.codemodel.fmt 0% 0% 46 46 105 105 36 36 9 9
com.sun.codemodel.util 2,086 0% 120 0% 107 107 222 222 47 47 9 9

[1]http://www.eclemma.org/jacoco/trunk/doc/examples/java/ReportGenerator.java

Thanks,
Krishantha.

Marc R. Hoffmann

unread,
Apr 29, 2015, 2:19:01 PM4/29/15
to jac...@googlegroups.com
Hi,

if you exclude classes at the agent configuration this simply means that
the agent does not collect execution data for those classes.

If you want exclude classes from the report you have to filter those
classes at report generation time. If you're working with the analyzer
you need to provide only the class files you want to see in the report.

Regards,
-marc

Krishantha Samaraweera

unread,
Apr 29, 2015, 2:59:13 PM4/29/15
to jac...@googlegroups.com
Hi Marc,

Thanks for your prompt reply!

I found the problem. There was jar file which contain another jar with com.sum classes. My simple grep command on all jars didn't list that jar. Excluding the parent jar from coverage did the trick.

I've another small clarification. In my project all packages are bundle as jars. So for ReportGenerator, i've set "classesDirectory" to the location of all jar files. In that case, how can i exclude a particular class in a jar file. At the moment only jar files can be passed to analyzer.analyzeAll(file) method after filtering according to the exclusion defined. How can I exclude specific class files (not the jar file) in this case.

Thanks,
Krishantha.


--
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/4kNrcAhiqy4/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/55412095.5080508%40mountainminds.com.

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

Marc R. Hoffmann

unread,
Apr 29, 2015, 3:45:27 PM4/29/15
to jac...@googlegroups.com
The Analyzer does not offer a filtering. You would need to traverse the JAR file contents yourself and do the filtering.

Another (nicer) option would be to implement a filtering ICoverageVisitor which you plug between the Analzer and the CoverageBuilder.

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/CAAws007wsicTWQhuMddjwbGuMt%3DjT43PBJe3JVPNOyb9K_JHQA%40mail.gmail.com.

Krishantha Samaraweera

unread,
Apr 29, 2015, 4:16:11 PM4/29/15
to jac...@googlegroups.com
Thanks for the tip will try this out.

Thanks,
Krishantha.

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