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:
12: import org.codehaus.aspectwerkz.transform.inlining.AsmHelper;
13:
14: /**
15: * Redefines the existing join point class and turns it into a delegation class delegating to the newly created
16: * replacement join point class.
17: *
18: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
19: */
20: public class MethodExecutionJoinPointRedefiner extends
21: MethodExecutionJoinPointCompiler {
22:
23: /**
24: * The redefined model.
25: */
26: private final CompilationInfo.Model m_redefinedModel;
27:
28: /**
29: * Creates a new join point compiler instance.
30: *
31: * @param model
32: */
33: MethodExecutionJoinPointRedefiner(final CompilationInfo model) {
34: super (model.getInitialModel());
35: m_redefinedModel = model.getRedefinedModel();
36: }
37:
38: /**
39: * Creates the 'invoke' method.
40: */
41: protected void createInvokeMethod() {
42: String invokeDesc = buildInvokeMethodSignature();
43: CodeVisitor cv = m_cw.visitMethod(ACC_PUBLIC + ACC_FINAL
44: + ACC_STATIC, INVOKE_METHOD_NAME, invokeDesc,
45: new String[] { THROWABLE_CLASS_NAME }, null);
46: AsmHelper.loadArgumentTypes(cv, Type
47: .getArgumentTypes(invokeDesc), true);
48: cv.visitMethodInsn(INVOKESTATIC, m_redefinedModel
49: .getJoinPointClassName(), INVOKE_METHOD_NAME,
50: invokeDesc);
51: AsmHelper
52: .addReturnStatement(cv, Type.getReturnType(invokeDesc));
53: cv.visitMaxs(0, 0);
54: }
55:
56: /**
57: * Creates the 'invoke' method.
58: */
59: protected void createInlinedInvokeMethod() {
60: createInvokeMethod();
61: }
62: }
|