1 4 package com.tc.aspectwerkz.transform.inlining.weaver; 5 6 import com.tc.asm.MethodAdapter; 7 import com.tc.asm.MethodVisitor; 8 9 import com.tc.aspectwerkz.transform.TransformationConstants; 10 11 19 public class AfterObjectInitializationCodeAdapter extends MethodAdapter implements TransformationConstants { 20 21 private String m_callerMemberName; 22 private int m_newCount = 0; 23 private int m_invokeSpecialCount = 0; 24 protected boolean m_isObjectInitialized = false; 25 26 public AfterObjectInitializationCodeAdapter(MethodVisitor cv, String callerMemberName) { 27 super(cv); 28 m_callerMemberName = callerMemberName; 29 if (!m_callerMemberName.equals(INIT_METHOD_NAME)) { 31 m_isObjectInitialized = true; 32 } 33 } 34 35 public void visitTypeInsn(int opcode, String desc) { 36 if (opcode == NEW) { 37 m_newCount++; 38 } 39 super.visitTypeInsn(opcode, desc); 40 } 41 42 protected boolean queryCurrentMethodInsn(final int opcode, 43 final String calleeClassName, 44 final String calleeMethodName, 45 final String calleeMethodDesc) { 46 int localInvokeSpecialCount = m_invokeSpecialCount; 47 int localNewCount = m_newCount; 48 49 if (opcode == INVOKESPECIAL) { 50 localInvokeSpecialCount++; 51 } 52 53 if (m_callerMemberName.equals(INIT_METHOD_NAME)) { 54 if (opcode == INVOKESPECIAL) { 61 if (localNewCount == localInvokeSpecialCount - 1) { 62 return true; 63 } 64 } 65 return false; 66 } 67 return false; 68 } 69 70 public void visitMethodInsn(final int opcode, 71 final String calleeClassName, 72 final String calleeMethodName, 73 final String calleeMethodDesc) { 74 if (opcode == INVOKESPECIAL) { 75 m_invokeSpecialCount++; 76 } 77 78 if (m_callerMemberName.equals(INIT_METHOD_NAME)) { 79 if (opcode == INVOKESPECIAL) { 86 if (m_newCount == m_invokeSpecialCount - 1) { 87 m_isObjectInitialized = true; 88 } 89 } 90 } 91 super.visitMethodInsn(opcode, calleeClassName, calleeMethodName, calleeMethodDesc); 92 } 93 } 94 | Popular Tags |