Skip to content

filtering GROOVY.ANNOTATIONS

Evgeny Mandrikov edited this page Jan 9, 2017 · 2 revisions

This page discusses a not yet available feature!

Description

Groovy has a feature named AST Transformations (see http://groovy.codehaus.org/Compile-time+Metaprogramming+-+AST+Transformations) that allow developers to instruct the compiler to generate new byte code according to certain conventions. Sometimes these new additions can be skipped from coverage as they represent bridge methods or some other plumbing code.

Filtering

Methods defined by a configuration mechanism matching specific annotations are excluded. May require the usage of regular expressions to match method signatures/names.

Source Example

@groovy.transform.Canonical
class Bean {
   String name
}

Bytecode Pattern

The class Bean contains the following methods and fields

Compiled from "Bean.groovy"
public class Bean implements groovy.lang.GroovyObject {
  public Bean(java.lang.String);             // added by @Canonical
  public Bean();
  public java.lang.String getName();
  public void setName(java.lang.String);
  public int hashCode();                     // added by @Canonical
  public boolean canEqual(java.lang.Object); // added by @Canonical
  public boolean equals(java.lang.Object);   // added by @Canonical
  public java.lang.String toString();        // added by @Canonical
  public groovy.lang.MetaClass getMetaClass();
  public void setMetaClass(groovy.lang.MetaClass);
  public java.lang.Object invokeMethod(java.lang.String, java.lang.Object);
  public java.lang.Object getProperty(java.lang.String);
  public void setProperty(java.lang.String, java.lang.Object);
  public static transient boolean __$stMC;
  public static long __timeStamp;
  public static long __timeStamp__239_neverHappen1416432549812;
  public java.lang.Object this$dist$invoke$1(java.lang.String, java.lang.Object);
  public void this$dist$set$1(java.lang.String, java.lang.Object);
  public java.lang.Object this$dist$get$1(java.lang.String);
  protected groovy.lang.MetaClass $getStaticMetaClass();
  public static void __$swapInit();
  static {};
  public void super$1$notify();
  public int super$1$hashCode();
  public java.lang.String super$1$toString();
  public java.lang.Object super$1$clone();
  public void super$1$wait(long, int);
  public void super$1$wait(long);
  public void super$1$wait();
  public void super$1$notifyAll();
  public boolean super$1$equals(java.lang.Object);
  public void super$1$finalize();
  public java.lang.Class super$1$getClass();
  static java.lang.Class class$(java.lang.String);
}