01: /**************************************************************************************
02: * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
03: * http://aspectwerkz.codehaus.org *
04: * ---------------------------------------------------------------------------------- *
05: * The software in this package is published under the terms of the LGPL license *
06: * a copy of which has been included with this distribution in the license.txt file. *
07: **************************************************************************************/package org.codehaus.aspectwerkz.transform.inlining.compiler;
08:
09: import org.objectweb.asm.CodeVisitor;
10: import org.objectweb.asm.Type;
11: import org.codehaus.aspectwerkz.transform.inlining.AsmHelper;
12:
13: /**
14: * Redefines the existing join point class and turns it into a delegation class delegating to the newly created
15: * replacement join point class.
16: *
17: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
18: */
19: public class MethodCallJoinPointRedefiner extends
20: MethodCallJoinPointCompiler {
21: /**
22: * The redefined model.
23: */
24: private final CompilationInfo.Model m_redefinedModel;
25:
26: /**
27: * Creates a new join point compiler instance.
28: *
29: * @param model
30: */
31: MethodCallJoinPointRedefiner(final CompilationInfo model) {
32: super (model.getInitialModel());
33: m_redefinedModel = model.getRedefinedModel();
34: }
35:
36: /**
37: * Creates the 'invoke' method.
38: */
39: protected void createInvokeMethod() {
40: String invokeDesc = buildInvokeMethodSignature();
41: CodeVisitor cv = m_cw.visitMethod(ACC_PUBLIC + ACC_FINAL
42: + ACC_STATIC, INVOKE_METHOD_NAME, invokeDesc,
43: new String[] { THROWABLE_CLASS_NAME }, null);
44: AsmHelper.loadArgumentTypes(cv, Type
45: .getArgumentTypes(invokeDesc), true);
46: cv.visitMethodInsn(INVOKESTATIC, m_redefinedModel
47: .getJoinPointClassName(), INVOKE_METHOD_NAME,
48: invokeDesc);
49: AsmHelper
50: .addReturnStatement(cv, Type.getReturnType(invokeDesc));
51: cv.visitMaxs(0, 0);
52: }
53:
54: /**
55: * Creates the 'invoke' method.
56: */
57: protected void createInlinedInvokeMethod() {
58: createInvokeMethod();
59: }
60:
61: }
|