* For a long time, AspectJ did not allow binary weaving of declare parents. This restriction is now lifted but could do with
* more testing!
*/
private boolean mungeNewParent(BcelClassWeaver weaver, NewParentTypeMunger typeTransformer) {
LazyClassGen newParentTarget = weaver.getLazyClassGen();
ResolvedType newParent = typeTransformer.getNewParent();
boolean performChange = true;
performChange = enforceDecpRule1_abstractMethodsImplemented(weaver, typeTransformer.getSourceLocation(), newParentTarget,
newParent);
performChange = enforceDecpRule2_cantExtendFinalClass(weaver, typeTransformer.getSourceLocation(), newParentTarget,
newParent) && performChange;
List<ResolvedMember> methods = newParent.getMethodsWithoutIterator(false, true, false);
for (ResolvedMember method : methods) {
if (!method.getName().equals("<init>")) {
LazyMethodGen subMethod = findMatchingMethod(newParentTarget, method);
// FIXME asc is this safe for all bridge methods?
if (subMethod != null && !subMethod.isBridgeMethod()) {
if (!(subMethod.isSynthetic() && method.isSynthetic())) {
if (!(subMethod.isStatic() && subMethod.getName().startsWith("access$"))) {
// ignore generated accessors
performChange = enforceDecpRule3_visibilityChanges(weaver, newParent, method, subMethod)
&& performChange;
performChange = enforceDecpRule4_compatibleReturnTypes(weaver, method, subMethod) && performChange;
performChange = enforceDecpRule5_cantChangeFromStaticToNonstatic(weaver,
typeTransformer.getSourceLocation(), method, subMethod)
&& performChange;
}
}
}
}
}
if (!performChange) {
// A rule was violated and an error message already reported
return false;
}
if (newParent.isClass()) {
// Changing the supertype
if (!attemptToModifySuperCalls(weaver, newParentTarget, newParent)) {
return false;
}
newParentTarget.setSuperClass(newParent);