KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > aspectwerkz > transform > inlining > compiler > MethodExecutionJoinPointRedefiner


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.aspectwerkz.transform.inlining.compiler;
5
6 import com.tc.asm.MethodVisitor;
7 import com.tc.asm.Type;
8
9 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 MethodExecutionJoinPointCompiler {
18
19   /**
20    * The redefined model.
21    */

22   private final CompilationInfo.Model m_redefinedModel;
23
24   /**
25    * Creates a new join point compiler instance.
26    *
27    * @param model
28    */

29   MethodExecutionJoinPointRedefiner(final CompilationInfo model) {
30     super(model.getInitialModel());
31     m_redefinedModel = model.getRedefinedModel();
32   }
33
34   /**
35    * Creates the 'invoke' method.
36    */

37   protected void createInvokeMethod() {
38     String JavaDoc invokeDesc = buildInvokeMethodSignature();
39     MethodVisitor cv = m_cw.visitMethod(
40             ACC_PUBLIC + ACC_FINAL + ACC_STATIC,
41             INVOKE_METHOD_NAME,
42             invokeDesc,
43             null,
44             new String JavaDoc[]{
45                     THROWABLE_CLASS_NAME
46             }
47     );
48     AsmHelper.loadArgumentTypes(cv, Type.getArgumentTypes(invokeDesc), true);
49     cv.visitMethodInsn(INVOKESTATIC, m_redefinedModel.getJoinPointClassName(), INVOKE_METHOD_NAME, invokeDesc);
50     AsmHelper.addReturnStatement(cv, Type.getReturnType(invokeDesc));
51     cv.visitMaxs(0, 0);
52   }
53
54   /**
55    * Creates the 'invoke' method.
56    */

57   protected void createInlinedInvokeMethod() {
58     createInvokeMethod();
59   }
60 }
61
Popular Tags