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();
Whoops, code confusion with a subclass. *Puts on dunce hat and sits in corner for 15 minutes*