use of org.hotswap.agent.javassist.bytecode.ClassFile 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.ClassFile 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.ClassFile in project HotswapAgent by HotswapProjects.
the class FieldInitLink method hasAnnotation.
// @Override
public boolean hasAnnotation(String annotationName) {
ClassFile cf = getClassFile2();
AnnotationsAttribute ainfo = (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.invisibleTag);
AnnotationsAttribute ainfo2 = (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.visibleTag);
return hasAnnotationType(annotationName, getClassPool(), ainfo, ainfo2);
}
use of org.hotswap.agent.javassist.bytecode.ClassFile in project HotswapAgent by HotswapProjects.
the class FieldInitLink method removeField.
public void removeField(CtField f) throws NotFoundException {
checkModify();
FieldInfo fi = f.getFieldInfo2();
ClassFile cf = getClassFile2();
if (cf.getFields().remove(fi)) {
getMembers().remove(f);
gcConstPool = true;
} else
throw new NotFoundException(f.toString());
}
use of org.hotswap.agent.javassist.bytecode.ClassFile in project HotswapAgent by HotswapProjects.
the class FieldInitLink method makeNestedClass.
public CtClass makeNestedClass(String name, boolean isStatic) {
if (!isStatic)
throw new RuntimeException("sorry, only nested static class is supported");
checkModify();
CtClass c = classPool.makeNestedClass(getName() + "$" + name);
ClassFile cf = getClassFile2();
ClassFile cf2 = c.getClassFile2();
InnerClassesAttribute ica = (InnerClassesAttribute) cf.getAttribute(InnerClassesAttribute.tag);
if (ica == null) {
ica = new InnerClassesAttribute(cf.getConstPool());
cf.addAttribute(ica);
}
ica.append(c.getName(), this.getName(), name, (cf2.getAccessFlags() & ~AccessFlag.SUPER) | AccessFlag.STATIC);
cf2.addAttribute(ica.copy(cf2.getConstPool(), null));
return c;
}
Aggregations