InstructionHandle next = curr.getNext();
Instruction inst = curr.getInstruction();
// open-up method call
if ((inst instanceof InvokeInstruction)) {
InvokeInstruction invoke = (InvokeInstruction) inst;
ResolvedType callee = m_aspectGen.getWorld().resolve(UnresolvedType.forName(invoke.getClassName(cpg)));
// look in the whole method list and not just declared for super calls and alike
List methods = callee.getMethodsWithoutIterator(false,true);
for (Iterator iter = methods.iterator(); iter.hasNext();) {
ResolvedMember resolvedMember = (ResolvedMember) iter.next();
if (invoke.getName(cpg).equals(resolvedMember.getName())
&& invoke.getSignature(cpg).equals(resolvedMember.getSignature())
&& !resolvedMember.isPublic()) {
if ("<init>".equals(invoke.getName(cpg))) {
// skipping open up for private constructor
// can occur when aspect new a private inner type
// too complex to handle new + dup + .. + invokespecial here.
aroundAdvice.setCanInline(false);
realizedCannotInline = true;
} else {
// specific handling for super.foo() calls, where foo is non public
if (aspectType.getSuperclass() != null
&& aspectType.getSuperclass().getName().equals(callee.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 instanceof GETFIELD) || (inst instanceof 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