1 /***************************************************************************************
2 * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
3 * http://aspectwerkz.codehaus.org *
4 * ---------------------------------------------------------------------------------- *
5 * The software in this package is published under the terms of the LGPL license *
6 * a copy of which has been included with this distribution in the license.txt file. *
7 **************************************************************************************/
8 package org.codehaus.aspectwerkz.transform.inlining.compiler;
9
10 import org.objectweb.asm.CodeVisitor;
11 import org.objectweb.asm.Type;
12
13 import org.codehaus.aspectwerkz.transform.inlining.AsmHelper;
14
15 /***
16 * Redefines the existing join point class and turns it into a delegation class delegating to the newly created
17 * replacement join point class.
18 *
19 * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
20 */
21 public class MethodExecutionJoinPointRedefiner extends 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(
44 ACC_PUBLIC + ACC_FINAL + ACC_STATIC,
45 INVOKE_METHOD_NAME,
46 invokeDesc,
47 new String[]{
48 THROWABLE_CLASS_NAME
49 },
50 null
51 );
52 AsmHelper.loadArgumentTypes(cv, Type.getArgumentTypes(invokeDesc), true);
53 cv.visitMethodInsn(INVOKESTATIC, m_redefinedModel.getJoinPointClassName(), INVOKE_METHOD_NAME, invokeDesc);
54 AsmHelper.addReturnStatement(cv, Type.getReturnType(invokeDesc));
55 cv.visitMaxs(0, 0);
56 }
57
58 /***
59 * Creates the 'invoke' method.
60 */
61 protected void createInlinedInvokeMethod() {
62 createInvokeMethod();
63 }
64 }