public class CodeAttribute extends AttributeInfo implements Opcode
Code_attribute.
 To browse the code field of
 a Code_attribute structure,
 use CodeIterator.
CodeIterator, 
iterator()| Modifier and Type | Class and Description | 
|---|---|
| static class  | CodeAttribute.RuntimeCopyExceptionAn exception that may be thrown by  copy()inCodeAttribute. | 
| Modifier and Type | Field and Description | 
|---|---|
| static String | tagThe name of this attribute  "Code". | 
constPoolAALOAD, AASTORE, ACONST_NULL, ALOAD, ALOAD_0, ALOAD_1, ALOAD_2, ALOAD_3, ANEWARRAY, ARETURN, ARRAYLENGTH, ASTORE, ASTORE_0, ASTORE_1, ASTORE_2, ASTORE_3, ATHROW, BALOAD, BASTORE, BIPUSH, CALOAD, CASTORE, CHECKCAST, D2F, D2I, D2L, DADD, DALOAD, DASTORE, DCMPG, DCMPL, DCONST_0, DCONST_1, DDIV, DLOAD, DLOAD_0, DLOAD_1, DLOAD_2, DLOAD_3, DMUL, DNEG, DREM, DRETURN, DSTORE, DSTORE_0, DSTORE_1, DSTORE_2, DSTORE_3, DSUB, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, F2D, F2I, F2L, FADD, FALOAD, FASTORE, FCMPG, FCMPL, FCONST_0, FCONST_1, FCONST_2, FDIV, FLOAD, FLOAD_0, FLOAD_1, FLOAD_2, FLOAD_3, FMUL, FNEG, FREM, FRETURN, FSTORE, FSTORE_0, FSTORE_1, FSTORE_2, FSTORE_3, FSUB, GETFIELD, GETSTATIC, GOTO, GOTO_W, I2B, I2C, I2D, I2F, I2L, I2S, IADD, IALOAD, IAND, IASTORE, ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, ICONST_M1, IDIV, IF_ACMPEQ, IF_ACMPNE, IF_ICMPEQ, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ICMPLT, IF_ICMPNE, IFEQ, IFGE, IFGT, IFLE, IFLT, IFNE, IFNONNULL, IFNULL, IINC, ILOAD, ILOAD_0, ILOAD_1, ILOAD_2, ILOAD_3, IMUL, INEG, INSTANCEOF, INVOKEDYNAMIC, INVOKEINTERFACE, INVOKESPECIAL, INVOKESTATIC, INVOKEVIRTUAL, IOR, IREM, IRETURN, ISHL, ISHR, ISTORE, ISTORE_0, ISTORE_1, ISTORE_2, ISTORE_3, ISUB, IUSHR, IXOR, JSR, JSR_W, L2D, L2F, L2I, LADD, LALOAD, LAND, LASTORE, LCMP, LCONST_0, LCONST_1, LDC, LDC_W, LDC2_W, LDIV, LLOAD, LLOAD_0, LLOAD_1, LLOAD_2, LLOAD_3, LMUL, LNEG, LOOKUPSWITCH, LOR, LREM, LRETURN, LSHL, LSHR, LSTORE, LSTORE_0, LSTORE_1, LSTORE_2, LSTORE_3, LSUB, LUSHR, LXOR, MONITORENTER, MONITOREXIT, MULTIANEWARRAY, NEW, NEWARRAY, NOP, POP, POP2, PUTFIELD, PUTSTATIC, RET, RETURN, SALOAD, SASTORE, SIPUSH, STACK_GROW, SWAP, T_BOOLEAN, T_BYTE, T_CHAR, T_DOUBLE, T_FLOAT, T_INT, T_LONG, T_SHORT, TABLESWITCH, WIDE| Constructor and Description | 
|---|
| CodeAttribute(ConstPool cp,
             int stack,
             int locals,
             byte[] code,
             ExceptionTable etable)Constructs a  Code_attribute. | 
| Modifier and Type | Method and Description | 
|---|---|
| int | computeMaxStack()Computes the maximum stack size and sets  max_stackto the computed size. | 
| AttributeInfo | copy(ConstPool newCp,
    Map classnames)Makes a copy. | 
| byte[] | get()This method is not available. | 
| AttributeInfo | getAttribute(String name)Returns the attribute with the specified name. | 
| List | getAttributes()Returns  attributes[]. | 
| byte[] | getCode()Returns  code[]. | 
| int | getCodeLength()Returns  code_length. | 
| String | getDeclaringClass()Returns the name of the class declaring the method including
 this code attribute. | 
| ExceptionTable | getExceptionTable()Returns  exception_table[]. | 
| int | getMaxLocals()Returns  max_locals. | 
| int | getMaxStack()Returns  max_stack. | 
| void | insertLocalVar(int where,
              int size)Changes the index numbers of the local variables
 to append a new parameter. | 
| CodeIterator | iterator()Makes a new iterator for reading this code attribute. | 
| int | length()Returns the length of this  attribute_infostructure. | 
| void | set(byte[] newinfo)This method is not available. | 
| void | setAttribute(StackMap sm)Adds a stack map table for J2ME (CLDC). | 
| void | setAttribute(StackMapTable smt)Adds a stack map table. | 
| void | setMaxLocals(int value)Sets  max_locals. | 
| void | setMaxStack(int value)Sets  max_stack. | 
getConstPool, getNamepublic static final String tag
"Code".public CodeAttribute(ConstPool cp, int stack, int locals, byte[] code, ExceptionTable etable)
Code_attribute.cp - constant pool tablestack - max_stacklocals - max_localscode - code[]etable - exception_table[]public AttributeInfo copy(ConstPool newCp, Map classnames) throws CodeAttribute.RuntimeCopyException
Map object.copy in class AttributeInfonewCp - the constant pool table used by the new copy.classnames - pairs of replaced and substituted
                          class names.CodeAttribute object.CodeAttribute.RuntimeCopyException - if a BadBytecode
                          exception is thrown, it is
                          converted into
                          RuntimeCopyException.public int length()
attribute_info
 structure.
 The returned value is attribute_length + 6.length in class AttributeInfopublic byte[] get()
get in class AttributeInfoUnsupportedOperationException - always thrown.public void set(byte[] newinfo)
set in class AttributeInfoUnsupportedOperationException - always thrown.public String getDeclaringClass()
public int getMaxStack()
max_stack.public void setMaxStack(int value)
max_stack.public int computeMaxStack()
                    throws BadBytecode
max_stack
 to the computed size.max_stackBadBytecode - if this method fails in computing.public int getMaxLocals()
max_locals.public void setMaxLocals(int value)
max_locals.public int getCodeLength()
code_length.public byte[] getCode()
code[].public CodeIterator iterator()
public ExceptionTable getExceptionTable()
exception_table[].public List getAttributes()
attributes[].
 It returns a list of AttributeInfo.
 A new element can be added to the returned list
 and an existing element can be removed from the list.AttributeInfopublic AttributeInfo getAttribute(String name)
name - attribute nameAttributeInfo object or null.public void setAttribute(StackMapTable smt)
smt - the stack map table added to this code attribute.
                  If it is null, a new stack map is not added.
                  Only the old stack map is removed.public void setAttribute(StackMap sm)
sm - the stack map table added to this code attribute.
                  If it is null, a new stack map is not added.
                  Only the old stack map is removed.public void insertLocalVar(int where,
                           int size)
                    throws BadBytecode
LocalVariableAttribute,
 LocalVariableTypeAttribute,
 StackMapTable, or StackMap.
 These attributes must be explicitly updated.where - the index of the new parameter.size - the type size of the new parameter (1 or 2).BadBytecodeLocalVariableAttribute.shiftIndex(int, int), 
LocalVariableAttribute.shiftIndex(int, int), 
StackMapTable.insertLocal(int, int, int), 
StackMap.insertLocal(int, int, int)Copyright © 2016 Shigeru Chiba, www.javassist.org. All Rights Reserved.