use of org.hotswap.agent.javassist.bytecode.MethodInfo in project HotswapAgent by HotswapProjects.
the class FieldInitLink method instrument.
public void instrument(CodeConverter converter) throws CannotCompileException {
checkModify();
ClassFile cf = getClassFile2();
ConstPool cp = cf.getConstPool();
List list = cf.getMethods();
int n = list.size();
for (int i = 0; i < n; ++i) {
MethodInfo minfo = (MethodInfo) list.get(i);
converter.doit(this, minfo, cp);
}
}
use of org.hotswap.agent.javassist.bytecode.MethodInfo in project HotswapAgent by HotswapProjects.
the class FieldInitLink method instrument.
public void instrument(ExprEditor editor) throws CannotCompileException {
checkModify();
ClassFile cf = getClassFile2();
List list = cf.getMethods();
int n = list.size();
for (int i = 0; i < n; ++i) {
MethodInfo minfo = (MethodInfo) list.get(i);
editor.doit(this, minfo);
}
}
use of org.hotswap.agent.javassist.bytecode.MethodInfo in project HotswapAgent by HotswapProjects.
the class FieldInitLink method removeMethod.
public void removeMethod(CtMethod m) throws NotFoundException {
checkModify();
MethodInfo mi = m.getMethodInfo2();
ClassFile cf = getClassFile2();
if (cf.getMethods().remove(mi)) {
getMembers().remove(m);
gcConstPool = true;
} else
throw new NotFoundException(m.toString());
}
use of org.hotswap.agent.javassist.bytecode.MethodInfo in project HotswapAgent by HotswapProjects.
the class FieldInitLink method modifyConstructors.
private void modifyConstructors(ClassFile cf) throws CannotCompileException, NotFoundException {
if (fieldInitializers == null)
return;
ConstPool cp = cf.getConstPool();
List list = cf.getMethods();
int n = list.size();
for (int i = 0; i < n; ++i) {
MethodInfo minfo = (MethodInfo) list.get(i);
if (minfo.isConstructor()) {
CodeAttribute codeAttr = minfo.getCodeAttribute();
if (codeAttr != null)
try {
Bytecode init = new Bytecode(cp, 0, codeAttr.getMaxLocals());
CtClass[] params = Descriptor.getParameterTypes(minfo.getDescriptor(), classPool);
int stacksize = makeFieldInitializer(init, params);
insertAuxInitializer(codeAttr, init, stacksize);
minfo.rebuildStackMapIf6(classPool, cf);
} catch (BadBytecode e) {
throw new CannotCompileException(e);
}
}
}
}
use of org.hotswap.agent.javassist.bytecode.MethodInfo in project HotswapAgent by HotswapProjects.
the class FieldInitLink method makeMemberList.
private void makeMemberList(HashMap table) {
int mod = getModifiers();
if (Modifier.isAbstract(mod) || Modifier.isInterface(mod))
try {
CtClass[] ifs = getInterfaces();
int size = ifs.length;
for (int i = 0; i < size; i++) {
CtClass ic = ifs[i];
if (ic != null && ic instanceof CtClassType)
((CtClassType) ic).makeMemberList(table);
}
} catch (NotFoundException e) {
}
try {
CtClass s = getSuperclass();
if (s != null && s instanceof CtClassType)
((CtClassType) s).makeMemberList(table);
} catch (NotFoundException e) {
}
List list = getClassFile2().getMethods();
int n = list.size();
for (int i = 0; i < n; i++) {
MethodInfo minfo = (MethodInfo) list.get(i);
table.put(minfo.getName(), this);
}
list = getClassFile2().getFields();
n = list.size();
for (int i = 0; i < n; i++) {
FieldInfo finfo = (FieldInfo) list.get(i);
table.put(finfo.getName(), this);
}
}
Aggregations