Bug 39911 - BCEL 5.2 - MethodGen does not initialize max_stack and max_locals properly
Summary: BCEL 5.2 - MethodGen does not initialize max_stack and max_locals properly
Status: RESOLVED FIXED
Alias: None
Product: BCEL - Now in Jira
Classification: Unclassified
Component: Main (show other bugs)
Version: unspecified
Hardware: All All
: P2 major
Target Milestone: ---
Assignee: issues@commons.apache.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-27 14:44 UTC by Alex Kinneer
Modified: 2006-08-15 08:07 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Kinneer 2006-06-27 14:44:40 UTC
The constructor for MethodGen:

public MethodGen(Method, String, ConstantPoolGen)

does not properly initialize the max_stack and max_local variables from the
Method object. Thus the following sequence of actions will produce a
non-verifying class, even though it clearly shouldn't:

ClassGen cg = new ClassGen(javaClass);
Method m = cg.getMethodAt(0);
MethodGen mg = new MethodGen(m, cg.getClassName(), cg.getConstantPool());
cg.setMethodAt(mg.getMethod(), 0);
cg.getJavaClass().dump(...);

Bug can be fixed by adding the following the constructor:

Code c = m.getCode();
max_stack = c.getMaxStack();
max_locals = c.getMaxLocals();
Comment 1 Alex Kinneer 2006-08-15 15:07:11 UTC
Whoops, code confusion with a subclass.

*Puts on dunce hat and sits in corner for 15 minutes*