diff options
author | Evgeny Mandrikov <138671+Godin@users.noreply.github.com> | 2019-01-08 19:56:54 +0100 |
---|---|---|
committer | Marc R. Hoffmann <hoffmann@mountainminds.com> | 2019-01-08 19:56:54 +0100 |
commit | 2458e8a4e467a5afc376b56a4e487ac54de0158e (patch) | |
tree | b0e6edc107b13e991ddb247bb46a5d8e111f1ed3 | |
parent | 34afa221fa3102427b04ca44ef827c4ddff2cd0f (diff) | |
download | platform_external_jacoco-2458e8a4e467a5afc376b56a4e487ac54de0158e.tar.gz platform_external_jacoco-2458e8a4e467a5afc376b56a4e487ac54de0158e.tar.bz2 platform_external_jacoco-2458e8a4e467a5afc376b56a4e487ac54de0158e.zip |
Extend filtering by annotation name to ones that simply contain Generated (#822)
3 files changed, 24 insertions, 4 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/AnnotationGeneratedFilterTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/AnnotationGeneratedFilterTest.java index 26070e49..caa894d1 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/AnnotationGeneratedFilterTest.java +++ b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/AnnotationGeneratedFilterTest.java @@ -67,6 +67,21 @@ public class AnnotationGeneratedFilterTest extends FilterTestBase { } @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, "hashCode", "()I", null, null); diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/AnnotationGeneratedFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/AnnotationGeneratedFilter.java index aae93f69..00492029 100644 --- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/AnnotationGeneratedFilter.java +++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/AnnotationGeneratedFilter.java @@ -20,7 +20,7 @@ import org.objectweb.asm.tree.MethodNode; * 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 { @@ -44,9 +44,10 @@ public final class AnnotationGeneratedFilter implements IFilter { } 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) { diff --git a/org.jacoco.doc/docroot/doc/changes.html b/org.jacoco.doc/docroot/doc/changes.html index 9b84b4f5..58d87c84 100644 --- a/org.jacoco.doc/docroot/doc/changes.html +++ b/org.jacoco.doc/docroot/doc/changes.html @@ -35,6 +35,10 @@ (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 |