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

- 2,972
- 3
- 23
- 34
2 Answers
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.

- 35,631
- 4
- 76
- 102
-
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? – Max Aug 19 '20 at 20:26
-
The question was about a JaCoCo report. That is what I'm referring to. :-) – Vampire Apr 05 '23 at 15:04
Adding **/*$*.*
in excluded list ignores all anonymous binders and classes in your classes

- 2,070
- 2
- 22
- 38