我是javassist的新手,开始惹恼它,并得到一些工作。但是,还有很多其他的东西似乎并不奏效。用javassist创建空的构造函数(java)不能上班
我做了注入代码的方法到类 -
public static void editMethodAddEvent(CtClass target, MethodInfo method, CtClass eventClass, int start, int[] bytes, int stacksize, String constructorParameters) throws BadBytecode, NotFoundException, CannotCompileException {
target.defrost();
CodeAttribute codeAttribute = method.getCodeAttribute();
CodeIterator iterator = codeAttribute.iterator();
int classID = method.getConstPool().addClassInfo(eventClass);
int constrnatID = method.getConstPool().addNameAndTypeInfo("",constructorParameters);
int constructID = method.getConstPool().addMethodrefInfo(classID,constrnatID);
int callnatID = method.getConstPool().addNameAndTypeInfo("call","()V");
int callID = method.getConstPool().addMethodrefInfo(