1 4 package com.tc.aspectwerkz.transform.inlining.compiler; 5 6 7 import com.tc.asm.MethodVisitor; 8 import com.tc.asm.Type; 9 10 11 import com.tc.aspectwerkz.transform.TransformationUtil; 12 13 20 public class StaticInitializationJoinPointCompiler extends AbstractJoinPointCompiler { 21 private static final Type[] ARG_TYPES = new Type[0]; 22 23 28 StaticInitializationJoinPointCompiler(final CompilationInfo.Model model) { 29 super(model); 30 } 31 32 35 protected void createJoinPointSpecificFields() { 36 m_fieldNames = new String [0]; 37 38 m_cw.visitField(ACC_PRIVATE + ACC_STATIC, 39 SIGNATURE_FIELD_NAME, 40 STATICINITIALIZATION_SIGNATURE_IMPL_CLASS_SIGNATURE, 41 null, 42 null); 43 } 44 45 50 protected void createSignature(final MethodVisitor cv) { 51 cv.visitFieldInsn(GETSTATIC, 52 m_joinPointClassName, 53 TARGET_CLASS_FIELD_NAME_IN_JP, 54 CLASS_CLASS_SIGNATURE); 55 cv.visitMethodInsn(INVOKESTATIC, 56 SIGNATURE_FACTORY_CLASS, 57 NEW_STATICINITIALIZATION_SIGNATURE_METHOD_NAME, 58 NEW_STATICINITIALIZATION_SIGNATURE_METHOD_SIGNATURE); 59 cv.visitFieldInsn(PUTSTATIC, 60 m_joinPointClassName, 61 SIGNATURE_FIELD_NAME, 62 STATICINITIALIZATION_SIGNATURE_IMPL_CLASS_SIGNATURE); 63 } 64 65 74 protected void createInlinedJoinPointInvocation(final MethodVisitor cv, 75 final CompilerInput input) { 76 String joinPointName = TransformationUtil.getPrefixedOriginalClinitName(m_calleeClassName); 77 78 cv.visitMethodInsn(INVOKESTATIC, m_calleeClassName, joinPointName, m_calleeMemberDesc); 79 } 80 81 87 protected void createJoinPointInvocation(final MethodVisitor cv) { 88 89 String joinPointName = TransformationUtil.getPrefixedOriginalClinitName(m_calleeClassName); 91 cv.visitMethodInsn(INVOKESTATIC, m_calleeClassName, joinPointName, m_calleeMemberDesc); 92 } 93 94 99 protected Type getJoinPointReturnType() { 100 return Type.VOID_TYPE; 101 } 102 103 108 protected Type[] getJoinPointArgumentTypes() { 109 return ARG_TYPES; 110 } 111 112 115 protected void createGetRttiMethod() { 116 MethodVisitor cv = m_cw.visitMethod(ACC_PUBLIC, 117 GET_RTTI_METHOD_NAME, 118 GET_RTTI_METHOD_SIGNATURE, 119 null, 120 null 121 ); 122 123 cv.visitTypeInsn(NEW, STATICINITIALIZATION_RTTI_IMPL_CLASS_NAME); 125 cv.visitInsn(DUP); 126 cv.visitFieldInsn(GETSTATIC, 127 m_joinPointClassName, 128 SIGNATURE_FIELD_NAME, 129 STATICINITIALIZATION_SIGNATURE_IMPL_CLASS_SIGNATURE); 130 cv.visitMethodInsn(INVOKESPECIAL, 131 STATICINITIALIZATION_RTTI_IMPL_CLASS_NAME, 132 INIT_METHOD_NAME, 133 STATICINITIALIZATION_RTTI_IMPL_INIT_SIGNATURE 134 ); 135 136 cv.visitInsn(ARETURN); 137 cv.visitMaxs(0, 0); 138 } 139 140 143 protected void createGetSignatureMethod() { 144 MethodVisitor cv = m_cw.visitMethod(ACC_PUBLIC, 145 GET_SIGNATURE_METHOD_NAME, 146 GET_SIGNATURE_METHOD_SIGNATURE, 147 null, 148 null); 149 150 cv.visitFieldInsn(GETSTATIC, 151 m_joinPointClassName, 152 SIGNATURE_FIELD_NAME, 153 STATICINITIALIZATION_SIGNATURE_IMPL_CLASS_SIGNATURE); 154 cv.visitInsn(ARETURN); 155 cv.visitMaxs(0, 0); 156 } 157 } | Popular Tags |