| Summary: | Incorrect LOCALVARIABLE entries in bytecode generated by ECJ | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Mario Zechner <contact> |
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | jarthana, manoj.palat, srikanth_sankaran, stephan.herrmann |
| Version: | 4.5 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | stalebug | ||
Not sure, which tool produced that output, but I can see the effect using familiar javap output, too:
static int test(int);
flags: ACC_STATIC
Code:
stack=2, locals=3, args_size=1
0: iload_0
1: ifle 16
4: bipush 10
6: istore_1
7: iload_1
8: bipush 10
10: if_icmpne 4
13: goto 32
16: iconst_0
17: istore_2
18: goto 26
21: iload_2
22: istore_1
23: iinc 2, 1
26: iload_2
27: bipush 10
29: if_icmplt 21
32: bipush 10
34: ireturn
LineNumberTable:
line 4: 0
line 6: 4
line 7: 7
line 9: 13
line 10: 16
line 11: 21
line 10: 23
line 14: 32
LocalVariableTable:
Start Length Slot Name Signature
0 35 0 a I
7 9 1 resDigit I
23 3 1 resDigit I
18 14 2 i I
StackMapTable: number_of_entries = 5
frame_type = 4 /* same */
frame_type = 11 /* same */
frame_type = 255 /* full_frame */
offset_delta = 4
locals = [ int, top, int ]
stack = []
frame_type = 4 /* same */
frame_type = 255 /* full_frame */
offset_delta = 5
locals = [ int ]
stack = []
Shouldn't the first range for resDigit start at 6?
Also the range for 'i' looks fishy, I'd expect start 16 or 17.
Line numbers look correct, though.
Sasi, Could you please take a look? This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |
Given this piece of code: static int test(int a) { int resDigit; if(a > 0) { while(true) { resDigit = 10; if(resDigit == 10) break; } } else { for(int i = 0; i < 10; i++) { resDigit = i; } } return 10; } ECJ generates the following byte code: static test(int) : int L0 LINENUMBER 5 L0 ILOAD 0: a IFLE L1 L2 LINENUMBER 7 L2 FRAME SAME BIPUSH 10 ISTORE 1 L3 LINENUMBER 8 L3 ILOAD 1: resDigit BIPUSH 10 IF_ICMPNE L2 L4 LINENUMBER 10 L4 GOTO L5 L1 LINENUMBER 11 L1 FRAME SAME ICONST_0 ISTORE 2 L6 GOTO L7 L8 LINENUMBER 12 L8 FRAME FULL [int top int] [] ILOAD 2: i ISTORE 1 L9 LINENUMBER 11 L9 IINC 2: i 1 L7 FRAME SAME ILOAD 2: i BIPUSH 10 IF_ICMPLT L8 L5 LINENUMBER 15 L5 FRAME FULL [int] [] BIPUSH 10 IRETURN L10 LOCALVARIABLE a int L0 L10 0 LOCALVARIABLE resDigit int L3 L1 1 LOCALVARIABLE resDigit int L9 L7 1 LOCALVARIABLE i int L6 L5 2 MAXSTACK = 2 MAXLOCALS = 3 As you can see, the second LOCALVARIABLE entry for resDigit is incorrect. It covers parts of the for loop head (L9-L7) instead of the body (L8 - L9). This also expresses itself when debugging this method. The resDigit local can not be found for the "false" branch of the condition, see http://libgdx.badlogicgames.com/uploads/Screen%20Shot%202014-08-01%20at%2015.19.33-O2FeabfIQ2.png