use of org.hotswap.agent.javassist.bytecode.ClassFile in project HotswapAgent by HotswapProjects.
the class FieldInitLink method replaceClassName.
public void replaceClassName(ClassMap classnames) throws RuntimeException {
String oldClassName = getName();
String newClassName = (String) classnames.get(Descriptor.toJvmName(oldClassName));
if (newClassName != null) {
newClassName = Descriptor.toJavaName(newClassName);
// check this in advance although classNameChanged() below does.
classPool.checkNotFrozen(newClassName);
}
super.replaceClassName(classnames);
ClassFile cf = getClassFile2();
cf.renameClass(classnames);
nameReplaced();
if (newClassName != null) {
super.setName(newClassName);
classPool.classNameChanged(oldClassName, this);
}
}
use of org.hotswap.agent.javassist.bytecode.ClassFile in project HotswapAgent by HotswapProjects.
the class FieldInitLink method getModifiers.
public int getModifiers() {
ClassFile cf = getClassFile2();
int acc = cf.getAccessFlags();
acc = AccessFlag.clear(acc, AccessFlag.SUPER);
int inner = cf.getInnerAccessFlags();
if (inner != -1 && (inner & AccessFlag.STATIC) != 0)
acc |= AccessFlag.STATIC;
return AccessFlag.toModifier(acc);
}
use of org.hotswap.agent.javassist.bytecode.ClassFile in project HotswapAgent by HotswapProjects.
the class FieldInitLink method setAttribute.
public void setAttribute(String name, byte[] data) {
checkModify();
ClassFile cf = getClassFile2();
cf.addAttribute(new AttributeInfo(cf.getConstPool(), name, data));
}
use of org.hotswap.agent.javassist.bytecode.ClassFile in project HotswapAgent by HotswapProjects.
the class FieldInitLink method getDeclaringClass.
public CtClass getDeclaringClass() throws NotFoundException {
ClassFile cf = getClassFile2();
InnerClassesAttribute ica = (InnerClassesAttribute) cf.getAttribute(InnerClassesAttribute.tag);
if (ica == null)
return null;
String name = getName();
int n = ica.tableLength();
for (int i = 0; i < n; ++i) if (name.equals(ica.innerClass(i))) {
String outName = ica.outerClass(i);
if (outName != null)
return classPool.get(outName);
else {
// maybe anonymous or local class.
EnclosingMethodAttribute ema = (EnclosingMethodAttribute) cf.getAttribute(EnclosingMethodAttribute.tag);
if (ema != null)
return classPool.get(ema.className());
}
}
return null;
}
use of org.hotswap.agent.javassist.bytecode.ClassFile in project HotswapAgent by HotswapProjects.
the class FieldInitLink method setName.
public void setName(String name) throws RuntimeException {
String oldname = getName();
if (name.equals(oldname))
return;
// check this in advance although classNameChanged() below does.
classPool.checkNotFrozen(name);
ClassFile cf = getClassFile2();
super.setName(name);
cf.setName(name);
nameReplaced();
classPool.classNameChanged(oldname, this);
}
Aggregations