use of javassist.bytecode.InnerClassesAttribute in project powermock by powermock.
the class AbstractMainMockTransformer method removeFinalModifierFromClass.
protected void removeFinalModifierFromClass(final CtClass clazz) {
if (strategy != INST_REDEFINE) {
if (Modifier.isFinal(clazz.getModifiers())) {
clazz.setModifiers(clazz.getModifiers() ^ Modifier.FINAL);
}
ClassFile classFile = clazz.getClassFile2();
AttributeInfo attribute = classFile.getAttribute(InnerClassesAttribute.tag);
if (attribute != null && attribute instanceof InnerClassesAttribute) {
InnerClassesAttribute ica = (InnerClassesAttribute) attribute;
String name = classFile.getName();
int n = ica.tableLength();
for (int i = 0; i < n; ++i) {
if (name.equals(ica.innerClass(i))) {
int accessFlags = ica.accessFlags(i);
if (Modifier.isFinal(accessFlags)) {
ica.setAccessFlags(i, accessFlags ^ Modifier.FINAL);
}
}
}
}
}
}
Aggregations