01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.aspectwerkz.transform.inlining.compiler;
05:
06: import com.tc.asm.MethodVisitor;
07: import com.tc.asm.Type;
08:
09: import com.tc.aspectwerkz.transform.inlining.AsmHelper;
10:
11: /**
12: * Redefines the existing join point class and turns it into a delegation class delegating to the newly created
13: * replacement join point class.
14: *
15: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
16: */
17: public class MethodExecutionJoinPointRedefiner extends
18: MethodExecutionJoinPointCompiler {
19:
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: MethodExecutionJoinPointRedefiner(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: MethodVisitor cv = m_cw.visitMethod(ACC_PUBLIC + ACC_FINAL
41: + ACC_STATIC, INVOKE_METHOD_NAME, invokeDesc, null,
42: new String[] { THROWABLE_CLASS_NAME });
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: }
|