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 52441] New: InstructionTargeters not being properly cleaned up.
Date Mon, 09 Jan 2012 16:30:23 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=52441

             Bug #: 52441
           Summary: InstructionTargeters not being properly cleaned up.
           Product: BCEL
           Version: 5.3
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: minor
          Priority: P2
         Component: Main
        AssignedTo: notifications@jakarta.apache.org
        ReportedBy: thiagobart@gmail.com
    Classification: Unclassified


Created attachment 28127
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28127
New method to InstructionTargeter for target cleanup.

It seems that InstructionTargeters are not being properly cleaned up when they
are not used anymore. That is, when a targeter is replaced or removed (e.g., a
LocalVariableGen is removed from a method), the targeter remains in the
targeters list of its targets.

For example, MethodGen's constructor which receives a Method uses its other
constructor to initialize the object:

public MethodGen(Method m, String class_name, ConstantPoolGen cp) {
   this(
       m.getAccessFlags(), 
       Type.getReturnType(m.getSignature()),
       Type.getArgumentTypes(m.getSignature()),
       null /* may be overridden anyway */,
       m.getName(), 
       class_name,
       ((m.getAccessFlags() & (Constants.ACC_ABSTRACT | Constants.ACC_NATIVE))
== 0) ? new InstructionList(m.getCode().getCode()) : null, cp);
...
}

Because this call passes null as its 4th argument, the constructor will create
placeholder LocalVariableGen for the arguments (like arg0, arg1, etc). Later in
this constructor the arguments will be overridden (as indicated by the
comment). However, the LocalVariableGens of the placeholder arguments (as well
as the LocalVariableGen for the "this" variable) will remain in the targeter
lists of the first and last instructions of the instruction list.

To avoid this problem I am submitting a patch in attachment. It adds a new
method to InstructionTargeter:

    /**
     * Removes all targets of this targeter.
     */
    void removeTargets();

and implements it to remove the targeter from the target's lists. The patch
also calls removeTargets() when discarding targeters in MethodGen.

-- 
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


Mime
View raw message