[prev in list] [next in list] [prev in thread] [next in thread]
List: slide-dev
Subject: DO NOT REPLY [Bug 52468] New: Invalid LocalVariableTable and LineNumberTable after modifying instruc
From: bugzilla () apache ! org
Date: 2012-01-14 17:58:38
Message-ID: bug-52468-55412 () https ! issues ! apache ! org/bugzilla/
[Download RAW message or body]
https://issues.apache.org/bugzilla/show_bug.cgi?id=52468
Bug #: 52468
Summary: Invalid LocalVariableTable and LineNumberTable after
modifying instruction list
Product: BCEL
Version: 5.3
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: Main
AssignedTo: notifications@jakarta.apache.org
ReportedBy: thiagobart@gmail.com
Classification: Unclassified
Created attachment 28158
--> https://issues.apache.org/bugzilla/attachment.cgi?id=28158
Fixes bugs 52441, 52422 and invalid offsets in local variable and line number
tables
LocalVariableGen objects point to the start and end InstructionHandles which
indicate the variable range. However, when changing the instruction list with
MethodGen.setInstructionList, the LocalVariableGen objects point to instruction
handles that do not belong to the new list. When MethodGen.getMethod is called,
LocalVariable objects will be created using the bytecode offsets of handles
that do not belong to the current instruction list. Because bytecode
instructions can have different lengths, the offsets may be invalid (i.e., do
not point to an instruction, which is invalid according to the java bytecode
spec).
A similar problem occurs with LineNumberGens.
One proposed solution is to check at getLocalVariables() (and
getLineNumberTable) whether the target handle belongs to the current
instruction list. If not, we first search for the "best candidate" in the
current list, i.e., the instruction with the position of the original targeted
instruction, or the next one if there is no perfect match. Then we use this
instruction's offset in the LocalVariable.
Sketch of the code:
public LocalVariableGen[] getLocalVariables() {
int size = variable_vec.size();
LocalVariableGen[] lg = new LocalVariableGen[size];
variable_vec.toArray(lg);
for (int i = 0; i < size; i++) {
if (lg[i].getStart() == null) {
lg[i].setStart(il.getStart());
} else {
lg[i].setStart(il.findHandle(lg[i].getStart().i_position));
}
...
}
The patch in attachment fixes this problem plus the last 2 bugs I reported (
https://issues.apache.org/bugzilla/show_bug.cgi?id=52441 and
https://issues.apache.org/bugzilla/show_bug.cgi?id=52422 ).
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@jakarta.apache.org
For additional commands, e-mail: notifications-help@jakarta.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic