So here is the example:
LocalVariableTable:
Start Length Slot Name Signature
0 133 0 this Lcom/my/class/Test;
2 131 1 a I
4 129 2 b I
7 126 3 i I
10 123 4 i2 I
16 117 5 o1 Ljava/lang/Integer;
31 102 6 o2 Ljava/lang/Integer;
What does start and length mean? Why does length have the value it has? Why length is different for the equal types (Integer)? Why length could be changed, when I add something to class and recompile it without touching that particular local variable?
Start is the start bytecode offset where this variable is visible. Length is number of bytecode bytes during which this variable is visible. Usually start points to the bytecode instruction where the variable is first assigned or to 0 for method parameters and this
. In your case it seems that all variables are valid to the end of the method (start+length = 133
for every variable), but if you declare some variables inside blocks, their scope will be shorter.
Note that local variables table (LVT) is an optional debugging information. It's not necessary for program execution and can be switched off using -g:none
during the compilation. The main purpose of this table is to make debugging more convenient: having it you can determine for each bytecode positions which variables are currently visible to display them in variables pane and hide them once you step out of the variable scope. Also this table is used by java decompilers and code analyzers like FindBugs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With