ResolvedType memberType = m_aspectGen.getWorld().resolve(resolvedMember.getDeclaringType());
if (!aspectType.equals(memberType) && memberType.isAssignableFrom(aspectType)) {
// old test was...
// if (aspectType.getSuperclass() != null
// && aspectType.getSuperclass().getName().equals(resolvedMember.getDeclaringType().getName())) {
ResolvedMember accessor = createOrGetInlineAccessorForSuperDispatch(resolvedMember);
InvokeInstruction newInst = factory.createInvoke(aspectType.getName(), accessor.getName(),
BcelWorld.makeBcelType(accessor.getReturnType()),
BcelWorld.makeBcelTypes(accessor.getParameterTypes()), Constants.INVOKEVIRTUAL);
curr.setInstruction(newInst);
} else {
ResolvedMember accessor = createOrGetInlineAccessorForMethod(resolvedMember);
InvokeInstruction newInst = factory.createInvoke(aspectType.getName(), accessor.getName(),
BcelWorld.makeBcelType(accessor.getReturnType()),
BcelWorld.makeBcelTypes(accessor.getParameterTypes()), Constants.INVOKESTATIC);
curr.setInstruction(newInst);
}
}
break;// ok we found a matching callee member and swapped the instruction with the accessor
}
}
} else if (inst instanceof FieldInstruction) {
FieldInstruction invoke = (FieldInstruction) inst;
ResolvedType callee = m_aspectGen.getWorld().resolve(UnresolvedType.forName(invoke.getClassName(cpg)));
for (int i = 0; i < callee.getDeclaredJavaFields().length; i++) {
ResolvedMember resolvedMember = callee.getDeclaredJavaFields()[i];
if (invoke.getName(cpg).equals(resolvedMember.getName())
&& invoke.getSignature(cpg).equals(resolvedMember.getSignature()) && !resolvedMember.isPublic()) {
final ResolvedMember accessor;
if ((inst.opcode == Constants.GETFIELD) || (inst.opcode == Constants.GETSTATIC)) {
accessor = createOrGetInlineAccessorForFieldGet(resolvedMember);
} else {
accessor = createOrGetInlineAccessorForFieldSet(resolvedMember);
}
InvokeInstruction newInst = factory.createInvoke(aspectType.getName(), accessor.getName(),
BcelWorld.makeBcelType(accessor.getReturnType()),
BcelWorld.makeBcelTypes(accessor.getParameterTypes()), Constants.INVOKESTATIC);
curr.setInstruction(newInst);
break;// ok we found a matching callee member and swapped the instruction with the accessor
}
}