jakarta-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 52468] New: Invalid LocalVariableTable and LineNumberTable after modifying instruction list
Date Sat, 14 Jan 2012 17:58:38 GMT

             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

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

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];
    for (int i = 0; i < size; i++) {
        if (lg[i].getStart() == null) {
        } else {

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

View raw message