JML

org.multijava.util.classfile
Class CodeInfo

java.lang.Object
  extended byorg.multijava.util.classfile.Attribute
      extended byorg.multijava.util.classfile.CodeInfo
Direct Known Subclasses:
SkippedCodeInfo

public class CodeInfo
extends Attribute

This class represents the Java virtual machine instructions and auxiliary information for a single method. VMS 4.7.3: Code Attribute. !!! graf 990904 add support for generic attributes.


Field Summary
private static AsciiConstant attr
           
private  AttributeList attributes
           
private  int codeLength
           
static CodeInfo DUM_INFO
           
private  HandlerInfo[] handlers
           
private  Instruction[] instructions
           
private  int maxLocals
           
private  int maxStack
           
private  int paramCnt
           
 
Constructor Summary
protected CodeInfo()
          This constructor is only used by SkippedCodeInfo
  CodeInfo(DataInput in, ConstantPool cp)
          Make up a new attribute
  CodeInfo(Instruction[] instructions, HandlerInfo[] handlers, LineNumberInfo[] lineNumbers, LocalVariableInfo[] localVariables)
          Make up a new attribute
 
Method Summary
private  void compactInstructions()
           
 int getCodeLength()
          Returns the length in bytes of the instruction array.
 HandlerInfo[] getHandlers()
          Returns handlers
 Instruction[] getInstructions()
          Returns the instruction of code
 LineNumberInfo[] getLineNumbers()
          Returns line number information
 LocalVariableInfo[] getLocalVariables()
          Returns local variable information
 int getMaxLocals()
          Returns the number of locals vars used in this method (including parameters).
 int getMaxStack()
          Returns the highest value reached by the stack.
 int getParameterCount()
          Gets the number of parameters for this method.
protected  int getSize()
          Returns the space in bytes used by this attribute in the classfile
protected  int getTag()
          Returns the attribute's tag
protected  void resolveConstants(ConstantPool cp)
          Insert or check location of constant value on constant pool
(package private)  void setCodeLength(int codeLength)
          Sets the length in bytes of the instruction array.
(package private)  void setMaxLocals(int maxLocals)
          Sets the number of locals var used by this method.
(package private)  void setMaxStack(int maxStack)
          Sets the highest value reached by the stack.
 void setParameterCount(int paramCnt)
          Sets the number of parameters for this method.
 void transformAccessors(AccessorTransformer transformer)
          Transforms the accessors contained in this class.
protected  void write(ConstantPool cp, DataOutput out)
          Write this class into the the file (out) getting data position from the constant pool
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DUM_INFO

public static final CodeInfo DUM_INFO

attr

private static AsciiConstant attr

instructions

private Instruction[] instructions

handlers

private HandlerInfo[] handlers

paramCnt

private int paramCnt

maxStack

private int maxStack

maxLocals

private int maxLocals

codeLength

private int codeLength

attributes

private AttributeList attributes
Constructor Detail

CodeInfo

public CodeInfo(Instruction[] instructions,
                HandlerInfo[] handlers,
                LineNumberInfo[] lineNumbers,
                LocalVariableInfo[] localVariables)
Make up a new attribute

Parameters:
instructions - array of VM instructions
handlers - exception handlers
lineNumbers - line number information
localVariables - local variable information

CodeInfo

public CodeInfo(DataInput in,
                ConstantPool cp)
         throws IOException,
                ClassFileFormatException
Make up a new attribute

Parameters:
in - the stream to read from
cp - the constant pool
Throws:
IOException - an io problem has occured
ClassFileFormatException - attempt to write a bad classfile info

CodeInfo

protected CodeInfo()
This constructor is only used by SkippedCodeInfo

Method Detail

compactInstructions

private void compactInstructions()

transformAccessors

public void transformAccessors(AccessorTransformer transformer)
                        throws BadAccessorException
Transforms the accessors contained in this class.

Parameters:
transformer - the transformer used to transform accessors
Throws:
BadAccessorException

getTag

protected int getTag()
Returns the attribute's tag


getSize

protected int getSize()
Returns the space in bytes used by this attribute in the classfile


getInstructions

public Instruction[] getInstructions()
Returns the instruction of code


getHandlers

public HandlerInfo[] getHandlers()
Returns handlers


getLineNumbers

public LineNumberInfo[] getLineNumbers()
Returns line number information


getLocalVariables

public LocalVariableInfo[] getLocalVariables()
Returns local variable information


getCodeLength

public int getCodeLength()
Returns the length in bytes of the instruction array.


getMaxStack

public int getMaxStack()
Returns the highest value reached by the stack.


getMaxLocals

public int getMaxLocals()
Returns the number of locals vars used in this method (including parameters).


setParameterCount

public void setParameterCount(int paramCnt)
Sets the number of parameters for this method.


getParameterCount

public int getParameterCount()
Gets the number of parameters for this method.


setCodeLength

void setCodeLength(int codeLength)
Sets the length in bytes of the instruction array.


setMaxStack

void setMaxStack(int maxStack)
Sets the highest value reached by the stack.


setMaxLocals

void setMaxLocals(int maxLocals)
Sets the number of locals var used by this method.


resolveConstants

protected void resolveConstants(ConstantPool cp)
                         throws ClassFileFormatException
Insert or check location of constant value on constant pool

Parameters:
cp - the constant pool for this class
Throws:
ClassFileFormatException

write

protected void write(ConstantPool cp,
                     DataOutput out)
              throws IOException,
                     ClassFileFormatException
Write this class into the the file (out) getting data position from the constant pool

Parameters:
cp - the constant pool that contain all data
out - the file where to write this object info
Throws:
IOException - an io problem has occured
ClassFileFormatException - attempt to write a bad classfile info

JML

JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.