Class ClassAnnotationSceneWriter
java.lang.Object
org.objectweb.asm.ClassVisitor
org.checkerframework.afu.scenelib.io.classfile.CodeOffsetAdapter
org.checkerframework.afu.scenelib.io.classfile.ClassAnnotationSceneWriter
A ClassAnnotationSceneWriter is a
ClassVisitor that can be used to
write a class file that is the combination of an existing class file and annotations in an AScene. The "write" in ClassAnnotationSceneWriter refers to a class file being rewritten
with information from a scene. Also see ClassAnnotationSceneReader.
The proper usage of this class is to construct a ClassAnnotationSceneWriter with a
AScene that already contains all its annotations, pass this as a ClassVisitor to ClassReader.accept(org.objectweb.asm.ClassVisitor, int), and then obtain
the resulting class, ready to be written to a file, with toByteArray().
All other methods are intended to be called only by ClassReader.accept(org.objectweb.asm.ClassVisitor, int), and should not be called anywhere else, due to the order
in which ClassVisitor methods should be called.
Throughout this class, "scene" refers to the AScene this class is merging into a class
file.
-
Field Summary
Fields inherited from class org.objectweb.asm.ClassVisitor
api, cv -
Constructor Summary
ConstructorsConstructorDescriptionClassAnnotationSceneWriter(int api, org.objectweb.asm.ClassReader classReader, AScene scene, boolean overwrite) Constructs a newClassAnnotationSceneWriterthat will insert all the annotations insceneinto the class that it visits. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]Returns a byte array that represents the resulting class file from merging all the annotations in the scene into the class file this has visited.voidvisit(int version, int access, String name, String signature, String superName, String[] interfaces) org.objectweb.asm.AnnotationVisitorvisitAnnotation(String descriptor, boolean visible) voidvisitEnd()org.objectweb.asm.FieldVisitorvisitField(int access, String name, String descriptor, String signature, Object value) voidvisitInnerClass(String name, String outerName, String innerName, int access) org.objectweb.asm.MethodVisitorvisitMethod(int access, String name, String descriptor, String signature, String[] exceptions) org.objectweb.asm.AnnotationVisitorvisitTypeAnnotation(int typeRef, org.objectweb.asm.TypePath typePath, String descriptor, boolean visible) Methods inherited from class org.checkerframework.afu.scenelib.io.classfile.CodeOffsetAdapter
getBytecodeOffset, getMethodCodeOffset, getPreviousCodeOffsetMethods inherited from class org.objectweb.asm.ClassVisitor
getDelegate, visitAttribute, visitModule, visitNestHost, visitNestMember, visitOuterClass, visitPermittedSubclass, visitRecordComponent, visitSource
-
Constructor Details
-
ClassAnnotationSceneWriter
public ClassAnnotationSceneWriter(int api, org.objectweb.asm.ClassReader classReader, AScene scene, boolean overwrite) Constructs a newClassAnnotationSceneWriterthat will insert all the annotations insceneinto the class that it visits.scenemust be anASceneover the class that this will visit.- Parameters:
api- the ASM API version to useclassReader- the reader for the class being modifiedscene- the annotation scene containing annotations to be inserted into the class this visitsoverwrite- true if to overwrite existing annotations on the same element
-
-
Method Details
-
toByteArray
public byte[] toByteArray()Returns a byte array that represents the resulting class file from merging all the annotations in the scene into the class file this has visited. This method may only be called once this has already completely visited a class, which is done by callingClassReader.accept(org.objectweb.asm.ClassVisitor, int).- Returns:
- a byte array of the merged class file
-
visit
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) - Overrides:
visitin classorg.objectweb.asm.ClassVisitor
-
visitInnerClass
- Overrides:
visitInnerClassin classorg.objectweb.asm.ClassVisitor
-
visitField
public org.objectweb.asm.FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value) - Overrides:
visitFieldin classorg.objectweb.asm.ClassVisitor
-
visitMethod
public org.objectweb.asm.MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) - Overrides:
visitMethodin classCodeOffsetAdapter
-
visitEnd
public void visitEnd()- Overrides:
visitEndin classorg.objectweb.asm.ClassVisitor
-
visitAnnotation
- Overrides:
visitAnnotationin classorg.objectweb.asm.ClassVisitor
-
visitTypeAnnotation
public org.objectweb.asm.AnnotationVisitor visitTypeAnnotation(int typeRef, org.objectweb.asm.TypePath typePath, String descriptor, boolean visible) - Overrides:
visitTypeAnnotationin classorg.objectweb.asm.ClassVisitor
-