Class AnnotationGenerator
- java.lang.Object
-
- 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
Constructors Constructor Description AnnotationGenerator(Singletons.Global g)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidannotate(Host h, Class<? extends Annotation> klass, List<AnnotationElem> elems)Applies a Java 1.5-style annotation to a given Host.voidannotate(Host h, Class<? extends Annotation> klass, AnnotationElem... elems)Applies a Java 1.5-style annotation to a given Host.voidannotate(Host h, String annotationName, int visibility, List<AnnotationElem> elems)Applies a Java 1.5-style annotation to a given Host.static AnnotationGeneratorv()Returns the unique instance of AnnotationGenerator.
-
-
-
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 typeSootClass,SootMethodorSootField.- Parameters:
h- a method, field, or classklass- the class of the annotation to apply tohelems- 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 typeSootClass,SootMethodorSootField.- Parameters:
h- a method, field, or classklass- the class of the annotation to apply tohelems- 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 typeSootClass,SootMethodorSootField.- Parameters:
h- a method, field, or classannotationName- the qualified name of the annotation classvisibility- any of the constants inAnnotationConstantselems- a (possibly empty) sequence of AnnotationElem objects corresponding to the elements that should be contained in this annotation
-
-