Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend filtering by annotation name to ones that simply contain Generated #822

Merged
merged 3 commits into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ public void should_filter_classes_annotated_with_runtime_visible_org_immutables_
assertMethodIgnored(m);
}

@Test
public void should_filter_classes_annotated_with_runtime_visible_org_apache_avro_specific_AvroGenerated() {
final MethodNode m = new MethodNode(InstrSupport.ASM_API_VERSION, 0,
"readExternal", "()V", null, null);

m.visitInsn(Opcodes.NOP);

context.classAnnotations
.add("Lorg/apache/avro/specific/AvroGenerated;");

filter.filter(m, context, output);

assertMethodIgnored(m);
}

@Test
public void should_filter_when_annotation_is_inner() {
final MethodNode m = new MethodNode(InstrSupport.ASM_API_VERSION, 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* Filters classes and methods annotated with
* {@link java.lang.annotation.RetentionPolicy#RUNTIME runtime visible} and
* {@link java.lang.annotation.RetentionPolicy#CLASS invisible} annotation whose
* simple name is <code>Generated</code>.
* simple name contains <code>Generated</code>.
*/
public final class AnnotationGeneratedFilter implements IFilter {

Expand All @@ -44,9 +44,10 @@ public void filter(final MethodNode methodNode,
}

private static boolean matches(final String annotation) {
return "Generated;".equals(
annotation.substring(Math.max(annotation.lastIndexOf('/'),
annotation.lastIndexOf('$')) + 1));
final String name = annotation
.substring(Math.max(annotation.lastIndexOf('/'),
annotation.lastIndexOf('$')) + 1);
return name.contains("Generated");
}

private static boolean presentIn(final List<AnnotationNode> annotations) {
Expand Down
4 changes: 4 additions & 0 deletions org.jacoco.doc/docroot/doc/changes.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ <h3>New Features</h3>
(GitHub <a href="https://github.com/jacoco/jacoco/issues/802">#802</a>,
<a href="https://github.com/jacoco/jacoco/issues/803">#803</a>,
<a href="https://github.com/jacoco/jacoco/issues/809">#809</a>).</li>
<li>Classes and methods annotated with runtime visible and invisible annotation
whose simple name contains "Generated" (previously equality was required)
are filtered out during generation of report
(GitHub <a href="https://github.com/jacoco/jacoco/issues/822">#822</a>).</li>
<li>HTML report shows message when source file can't be found
(GitHub <a href="https://github.com/jacoco/jacoco/issues/801">#801</a>).</li>
<li>HTML report shows message when class has no debug information
Expand Down