enclosingMethod.setCanInline(false);
// start by exposing various useful things into the frame
- final InstructionFactory fact = getFactory();
// now generate the aroundBody method
// eg. "private static final void method_aroundBody0(M, M, String, org.aspectj.lang.JoinPoint)"
LazyMethodGen extractedShadowMethod = extractShadowInstructionsIntoNewMethod(NameMangler.aroundShadowMethodName(
- getSignature(), new Integer(getEnclosingClass().getNewGeneratedNameTag()).toString()), Modifier.PRIVATE, munger);
+ getSignature(), new Integer(getEnclosingClass().getNewGeneratedNameTag()).toString()), Modifier.PRIVATE, munger
+ .getSourceLocation());
List argsToCallLocalAdviceMethodWith = new ArrayList();
List proceedVarList = new ArrayList();
varMap.put(i - extraParamOffset, i);
}
+ final InstructionFactory fact = getFactory();
+
localAdviceMethod.getBody().insert(
BcelClassWeaver.genInlineInstructions(adviceMethod, localAdviceMethod, varMap, fact, true));
int linenumber = getSourceLine();
// MOVE OUT ALL THE INSTRUCTIONS IN MY SHADOW INTO ANOTHER METHOD!
LazyMethodGen callbackMethod = extractShadowInstructionsIntoNewMethod(NameMangler.aroundShadowMethodName(getSignature(),
- new Integer(getEnclosingClass().getNewGeneratedNameTag()).toString()), 0, munger);
+ new Integer(getEnclosingClass().getNewGeneratedNameTag()).toString()), 0, munger.getSourceLocation());
BcelVar[] adviceVars = munger.getExposedStateAsBcelVars(true);
// ---- extraction methods
- public LazyMethodGen extractShadowInstructionsIntoNewMethod(String newMethodName, int visibilityModifier, ShadowMunger munger) {
- LazyMethodGen.assertGoodBody(range.getBody(), newMethodName);
+ /**
+ * Extract the instructions in the shadow to a new method.
+ *
+ * @param extractedMethodName name for the new method
+ * @param extractedMethodVisibilityModifier visibility modifiers for the new method
+ * @param adviceSourceLocation source location of the advice affecting the shadow
+ */
+ public LazyMethodGen extractShadowInstructionsIntoNewMethod(String extractedMethodName, int extractedMethodVisibilityModifier,
+ ISourceLocation adviceSourceLocation) {
+ LazyMethodGen.assertGoodBody(range.getBody(), extractedMethodName);
if (!getKind().allowsExtraction())
throw new BCException("Attempt to extract method from a shadow kind that does not support this operation (" + getKind()
+ ")");
- LazyMethodGen freshMethod = createShadowMethodGen(newMethodName, visibilityModifier);
+ LazyMethodGen freshMethod = createShadowMethodGen(extractedMethodName, extractedMethodVisibilityModifier);
// System.err.println("******");
// System.err.println("ABOUT TO EXTRACT METHOD for" + this);
if (getKind() == PreInitialization) {
addPreInitializationReturnCode(freshMethod, getSuperConstructorParameterTypes());
}
- getEnclosingClass().addMethodGen(freshMethod, munger.getSourceLocation());
+ getEnclosingClass().addMethodGen(freshMethod, adviceSourceLocation);
return freshMethod;
}
public boolean implementOn(Shadow s) {
BcelShadow shadow = (BcelShadow) s;
- LazyMethodGen newMethod = shadow.extractMethod(
- NameMangler.getExtractableName(shadow.getSignature()) + "_extracted", 0, this);
+ LazyMethodGen newMethod = shadow.extractShadowInstructionsIntoNewMethod(NameMangler.getExtractableName(shadow
+ .getSignature())
+ + "_extracted", 0, this.getSourceLocation());
shadow.getRange().append(shadow.makeCallToCallback(newMethod));
if (!shadow.isFallsThrough()) {
public boolean implementOn(Shadow s) {
BcelShadow shadow = (BcelShadow) s;
- LazyMethodGen newMethod = shadow.extractMethod(NameMangler.getExtractableName(shadow.getSignature()) + "_extracted"
- + counter++, 0, this);
+ LazyMethodGen newMethod = shadow.extractShadowInstructionsIntoNewMethod(NameMangler.getExtractableName(shadow
+ .getSignature())
+ + "_extracted" + counter++, 0, this.getSourceLocation());
shadow.getRange().append(shadow.makeCallToCallback(newMethod));
if (!shadow.isFallsThrough()) {