KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > aspectwerkz > transform > inlining > compiler > FieldSetJoinPointRedefiner


1 /**************************************************************************************
2  * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
3  * http://aspectwerkz.codehaus.org *
4  * ---------------------------------------------------------------------------------- *
5  * The software in this package is published under the terms of the LGPL license *
6  * a copy of which has been included with this distribution in the license.txt file. *
7  **************************************************************************************/

8 package org.codehaus.aspectwerkz.transform.inlining.compiler;
9
10 import org.objectweb.asm.CodeVisitor;
11 import org.objectweb.asm.Type;
12 import org.codehaus.aspectwerkz.transform.inlining.AsmHelper;
13
14 /**
15  * Redefines the existing join point class and turns it into a delegation class delegating to the newly created
16  * replacement join point class.
17  *
18  * @author <a HREF="mailto:jboner@codehaus.org">Jonas BonŽr </a>
19  */

20 public class FieldSetJoinPointRedefiner extends FieldSetJoinPointCompiler {
21     /**
22      * The redefined model.
23      */

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

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

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

59     protected void createInlinedInvokeMethod() {
60         createInvokeMethod();
61     }
62
63 }
64
Popular Tags