Additional top-level class in compilation unit: ByteVector.
A Bytecode object is an unbounded array
containing bytecode. For example,
ConstPool cp = ...; // constant pool table Bytecode b = new Bytecode(cp, 1, 0); b.addIconst(3); b.addReturn(CtClass.intType); CodeAttribute ca = b.toCodeAttribute();
This program produces a Code attribute including a bytecode sequence:
iconst_3 ireturn
ConstPool, CodeAttribute
| Modifier and Type | Field and Description |
|---|---|
| pack-priv ConstPool | |
| pack-priv int | |
| pack-priv int | |
| private int | |
| public static final CtClass | THIS
Represents the |
| pack-priv ExceptionTable |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | add(int code)
Overrides javassist. Appends an 8bit value to the end of the bytecode sequence. |
| public void | |
| public void | |
| public void | |
| public void | addAnewarray(CtClass
the elememnt type. clazz, int the array length. length)Appends ICONST and ANEWARRAY. |
| public void | |
| public void | |
| public void | |
| public void | addConstZero(CtClass
the type of the zero value (or null). type)Appends an instruction for pushing zero or null on the stack. |
| public void | |
| public void | |
| public void | |
| public void | addExceptionHandler(int start, int end, int handler, CtClass type)
Adds a new entry of |
| public void | addExceptionHandler(int start, int end, int handler, String
the fully-qualified name of a throwable class. type)Adds a new entry of |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | addGap(int
the gap length in byte. length)Overrides javassist. Appends the length-byte gap to the end of the bytecode sequence. |
| public void | addGetfield(CtClass
the class. c, String the field name. name, String the descriptor of the field type. type)Appends GETFIELD. |
| public void | addGetfield(String
the fully-qualified class name. c, String the field name. name, String the descriptor of the field type. type)Appends GETFIELD. |
| public void | addGetstatic(CtClass
the class c, String the field name name, String the descriptor of the field type. type)Appends GETSTATIC. |
| public void | addGetstatic(String
the fully-qualified class name c, String the field name name, String the descriptor of the field type. type)Appends GETSTATIC. |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | addInvokedynamic(int
an index into the bootstrap, String bootstrap_methods array
of the bootstrap method table.the method name. name, String the method descriptor. desc)Appends INVOKEDYNAMIC. |
| public void | addInvokeinterface(CtClass
the target class. clazz, String the method name name, CtClass the return type. returnType, CtClass[] the parameter types. paramTypes, int the count operand of the instruction. count)Appends INVOKEINTERFACE. |
| public void | addInvokeinterface(CtClass
the target class. clazz, String the method name name, String the descriptor of the method signature. desc, int the count operand of the instruction. count)Appends INVOKEINTERFACE. |
| public void | addInvokeinterface(String
the fully-qualified class name. classname, String the method name name, String the descriptor of the method signature. desc, int the count operand of the instruction. count)Appends INVOKEINTERFACE. |
| public void | addInvokeinterface(int
the index of clazz, String CONSTANT_Class_info
structure.the method name name, String the descriptor of the method signature. desc, int the count operand of the instruction. count)Appends INVOKEINTERFACE. |
| public void | addInvokespecial(CtClass
the target class. clazz, String the method name. name, CtClass the return type. returnType, CtClass[] the parameter types. paramTypes)Appends INVOKESPECIAL. |
| public void | addInvokespecial(CtClass
the target class. clazz, String the method name name, String the descriptor of the method signature. desc)Appends INVOKESPECIAL. |
| public void | addInvokespecial(String
the fully-qualified class name. clazz, String the method name name, String the descriptor of the method signature. desc)Appends INVOKESPECIAL. |
| public void | addInvokespecial(int
the index of clazz, String CONSTANT_Class_info
structure.the method name name, String the descriptor of the method signature. desc)Appends INVOKESPECIAL. |
| public void | addInvokespecial(boolean
true if the invoked method is a default method
declared in an interface. isInterface, int the index of clazz, String CONSTANT_Class_info
structure.the method name name, String the descriptor of the method signature. desc)Appends INVOKESPECIAL. |
| public void | addInvokespecial(int
the index of index, String CONSTANT_Methodref_info
or CONSTANT_InterfaceMethodref_infothe descriptor of the method signature. desc)Appends INVOKESPECIAL. |
| public void | addInvokestatic(CtClass
the target class. clazz, String the method name name, CtClass the return type. returnType, CtClass[] the parameter types. paramTypes)Appends INVOKESTATIC. |
| public void | addInvokestatic(CtClass
the target class. clazz, String the method name name, String the descriptor of the method signature. desc)Appends INVOKESTATIC. |
| public void | addInvokestatic(String
the fully-qualified class name.
It must not be an interface-type name. classname, String the method name name, String the descriptor of the method signature. desc)Appends INVOKESTATIC. |
| public void | addInvokestatic(int
the index of clazz, String CONSTANT_Class_info
structure. It must not be an interface type.the method name name, String the descriptor of the method signature. desc)Appends INVOKESTATIC. |
| private void | |
| public void | addInvokevirtual(CtClass
the target class. clazz, String the method name name, CtClass the return type. returnType, CtClass[] the parameter types. paramTypes)Appends INVOKEVIRTUAL. |
| public void | addInvokevirtual(CtClass
the target class. clazz, String the method name name, String the descriptor of the method signature. desc)Appends INVOKEVIRTUAL. |
| public void | addInvokevirtual(String
the fully-qualified class name. classname, String the method name name, String the descriptor of the method signature. desc)Appends INVOKEVIRTUAL. |
| public void | addInvokevirtual(int
the index of clazz, String CONSTANT_Class_info
structure.the method name name, String the descriptor of the method signature. desc)Appends INVOKEVIRTUAL. |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public int | |
| public int | addLoadParameters(CtClass[] params, int
the index of the first parameter. It is 0
if the method is static. Otherwise, it is 1. offset)Appends instructions for loading all the parameters onto the operand stack. |
| public void | |
| public int | Returns: the length ofdimensions.the array type. clazz, int[] the sizes of all dimensions. dimensions)Appends MULTINEWARRAY. |
| public int | Returns: the value ofdim.the array type. clazz, int the number of the dimensions. dim)Appends MULTINEWARRAY. |
| public int | Returns: the value ofdim.the type descriptor of the created array. desc, int dimensions. dim)Appends MULTINEWARRAY. |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | addPrintln(String
printed message. message)Appends instructions for executing
|
| public void | addPutfield(CtClass
the target class. c, String the field name. name, String the descriptor of the field type. desc)Appends PUTFIELD. |
| public void | addPutfield(String
the fully-qualified name of the target class. classname, String the field name. name, String the descriptor of the field type. desc)Appends PUTFIELD. |
| private void | |
| public void | addPutstatic(CtClass
the target class. c, String the field name. name, String the descriptor of the field type. desc)Appends PUTSTATIC. |
| public void | addPutstatic(String
the fully-qualified name of the target class. classname, String the field name. fieldName, String the descriptor of the field type. desc)Appends PUTSTATIC. |
| private void | |
| public void | |
| public void | |
| public int | |
| public Object | |
| public int | |
| public byte[] | |
| public ConstPool | |
| public ExceptionTable | |
| public int | |
| public int | |
| public int | |
| public void | |
| public void | |
| public int | |
| public int | read(int offset)
Overrides javassist. Reads a signed 8bit value at the offset from the beginning of the bytecode sequence. |
| public int | read16bit(int offset)
Reads a signed 16bit value at the offset from the beginning of the bytecode sequence. |
| public int | read32bit(int offset)
Reads a signed 32bit value at the offset from the beginning of the bytecode sequence. |
| public void | |
| public void | setMaxLocals(boolean
true if isStatic, CtClass[] params must be
interpreted as parameters to a static method.parameter types. params, int the number of local variables excluding
ones used to pass parameters. locals)Sets |
| public void | |
| public void | |
| public CodeAttribute | |
| public void | write(int offset, int value)
Overrides javassist. Writes an 8bit value at the offset from the beginning of the bytecode sequence. |
| public void | write16bit(int offset, int value)
Writes an 16bit value at the offset from the beginning of the bytecode sequence. |
| public void | write32bit(int offset, int value)
Writes an 32bit value at the offset from the beginning of the bytecode sequence. |