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