use of org.hotswap.agent.javassist.bytecode.EnclosingMethodAttribute in project HotswapAgent by HotswapProjects.
the class FieldInitLink method getEnclosingBehavior.
public CtBehavior getEnclosingBehavior() throws NotFoundException {
ClassFile cf = getClassFile2();
EnclosingMethodAttribute ema = (EnclosingMethodAttribute) cf.getAttribute(EnclosingMethodAttribute.tag);
if (ema == null)
return null;
else {
CtClass enc = classPool.get(ema.className());
String name = ema.methodName();
if (MethodInfo.nameInit.equals(name))
return enc.getConstructor(ema.methodDescriptor());
else if (MethodInfo.nameClinit.equals(name))
return enc.getClassInitializer();
else
return enc.getMethod(name, ema.methodDescriptor());
}
}
use of org.hotswap.agent.javassist.bytecode.EnclosingMethodAttribute 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;
}
Aggregations