open class ClassWriter : ClassVisitor
A ClassVisitor that generates classes in bytecode form. More precisely this visitor generates a byte array conforming to the Java class file format. It can be used alone, to generate a Java class "from scratch", or with one or more ClassReader and adapter class visitor to generate a modified class from one or more existing Java classes.
Author
Eric Bruneton
ClassWriter(flags: Int)
Constructs a new ClassWriter object. ClassWriter(classReader: ClassReader, flags: Int)
Constructs a new ClassWriter object and enables optimizations for "mostly add" bytecode transformations. These optimizations are the following:
|
static val COMPUTE_FRAMES: Int
Flag to automatically compute the stack map frames of methods from scratch. If this flag is set, then the calls to the |
|
static val COMPUTE_MAXS: Int
Flag to automatically compute the maximum stack size and the maximum number of local variables of methods. If this flag is set, then the arguments of the |
open fun newClass(value: String): Int
Adds a class reference to the constant pool of the class being build. Does nothing if the constant pool already contains a similar item. This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters. |
|
open fun newConst(cst: Any): Int
Adds a number or string constant to the constant pool of the class being build. Does nothing if the constant pool already contains a similar item. This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters. |
|
open fun newField(owner: String, name: String, desc: String): Int
Adds a field reference to the constant pool of the class being build. Does nothing if the constant pool already contains a similar item. This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters. |
|
open fun newHandle(tag: Int, owner: String, name: String, desc: String): Int open fun newHandle(tag: Int, owner: String, name: String, desc: String, itf: Boolean): Int
Adds a handle to the constant pool of the class being build. Does nothing if the constant pool already contains a similar item. This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters. |
|
open fun newInvokeDynamic(name: String, desc: String, bsm: Handle, vararg bsmArgs: Any): Int
Adds an invokedynamic reference to the constant pool of the class being build. Does nothing if the constant pool already contains a similar item. This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters. |
|
open fun newMethod(owner: String, name: String, desc: String, itf: Boolean): Int
Adds a method reference to the constant pool of the class being build. Does nothing if the constant pool already contains a similar item. This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters. |
|
open fun newMethodType(methodDesc: String): Int
Adds a method type reference to the constant pool of the class being build. Does nothing if the constant pool already contains a similar item. This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters. |
|
open fun newModule(moduleName: String): Int
Adds a module reference to the constant pool of the class being build. Does nothing if the constant pool already contains a similar item. This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters. |
|
open fun newNameType(name: String, desc: String): Int
Adds a name and type to the constant pool of the class being build. Does nothing if the constant pool already contains a similar item. This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters. |
|
open fun newPackage(packageName: String): Int
Adds a package reference to the constant pool of the class being build. Does nothing if the constant pool already contains a similar item. This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters. |
|
open fun newUTF8(value: String): Int
Adds an UTF8 string to the constant pool of the class being build. Does nothing if the constant pool already contains a similar item. This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters. |
|
open fun toByteArray(): ByteArray
Returns the bytecode of the class that was build with this class writer. |
|
fun visit(version: Int, access: Int, name: String, signature: String, superName: String, interfaces: Array<String>): Unit |
|
fun visitAnnotation(desc: String, visible: Boolean): AnnotationVisitor |
|
fun visitAttribute(attr: Attribute): Unit |
|
fun visitEnd(): Unit |
|
fun visitField(access: Int, name: String, desc: String, signature: String, value: Any): FieldVisitor |
|
fun visitInnerClass(name: String, outerName: String, innerName: String, access: Int): Unit |
|
fun visitMethod(access: Int, name: String, desc: String, signature: String, exceptions: Array<String>): MethodVisitor |
|
fun visitModule(name: String, access: Int, version: String): ModuleVisitor |
|
fun visitOuterClass(owner: String, name: String, desc: String): Unit |
|
fun visitSource(file: String, debug: String): Unit |
|
fun visitTypeAnnotation(typeRef: Int, typePath: TypePath, desc: String, visible: Boolean): AnnotationVisitor |