|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--util.dataRead | +--attr.attrInfo | +--attr.localVarTabAttr
This object represents the local variable table. The local variable table is an attribute that may be in the attribute table of the code attribute (codeAttr object). This attribute is generated by the Java compiler when debug is turned on (-g).
The JVM Spec. states:
It may be used by debuggers to determine the value of a given local variable during the execution of a method. If LocalVariableTable attributes are present in the attributes table of a given Code attribute, then they may appear in any order. There may be no more than one LocalVariableTable attribute per local variable in the Code attribute. (JVM 4.7.9)
This is rather misleading. The local variable table contains information about the local variable declarations. There is one entry for each local variable (the table includes the class reference variable "this").
The LocalVariableTable attribute has the format
LocalVariableTable_attribute { u2 attribute_name_index; u4 attribute_length; u2 local_variable_table_length; localVarEnt local_variable_table[local_variable_table_length]; }
The attribute_name_index and attribute length are read by the attrFactory.allocAttr method. These values are passed into the class constructor.
The localVarEnt is
localVarEnt { u2 start_pc; u2 length; u2 name_index; u2 descriptor_index; u2 index; }
There is one localVarEnt structure for each local variable.
The JVM Spec (4.7.9) states:
The given local variable must have a value at indices into the code array in the interval [start_pc, start_pc+length], that is, between start_pc and start_pc+length inclusive. The value of start_pc must be a valid index into the code array of this Code attribute of the opcode of an instruction. The value of start_pc+length must be either a valid index into the code array of this Code attribute of the opcode of an instruction, or the first index beyond the end of that code array.
So the byte code from start_pc to start_pc+length seems to indicate the live range for the variable. That is, the variable is assigned a value at the start of the range and may be assigned other values through out the range. The range ends with the last reference to the variable.
If an optimizing compiler generated the code and the variable is "dead" at a point in the source where a a debugger asks for its value or attempts to write the value then the debugger can report that the value is unavailable.
The start_pc (the offset into the code array) is 16-bits. However, the size of the code array is 32-bits. In theory this means that there may be indices that can't be referenced. In practice the size of Java objects seems to be limited (at least up through release 1.2).
The name_index is an index into the constant table for the constUtf8 object for the variable name.
The descriptor_index is an index into the constant table for the constUtf8 object for the variable descriptor that describes the object.
The index field is the frame offset location for the local variable.
The JVM Spec states for the index:
The given local variable must be at index in its method's local variables. If the local variable at index is a two-word type (double or long), it occupies both index and index+1.
By local variables, the JVM Spec is referring to the local frame. Note that frames are not necessarily allocated on the stack.
Inner Class Summary | |
(package private) class |
localVarTabAttr.localVarEnt
Local variable entry in the local variable table. |
Field Summary | |
(package private) localVarTabAttr.localVarEnt[] |
localVarTab
|
Fields inherited from class attr.attrInfo |
attrName,
len |
Fields inherited from class util.dataRead |
bytesRead |
Constructor Summary | |
(package private) |
localVarTabAttr(java.lang.String name,
int length,
java.io.DataInputStream dStream,
constPool constPoolSec)
|
Method Summary | |
java.util.Vector |
getLocalVarVec()
|
Methods inherited from class attr.attrInfo |
getName,
pr |
Methods inherited from class util.dataRead |
getBytesRead,
readU1,
readU2,
readU4 |
Methods inherited from class java.lang.Object |
|
Field Detail |
localVarTabAttr.localVarEnt[] localVarTab
Constructor Detail |
localVarTabAttr(java.lang.String name, int length, java.io.DataInputStream dStream, constPool constPoolSec)
Method Detail |
public java.util.Vector getLocalVarVec()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |