soot.jimple.toolkits.annotation.j5anno
Class AnnotationGenerator

java.lang.Object
  extended by soot.jimple.toolkits.annotation.j5anno.AnnotationGenerator

public class AnnotationGenerator
extends Object

AnnotationGenerator is a singleton class that wraps up Soot's support for Java 5 annotations in a more convenient interface. It supplies three annotate() methods that take an Host, an annotation class, and zero or more AnnotationElem objects; these methods find the appropriate Tag on the given Host for the appropriate annotation visibility and add an annotation of the given type to it. Note that the first two methods expect an annotation class, which the last method expects a class name. If the class is passed, this class has to be on Soot's classpath at compile time. It is not enough to add the class to the soo-classpath!

One caveat: annotate() does not add annotation classes to the Scene, so you will have to manually add any annotation classes that were not already in the Scene to the output directory or jar.

Author:
Will Benton, Eric Bodden

Constructor Summary
AnnotationGenerator(Singletons.Global g)
           
 
Method Summary
 void annotate(Host h, Class<? extends Annotation> klass, AnnotationElem... elems)
          Applies a Java 1.5-style annotation to a given Host.
 void annotate(Host h, Class<? extends Annotation> klass, List<AnnotationElem> elems)
          Applies a Java 1.5-style annotation to a given Host.
 void annotate(Host h, String annotationName, int visibility, List<AnnotationElem> elems)
          Applies a Java 1.5-style annotation to a given Host.
static AnnotationGenerator v()
          Returns the unique instance of AnnotationGenerator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationGenerator

public AnnotationGenerator(Singletons.Global g)
Method Detail

v

public static AnnotationGenerator v()
Returns the unique instance of AnnotationGenerator.


annotate

public void annotate(Host h,
                     Class<? extends Annotation> klass,
                     AnnotationElem... elems)
Applies a Java 1.5-style annotation to a given Host. The Host must be of type SootClass, SootMethod or SootField.

Parameters:
h - a method, field, or class
klass - the class of the annotation to apply to h
elems - a (possibly empty) sequence of AnnotationElem objects corresponding to the elements that should be contained in this annotation

annotate

public void annotate(Host h,
                     Class<? extends Annotation> klass,
                     List<AnnotationElem> elems)
Applies a Java 1.5-style annotation to a given Host. The Host must be of type SootClass, SootMethod or SootField.

Parameters:
h - a method, field, or class
klass - the class of the annotation to apply to h
elems - a (possibly empty) sequence of AnnotationElem objects corresponding to the elements that should be contained in this annotation

annotate

public void annotate(Host h,
                     String annotationName,
                     int visibility,
                     List<AnnotationElem> elems)
Applies a Java 1.5-style annotation to a given Host. The Host must be of type SootClass, SootMethod or SootField.

Parameters:
h - a method, field, or class
annotationName - the qualified name of the annotation class
visibility - any of the constants in AnnotationConstants
elems - a (possibly empty) sequence of AnnotationElem objects corresponding to the elements that should be contained in this annotation