jakarta-bcel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 44212] New: - Type of 'this' on instantiation of MethodGen from existing Method
Date Fri, 11 Jan 2008 17:27:24 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=44212>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=44212

           Summary: Type of 'this' on instantiation of MethodGen from
                    existing Method
           Product: BCEL
           Version: 5.2
          Platform: Other
        OS/Version: Mac OS X 10.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Main
        AssignedTo: bcel-dev@jakarta.apache.org
        ReportedBy: jesper.spring@epfl.ch


I have an issue when instantiating a MethodGen from an existing (non-static) method instance.
I'm 
trying to copy a (non-static) method from one class to another class using BCEL. Specifically,
I do:

MethodGen newMethodGen = new MethodGen(originalMethod.getBCELMethod(), 
newClassGen.getClassName(), newClassGen.getConstantPool());

This works nicely except for one issue; the 'this' variable in the local variable table points
to the entry in 
the CP representing the type of the originating class, and not the type of the class in which
it is inserted 
in. 

I traced a bit in the BCEL code, and found that to start with during the instantiation process
of the 
MethodGen class (in the constructor), the 'this' variable in the local variable table indeed
points to the 
correct entry in the CP representing the type of the new class .. 

However, it appears that after the initial instantiation, the attributes of the provided originating
method 
overrides the local variable table. Specifically, in the constructor (the lines 213-229) the
local variable 
table is deleted, and instead the local variable table of the provided original method is
copied over.

>From the documentation I cannot tell if this is by design, but it does appear to be a
bit confusing; 
specifically, one can put a method into one class, but the 'this' variable points to another
class. If this is 
by design, I would propose some exception throwing if the provided name of the class differs
from 
class used in the local variable table.

Now we're at it .. invoking setClassName() on a MethodGen instance does also not make any
changes to 
the local variable table -- again making it possible to have this inconsistency.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-dev-help@jakarta.apache.org


Mime
View raw message