You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Generated annotation filter detection does not work when used with parameters #831
Class generated with @Generated annotation with parameters should also be ignored from code coverage report.
It is pretty easily reproducable when used by Google's Dagger annotation processor. They put something like below on top of generated classes
@Generated(
value = "dagger.internal.codegen.ComponentProcessor",
comments = "https://google.github.io/dagger"
)
public final class SomeGeneratedClass
Actual behaviour
Not just simple usage of @Generated annotation but all versions should be ignored.
Thanks for the detailed reply. I actually searched before posting but couldn't find it.
Here is 2 feedback:
the docs says Generated annotation is detected if it is visible or invisible. That is kind of confusing. I thought SOURCE retention would mean visible :)
The source files are available to Jacoco. Would it be possible to read sources to pick up the annotation?
the docs says Generated annotation is detected if it is visible or invisible. That is kind of confusing. I thought SOURCE retention would mean visible :)
Noted, will improve.
The source files are available to Jacoco. Would it be possible to read sources to pick up the annotation?
No - source code parsing is out of scope of project, not even recalling/considering that JaCoCo supports Kotlin and Groovy.
Activity
Godin commentedon Jan 17, 2019
Hi,
This has nothing to do with parameters, because as you can see Google's Dagger annotation processor uses either
javax.annotation.Generatedorjavax.annotation.processing.Generatedand unfortunately both have retention policy SOURCE (aka discarded by compiler). This has been already discussed many times ( #685 (comment) , #656 (comment) ) and even mentioned in changelog - JaCoCo performs analysis of bytecode and hence annotation must have retention policy RUNTIME (aka "runtime visible") or CLASS (aka "runtime invisible" yet retained in class files).Annotations with parameters having correct retention policy are processed correctly:
given
src/org/example/Example.javaexecution of
produces
as expected.
tasomaniac commentedon Jan 17, 2019
Thanks for the detailed reply. I actually searched before posting but couldn't find it.
Here is 2 feedback:
the docs says Generated annotation is detected if it is visible or invisible. That is kind of confusing. I thought SOURCE retention would mean visible :)
The source files are available to Jacoco. Would it be possible to read sources to pick up the annotation?
Godin commentedon Jan 17, 2019
Noted, will improve.
No - source code parsing is out of scope of project, not even recalling/considering that JaCoCo supports Kotlin and Groovy.
tasomaniac commentedon Jan 17, 2019
That makes sense. 😊 Thanks a lot.