Skip to content

Commit

Permalink
Extend filtering by annotation name to ones that simply contain Gener…
Browse files Browse the repository at this point in the history
…ated (#822)
  • Loading branch information
Godin authored and marchof committed Jan 8, 2019
1 parent 34afa22 commit 2458e8a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
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

0 comments on commit 2458e8a

Please sign in to comment.