How do I rename things using BCEL? So far what I do is go through each method in a class and create a new NameAndType constant in the constant pool, then I replace the old NameAndType constant with that one
int nameRef = cpg.addNameAndType(newName, m.getSignature());
cpg.setConstant(m.getNameIndex(), cpg.getConstant(nameRef));
This seems like it should work but my decompiler tells me the constant pool is corrupt after this. Am I missing a step or something?