Class CodeAttribute

java.lang.Object
  |
  +--JavaElement
        |
        +--CodeAttribute

class CodeAttribute
extends JavaElement
implements JVM


Inner Class Summary
(package private)  class CodeAttribute.exception_table_entry
           
(package private)  class CodeAttribute.NeededInstructionsCollector
           
 
Field Summary
private  AttributeTable attributes
           
(package private)  byte[] code
           
(package private)  boolean[] codeNeeded
           
(package private)  CodeAttribute.exception_table_entry[] exception_table
           
(package private)  int max_locals
           
(package private)  int max_stack
           
(package private)  MethodInfo method
           
(package private)  ConstantPool pool
           
 
Fields inherited from class JavaElement
EXACT_INSTANCE_NEEDED, INSTANCE_NEEDED, NEEDED, NEEDED_INSTANCEOF, NEEDED_VIRTUALLY, neededModeAddOn, neededModeBasic, neededReasons, UNNEEDED
 
Constructor Summary
(package private) CodeAttribute(java.lang.Object obj, ConstantPool pool, java.io.DataInput in)
           
 
Method Summary
(package private)  boolean[] computeInstructionsNeeded(StackEntry[] preStackArray, CodeOptions options)
          For a method that is globally needed, compute an array marking individual instructions as needed or unneeded.
(package private)  boolean[] computeJumpTargets()
          return a boolean array marking the jump targets of this code.
(package private)  StackEntry[] computeStackArray()
          computes the stack contents array.
(package private)  void markBytecodesUsed(boolean[] bytecodesUsed)
          marks the bytecodes used in this code.
(package private)  void needAastore()
          declare the element types of all reference-array classes with instances as 'NEEDED_INSTANCEOF'.
(package private)  void needException(java.lang.String className)
          declare a named exception class as 'INSTANCE_NEEDED'.
(package private)  void report()
          print to System.out a readable description of this code.
(package private)  void updateNeeded()
          update the 'needed' state of this code's method and the elements referenced in this code.
(package private)  void updateNeededComplex(CodeOptions options)
          update the 'needed' state of this code's method and the elements referenced in this code.
(package private)  void updateNeededSimple()
          update the 'needed' state of this code's method and the elements referenced in this code.
(package private)  void write(java.io.DataOutput out)
          write this code attribute to a classfile.
 
Methods inherited from class JavaElement
isNeeded, isNeeded, markNeeded
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

max_stack

int max_stack

max_locals

int max_locals

code

byte[] code

codeNeeded

boolean[] codeNeeded

exception_table

CodeAttribute.exception_table_entry[] exception_table

attributes

private AttributeTable attributes

method

MethodInfo method

pool

ConstantPool pool
Constructor Detail

CodeAttribute

CodeAttribute(java.lang.Object obj,
              ConstantPool pool,
              java.io.DataInput in)
        throws java.io.IOException
Method Detail

write

void write(java.io.DataOutput out)
     throws java.io.IOException
write this code attribute to a classfile.

needException

void needException(java.lang.String className)
declare a named exception class as 'INSTANCE_NEEDED'. A JVM instruction that can cause such an exception to be thrown uses this call in the 'updateNeeded()' process to declare the dependency on this exception class. In addition to the class itself, its no-args initializer is 'NEEDED' too.
Parameters:
className - the name of the exception class.

needAastore

void needAastore()
declare the element types of all reference-array classes with instances as 'NEEDED_INSTANCEOF'. E.g. if [Ljava/lang/String; has instances, then the java/lang/String class becomes 'NEEDED_INSTANCEOF'. This is a result of having an 'aastore' instruction. Any reference-array can become destination of such an instruction, and thus an implicit 'checkcast' to the element type of the array (determined at run-time!) must be executed.

updateNeeded

void updateNeeded()
update the 'needed' state of this code's method and the elements referenced in this code.
Overrides:
updateNeeded in class JavaElement

updateNeededSimple

void updateNeededSimple()
update the 'needed' state of this code's method and the elements referenced in this code. This is the simple version treating the method as an atomic entity. Its code is either completely included or completely excluded.

updateNeededComplex

void updateNeededComplex(CodeOptions options)
update the 'needed' state of this code's method and the elements referenced in this code. This is the complex version looking at the individual instructions and deciding which of them are necessary.

computeJumpTargets

boolean[] computeJumpTargets()
return a boolean array marking the jump targets of this code. Start-pc and end-pc of exception-handling regions are considered jump targets too, as they also need to have labels.

computeStackArray

StackEntry[] computeStackArray()
computes the stack contents array. This array contains the stack description for every instruction in the code. At index N, the array shows the stack contents before executing the instruction at index N.

markBytecodesUsed

void markBytecodesUsed(boolean[] bytecodesUsed)
marks the bytecodes used in this code.

computeInstructionsNeeded

boolean[] computeInstructionsNeeded(StackEntry[] preStackArray,
                                    CodeOptions options)
For a method that is globally needed, compute an array marking individual instructions as needed or unneeded. True means 'needed'. As a side-effect, elements that this code depends upon (e.g. fields or methods) are marked 'needed', too. If the code has a 'needed' side-effect, it is marked 'needed' itself (to allow for <clinit> methods to become needed for the side-effects).

report

void report()
print to System.out a readable description of this code.