How to exclude an anonyomous class from jacoco?
Asked Answered
E

2

8

I am seeing class CacheConfig.new CacheLoader() {...} in my jacoco report. Is there a way to exclude it?

Excisable answered 1/7, 2016 at 16:2 Comment(0)
M
7

To exclude all anonymous classes in CacheConfig, it should work if you exclude CacheConfig$1*.class, CacheConfig$2*.class, CacheConfig$3*.class, CacheConfig$4*.class, CacheConfig$5*.class, CacheConfig$6*.class, CacheConfig$7*.class, CacheConfig$8*.class, CacheConfig$9*.class as anonymous classes are compiled to CacheConfig$1.class, CacheConfig$2.class and so on.

Excluding CacheConfig$*.class will not work, as it would exclude all inner classes, not only anonymous ones. If you want to exclude all inner classes, CacheConfig$*.class is ok to be used.

If you only want to exclude this one anonymous class, you can of course also exclude CacheConfig$1.class or what number it has. You can see this from the link that the label CacheConfig.new CacheLoader() {...} in the report is pointing at. But be aware, if you add another anonymous class before this one in CacheConfig, numbers will shift accordingly.

Minor answered 12/9, 2016 at 15:27 Comment(2)
Your answer helped, but I'm not sure what this part means, " You can see this from the link that the label ..." what link / label are you referring to?Adna
The question was about a JaCoCo report. That is what I'm referring to. :-)Minor
I
7

Adding **/*$*.* in excluded list ignores all anonymous binders and classes in your classes

Ibanez answered 14/2, 2020 at 13:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.