loadAspect(cv, isOptimizedJoinPoint, joinPointInstanceIndex, adviceMethodInfo.getAspectInfo());
AspectDefinition aspectDef = adviceMethodInfo.getAdviceInfo().getAdviceDefinition().getAspectDefinition();
if (aspectDef.isAspectWerkzAspect()) {
// AW aspect
// load the arguments that should be passed to the advice
int[] argIndexes = adviceMethodInfo.getAdviceMethodArgIndexes();
for (int j = 0; j < argIndexes.length; j++) {
int argIndex = argIndexes[j];
if (argIndex >= 0) {
Type argumentType = m_argumentTypes[argIndex];
int argStackIndex = AsmHelper.getRegisterIndexOf(m_argumentTypes, argIndex) + argStartIndex;
AsmHelper.loadType(cv, argStackIndex, argumentType);
} else if (argIndex == AdviceInfo.JOINPOINT_ARG || argIndex == AdviceInfo.STATIC_JOINPOINT_ARG) {
loadJoinPointInstance(cv, isOptimizedJoinPoint, joinPointInstanceIndex);
} else if (argIndex == AdviceInfo.TARGET_ARG) {
loadCallee(cv, isOptimizedJoinPoint, joinPointInstanceIndex, calleeIndex);
// add a cast if runtime check was used
if (adviceMethodInfo.getAdviceInfo().hasTargetWithRuntimeCheck()) {
cv.visitTypeInsn(
CHECKCAST,
adviceMethodInfo.getAdviceInfo().getMethodParameterTypes()[j].getInternalName()
);
}
} else if (argIndex == AdviceInfo.THIS_ARG) {
loadCaller(cv, isOptimizedJoinPoint, joinPointInstanceIndex, callerIndex);
} else if (argIndex == AdviceInfo.SPECIAL_ARGUMENT && specialArgIndex != INDEX_NOTAVAILABLE) {
Type argumentType = adviceMethodInfo.getAdviceInfo().getMethodParameterTypes()[j];
AsmHelper.loadType(cv, specialArgIndex, argumentType);
if (adviceMethodInfo.getAdviceInfo().getAdviceDefinition().getType().equals(
AdviceType.AFTER_THROWING
)) {
cv.visitTypeInsn(CHECKCAST, argumentType.getInternalName());
}
} else {
throw new Error("magic index is not supported: " + argIndex);
}
}
} else {
// non-AW aspect
adviceMethodInfo.setJoinPointIndex(joinPointInstanceIndex);
for (int i = 0; i < m_aspectModels.length; i++) {
AspectModel aspectModel = m_aspectModels[i];
if (aspectDef.getAspectModel().equals(aspectModel.getAspectModelType())) {
aspectModel.createAfterAdviceArgumentHandling(cv, adviceMethodInfo);
}