// inlining support for code style aspects
if (!munger.getDeclaringType().isAnnotationStyleAspect()) {
String proceedName = NameMangler.proceedMethodName(munger.getSignature().getName());
InstructionHandle curr = localAdviceMethod.getBody().getStart();
InstructionHandle end = localAdviceMethod.getBody().getEnd();
ConstantPool cpg = localAdviceMethod.getEnclosingClass().getConstantPool();
while (curr != end) {
InstructionHandle next = curr.getNext();
Instruction inst = curr.getInstruction();
if ((inst.opcode == Constants.INVOKESTATIC) && proceedName.equals(((InvokeInstruction) inst).getMethodName(cpg))) {
localAdviceMethod.getBody().append(curr,
getRedoneProceedCall(fact, extractedShadowMethod, munger, localAdviceMethod, proceedVarList));
Utility.deleteInstruction(curr, localAdviceMethod);
}
curr = next;
}
// and that's it.
} else {
// ATAJ inlining support for @AJ aspects
// [TODO document @AJ code rule: don't manipulate 2 jps proceed at the same time.. in an advice body]
InstructionHandle curr = localAdviceMethod.getBody().getStart();
InstructionHandle end = localAdviceMethod.getBody().getEnd();
ConstantPool cpg = localAdviceMethod.getEnclosingClass().getConstantPool();
while (curr != end) {
InstructionHandle next = curr.getNext();
Instruction inst = curr.getInstruction();
if ((inst instanceof INVOKEINTERFACE) && "proceed".equals(((INVOKEINTERFACE) inst).getMethodName(cpg))) {
final boolean isProceedWithArgs;
if (((INVOKEINTERFACE) inst).getArgumentTypes(cpg).length == 1) {
// proceed with args as a boxed Object[]
isProceedWithArgs = true;
} else {
isProceedWithArgs = false;
}
InstructionList insteadProceedIl = getRedoneProceedCallForAnnotationStyle(fact, extractedShadowMethod, munger,
localAdviceMethod, proceedVarList, isProceedWithArgs);
localAdviceMethod.getBody().append(curr, insteadProceedIl);
Utility.deleteInstruction(curr, localAdviceMethod);
}
curr = next;
}
}
// if (parameterNames.size() == 0) {
// On return we have inserted the advice body into the local advice method. We have remapped all the local variables
// that were referenced in the advice as we did the copy, and so the local variable table for localAdviceMethod is
// now lacking any information about all the initial variables.
InstructionHandle start = localAdviceMethod.getBody().getStart();
InstructionHandle end = localAdviceMethod.getBody().getEnd();
// Find the real start and end
while (start.getInstruction().opcode == Constants.IMPDEP1) {
start = start.getNext();
}
while (end.getInstruction().opcode == Constants.IMPDEP1) {
end = end.getPrev();
}
Type[] args = localAdviceMethod.getArgumentTypes();
int argNumber = 0;
for (int slot = 0; slot < extraParamOffset; argNumber++) { // slot will increase by the argument size each time
String argumentName = null;
if (argNumber >= args.length || parameterNames.size() == 0 || argNumber >= parameterNames.size()) {
// this should be unnecessary as I think all known joinpoints and helper methods
// propagate the parameter names around correctly - but just in case let us do this
// rather than fail. If a bug is raised reporting unknown as a local variable name
// then investigate the joinpoint giving rise to the ResolvedMember and why it has
// no parameter names specified
argumentName = new StringBuffer("unknown").append(argNumber).toString();
} else {
argumentName = parameterNames.get(argNumber);
}
String argumentSignature = args[argNumber].getSignature();
LocalVariableTag lvt = new LocalVariableTag(argumentSignature, argumentName, slot, 0);
start.addTargeter(lvt);
end.addTargeter(lvt);
slot += args[argNumber].getSize();
}
}