com.go.trove.classfile
Class CodeAttr

java.lang.Object
  |
  +--com.go.trove.classfile.Attribute
        |
        +--com.go.trove.classfile.CodeAttr

public class CodeAttr
extends Attribute

This class corresponds to the Code_attribute structure as defined in section 4.7.4 of The Java Virtual Machine Specification. To make it easier to create bytecode for the CodeAttr, use the CodeBuilder.

Version:
34 , 01/01/02
Author:
Brian S O'Neill
See Also:
Opcode, CodeBuilder

Fields inherited from class com.go.trove.classfile.Attribute
mCp
 
Method Summary
 void addAttribute(Attribute attr)
           
 Attribute[] getAttributes()
          Some attributes have sub-attributes.
 CodeBuffer getCodeBuffer()
          Returns null if no CodeBuffer is defined for this CodeAttr.
 int getLength()
          Returns the length (in bytes) of this object in the class file.
 int getLineNumber(Location start)
          Returns the line number in the source code from the given bytecode address (start_pc).
 void localVariableUse(LocalVariable localVar)
          Indicate a local variable's use information be recorded in the ClassFile as a debugging aid.
 void mapLineNumber(Location start, int line_number)
          Map a bytecode address (start_pc) to a line number in the source code as a debugging aid.
 void setCodeBuffer(CodeBuffer code)
           
 void writeDataTo(java.io.DataOutput dout)
          Write just the attribute specific data.
 
Methods inherited from class com.go.trove.classfile.Attribute
getConstantPool, getName, getNameConstant, readFrom, writeTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getCodeBuffer

public CodeBuffer getCodeBuffer()
Returns null if no CodeBuffer is defined for this CodeAttr.

setCodeBuffer

public void setCodeBuffer(CodeBuffer code)

getLineNumber

public int getLineNumber(Location start)
Returns the line number in the source code from the given bytecode address (start_pc).
Returns:
-1 if no line number is mapped for the start_pc.

mapLineNumber

public void mapLineNumber(Location start,
                          int line_number)
Map a bytecode address (start_pc) to a line number in the source code as a debugging aid.

localVariableUse

public void localVariableUse(LocalVariable localVar)
Indicate a local variable's use information be recorded in the ClassFile as a debugging aid. If the LocalVariable doesn't provide both a start and end location, then its information is not recorded. This method should be called at most once per LocalVariable instance.

addAttribute

public void addAttribute(Attribute attr)

getAttributes

public Attribute[] getAttributes()
Description copied from class: Attribute
Some attributes have sub-attributes. Default implementation returns an empty array.
Overrides:
getAttributes in class Attribute

getLength

public int getLength()
Returns the length (in bytes) of this object in the class file.
Overrides:
getLength in class Attribute

writeDataTo

public void writeDataTo(java.io.DataOutput dout)
                 throws java.io.IOException
Description copied from class: Attribute
Write just the attribute specific data. The default implementation writes nothing.
Overrides:
writeDataTo in class Attribute