KickJava   Java API By Example, From Geeks To Geeks.

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


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 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 JavaDoc invokeDesc = buildInvokeMethodSignature();
38     MethodVisitor cv = m_cw.visitMethod(
39             ACC_PUBLIC + ACC_FINAL + ACC_STATIC,
40             INVOKE_METHOD_NAME,
41             invokeDesc,
42             null,
43             new String JavaDoc[]{
44                     THROWABLE_CLASS_NAME
45             }
46     );
47     AsmHelper.loadArgumentTypes(cv, Type.getArgumentTypes(invokeDesc), true);
48     cv.visitMethodInsn(INVOKESTATIC, m_redefinedModel.getJoinPointClassName(), INVOKE_METHOD_NAME, invokeDesc);
49     AsmHelper.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 }
60
Popular Tags