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 HandlerJoinPointRedefiner extends HandlerJoinPointCompiler {
20: /**
21: * The redefined model.
22: */
23: private final CompilationInfo.Model m_redefinedModel;
24:
25: /**
26: * Creates a new join point compiler instance.
27: *
28: * @param model
29: */
30: HandlerJoinPointRedefiner(final CompilationInfo model) {
31: super (model.getInitialModel());
32: m_redefinedModel = model.getRedefinedModel();
33: }
34:
35: /**
36: * Creates the 'invoke' method.
37: */
38: protected void createInvokeMethod() {
39: String invokeDesc = buildInvokeMethodSignature();
40: CodeVisitor cv = m_cw.visitMethod(ACC_PUBLIC + ACC_FINAL
41: + ACC_STATIC, INVOKE_METHOD_NAME, invokeDesc,
42: new String[] { THROWABLE_CLASS_NAME }, null);
43: AsmHelper.loadArgumentTypes(cv, Type
44: .getArgumentTypes(invokeDesc), true);
45: cv.visitMethodInsn(INVOKESTATIC, m_redefinedModel
46: .getJoinPointClassName(), INVOKE_METHOD_NAME,
47: invokeDesc);
48: AsmHelper
49: .addReturnStatement(cv, Type.getReturnType(invokeDesc));
50: cv.visitMaxs(0, 0);
51: }
52:
53: /**
54: * Creates the 'invoke' method.
55: */
56: protected void createInlinedInvokeMethod() {
57: createInvokeMethod();
58: }
59: }
|