org.codehaus.aspectwerkz.transform.inlining.compiler
Class AbstractJoinPointCompiler

java.lang.Object
  extended by org.codehaus.aspectwerkz.transform.inlining.compiler.AbstractJoinPointCompiler
All Implemented Interfaces:
Compiler, TransformationConstants, org.objectweb.asm.Constants
Direct Known Subclasses:
ConstructorCallJoinPointCompiler, ConstructorExecutionJoinPointCompiler, FieldGetJoinPointCompiler, FieldSetJoinPointCompiler, HandlerJoinPointCompiler, MethodCallJoinPointCompiler, MethodExecutionJoinPointCompiler, StaticInitializationJoinPointCompiler

public abstract class AbstractJoinPointCompiler
extends Object
implements Compiler, TransformationConstants

Abstract base class for the different join point compiler implementations.

Compiles/generates a class that represents a specific join point, a class which invokes the advices and the target join point statically.

FIXME: depending on hotswap needs, remove the implements StaticJP or JP decision FIXME: remove isOptimizedJP and put it global

Author:
Jonas BonŽr , Alexandre Vasseur , Alex Popescu

Field Summary
protected static String DUMP_DIR
           
static boolean DUMP_JIT_CLASSES
           
protected  AdviceMethodInfo[] m_afterFinallyAdviceMethodInfos
           
protected  AdviceMethodInfo[] m_afterReturningAdviceMethodInfos
           
protected  AdviceMethodInfo[] m_afterThrowingAdviceMethodInfos
           
protected  org.objectweb.asm.Type[] m_argumentTypes
           
protected  AdviceMethodInfo[] m_aroundAdviceMethodInfos
           
protected  AspectInfo[] m_aspectInfos
           
protected  AspectModel[] m_aspectModels
           
protected  AdviceMethodInfo[] m_beforeAdviceMethodInfos
           
protected  String m_calleeClassName
           
protected  String m_calleeClassSignature
           
protected  String m_calleeMemberDesc
           
protected  int m_calleeMemberModifiers
           
protected  String m_calleeMemberName
           
protected  String m_callerClassName
           
protected  String m_callerClassSignature
           
protected  String m_callerMethodDesc
           
protected  int m_callerMethodModifiers
           
protected  String m_callerMethodName
           
protected  List m_customProceedMethodStructs
           
protected  org.objectweb.asm.ClassWriter m_cw
           
protected  String[] m_fieldNames
           
protected  boolean m_hasAroundAdvices
           
protected  boolean m_isThisAdvisable
           
protected  String m_joinPointClassName
           
protected  int m_joinPointHash
           
protected  int m_joinPointType
           
protected  boolean m_requiresJoinPoint
           
protected  boolean m_requiresThisOrTarget
           
protected  org.objectweb.asm.Type m_returnType
           
protected static String TARGET_CLASS_FIELD_NAME
           
protected static String THIS_CLASS_FIELD_NAME
           
 
Fields inherited from interface org.codehaus.aspectwerkz.transform.TransformationConstants
ADD_META_DATA_METHOD_NAME, ADD_META_DATA_METHOD_SIGNATURE, ADVISABLE_CLASS_JAVA_NAME, ADVISABLE_CLASS_NAME, AFTER_ADVICE_ARRAY_CLASS_SIGNATURE, AFTER_ADVICE_CLASS_NAME, AFTER_ADVICE_INVOKE_METHOD_SIGNATURE, AFTER_INTERCEPTORS_FIELD_NAME, AFTER_RETURNING_ADVICE_ARRAY_CLASS_SIGNATURE, AFTER_RETURNING_ADVICE_CLASS_NAME, AFTER_RETURNING_ADVICE_INVOKE_METHOD_SIGNATURE, AFTER_RETURNING_INTERCEPTORS_FIELD_NAME, AFTER_THROWING_ADVICE_ARRAY_CLASS_SIGNATURE, AFTER_THROWING_ADVICE_CLASS_NAME, AFTER_THROWING_ADVICE_INVOKE_METHOD_SIGNATURE, AFTER_THROWING_INTERCEPTORS_FIELD_NAME, ARGUMENT_FIELD, AROUND_ADVICE_ARRAY_CLASS_SIGNATURE, AROUND_ADVICE_CLASS_NAME, AROUND_ADVICE_INVOKE_METHOD_SIGNATURE, AROUND_INTERCEPTORS_FIELD_NAME, ASPECT_FIELD_PREFIX, ASPECT_OF_METHOD_NAME, ASPECT_OF_PER_CLASS_METHOD_SIGNATURE, ASPECT_OF_PER_INSTANCE_METHOD_SIGNATURE, ASPECT_OF_PER_JVM_METHOD_SIGNATURE, ASPECTS_CLASS_NAME, ASPECTWERKZ_PREFIX, BEFORE_ADVICE_ARRAY_CLASS_SIGNATURE, BEFORE_ADVICE_CLASS_NAME, BEFORE_ADVICE_INVOKE_METHOD_SIGNATURE, BEFORE_INTERCEPTORS_FIELD_NAME, BOOLEAN_CLASS_INIT_METHOD_SIGNATURE, BOOLEAN_CLASS_NAME, BOOLEAN_VALUE_METHOD_NAME, BOOLEAN_VALUE_METHOD_SIGNATURE, BYTE_CLASS_INIT_METHOD_SIGNATURE, BYTE_CLASS_NAME, BYTE_VALUE_METHOD_NAME, BYTE_VALUE_METHOD_SIGNATURE, CALLEE_INSTANCE_FIELD_NAME, CALLER_INSTANCE_FIELD_NAME, CHAR_VALUE_METHOD_NAME, CHAR_VALUE_METHOD_SIGNATURE, CHARACTER_CLASS_INIT_METHOD_SIGNATURE, CHARACTER_CLASS_NAME, CLASS_CLASS, CLASS_CLASS_GETCLASSLOADER_METHOD_SIGNATURE, CLASS_CLASS_SIGNATURE, CLASS_LOADER_CLASS_NAME, CLASS_LOADER_REFLECT_CLASS_NAME, CLASS_NOT_FOUND_EXCEPTION_CLASS_NAME, CLINIT_METHOD_NAME, CLINIT_METHOD_SIGNATURE, CONSTRUCTOR_RTTI_IMPL_CLASS_NAME, CONSTRUCTOR_RTTI_IMPL_CLASS_SIGNATURE, CONSTRUCTOR_RTTI_IMPL_INIT_SIGNATURE, CONSTRUCTOR_SIGNATURE_IMPL_CLASS_SIGNATURE, COPY_METHOD_NAME, COPY_METHOD_SIGNATURE, DEFINE_CLASS_METHOD_NAME, DELIMITER, DOUBLE_CLASS_INIT_METHOD_SIGNATURE, DOUBLE_CLASS_NAME, DOUBLE_VALUE_METHOD_NAME, DOUBLE_VALUE_METHOD_SIGNATURE, EMITTED_JOINPOINTS_FIELD_NAME, EMPTY_WRAPPER_ATTRIBUTE_VALUE_EMPTY, EMPTY_WRAPPER_ATTRIBUTE_VALUE_NOTEMPTY, EMTPTY_ARRAY_LIST, ENCLOSING_SJP_FIELD_CLASS_SIGNATURE, ENCLOSING_SJP_FIELD_NAME, FIELD_RTTI_IMPL_CLASS_NAME, FIELD_RTTI_IMPL_CLASS_SIGNATURE, FIELD_RTTI_IMPL_INIT_SIGNATURE, FIELD_SIGNATURE_IMPL_CLASS_SIGNATURE, FLOAT_CLASS_INIT_METHOD_SIGNATURE, FLOAT_CLASS_NAME, FLOAT_VALUE_METHOD_NAME, FLOAT_VALUE_METHOD_SIGNATURE, FOR_NAME_METHOD_NAME, FOR_NAME_METHOD_SIGNATURE, GET_AFTER_ADVICE_METHOD_NAME, GET_AFTER_ADVICE_METHOD_SIGNATURE, GET_AFTER_RETURNING_ADVICE_METHOD_NAME, GET_AFTER_RETURNING_ADVICE_METHOD_SIGNATURE, GET_AFTER_THROWING_ADVICE_METHOD_NAME, GET_AFTER_THROWING_ADVICE_METHOD_SIGNATURE, GET_AROUND_ADVICE_METHOD_NAME, GET_AROUND_ADVICE_METHOD_SIGNATURE, GET_BEFORE_ADVICE_METHOD_NAME, GET_BEFORE_ADVICE_METHOD_SIGNATURE, GET_CALLEE_CLASS_METHOD_NAME, GET_CALLEE_CLASS_METHOD_SIGNATURE, GET_CALLEE_METHOD_NAME, GET_CALLER_CLASS_METHOD_NAME, GET_CALLER_CLASS_METHOD_SIGNATURE, GET_CALLER_METHOD_NAME, GET_CFLOW_STACK_METHOD_NAME, GET_CFLOW_STACK_METHOD_SIGNATURE, GET_ENCLOSING_SJP_METHOD_NAME, GET_ENCLOSING_SJP_METHOD_SIGNATURE, GET_INSTANCE_LEVEL_ASPECT_METHOD_NAME, GET_INSTANCE_LEVEL_ASPECT_METHOD_SIGNATURE, GET_META_DATA_METHOD_NAME, GET_META_DATA_METHOD_SIGNATURE, GET_METHOD_NAME, GET_METHOD_SIGNATURE, GET_RTTI_METHOD_NAME, GET_RTTI_METHOD_SIGNATURE, GET_SIGNATURE_METHOD_NAME, GET_SIGNATURE_METHOD_SIGNATURE, GET_TARGET_CLASS_METHOD_NAME, GET_TARGET_CLASS_METHOD_SIGNATURE, GET_TARGET_METHOD_NAME, GET_THIS_METHOD_NAME, GET_TYPE_METHOD_NAME, GET_TYPE_METHOD_SIGNATURE, GETCLASSLOADER_METHOD_NAME, GETFIELD_WRAPPER_METHOD_PREFIX, HANDLER_RTTI_IMPL_CLASS_NAME, HANDLER_RTTI_IMPL_CLASS_SIGNATURE, HANDLER_RTTI_IMPL_INIT_SIGNATURE, HANDLER_SIGNATURE_IMPL_CLASS_SIGNATURE, HAS_INSTANCE_LEVEL_ASPECT_INTERFACE_NAME, HASH_MAP_CLASS_NAME, I, INDEX_NOTAVAILABLE, INIT_JOIN_POINTS_METHOD_NAME, INIT_METHOD_NAME, INSTANCE_LEVEL_ASPECT_MAP_FIELD_NAME, INSTANCE_LEVEL_ASPECT_MAP_FIELD_SIGNATURE, INT_VALUE_METHOD_NAME, INT_VALUE_METHOD_SIGNATURE, INTEGER_CLASS_INIT_METHOD_SIGNATURE, INTEGER_CLASS_NAME, INTERCEPT_INVOKE_METHOD_NAME, INTERCEPTOR_INDEX_FIELD_NAME, INVOKE_METHOD_NAME, INVOKE_WRAPPER_METHOD_PREFIX, IS_IN_CFLOW_METOD_NAME, IS_IN_CFLOW_METOD_SIGNATURE, JOIN_POINT_CLASS_NAME, JOIN_POINT_CLASS_SIGNATURE, JOIN_POINT_CLASS_SUFFIX, JOIN_POINT_JAVA_CLASS_NAME, JOIN_POINT_MANAGER_CLASS_NAME, L, LOAD_JOIN_POINT_METHOD_NAME, LOAD_JOIN_POINT_METHOD_SIGNATURE, LONG_CLASS_INIT_METHOD_SIGNATURE, LONG_CLASS_NAME, LONG_VALUE_METHOD_NAME, LONG_VALUE_METHOD_SIGNATURE, MAP_CLASS_NAME, MAP_CLASS_SIGNATURE, META_DATA_FIELD_NAME, METHOD_RTTI_IMPL_CLASS_NAME, METHOD_RTTI_IMPL_CLASS_SIGNATURE, METHOD_RTTI_IMPL_INIT_SIGNATURE, METHOD_SIGNATURE_IMPL_CLASS_NAME, METHOD_SIGNATURE_IMPL_CLASS_SIGNATURE, MIXIN_FIELD_NAME, MIXIN_OF_METHOD_NAME, MIXIN_OF_METHOD_PER_CLASS_SIGNATURE, MIXIN_OF_METHOD_PER_INSTANCE_SIGNATURE, MIXIN_OF_METHOD_PER_JVM_SIGNATURE, MIXINS_CLASS_NAME, MODIFIER_INVOKEINTERFACE, NEW_CATCH_CLAUSE_SIGNATURE_METHOD_NAME, NEW_CONSTRUCTOR_SIGNATURE_METHOD_NAME, NEW_CONSTRUCTOR_SIGNATURE_METHOD_SIGNATURE, NEW_ENCLOSING_SJP_METHOD_NAME, NEW_ENCLOSING_SJP_METHOD_SIGNATURE, NEW_FIELD_SIGNATURE_METHOD_NAME, NEW_FIELD_SIGNATURE_METHOD_SIGNATURE, NEW_HANDLER_SIGNATURE_METHOD_SIGNATURE, NEW_METHOD_SIGNATURE_METHOD_NAME, NEW_METHOD_SIGNATURE_METHOD_SIGNATURE, NEW_STATICINITIALIZATION_SIGNATURE_METHOD_NAME, NEW_STATICINITIALIZATION_SIGNATURE_METHOD_SIGNATURE, NO_PARAM_RETURN_VOID_SIGNATURE, NO_PARAMS_RETURN_VOID_METHOD_SIGNATURE, NO_PARAMS_SIGNATURE, NON_OPTIMIZED_JOIN_POINT, NR_OF_AFTER_INTERCEPTORS_FIELD_NAME, NR_OF_AFTER_RETURNING_INTERCEPTORS_FIELD_NAME, NR_OF_AFTER_THROWING_INTERCEPTORS_FIELD_NAME, NR_OF_AROUND_INTERCEPTORS_FIELD_NAME, NR_OF_BEFORE_INTERCEPTORS_FIELD_NAME, OBJECT_CLASS_NAME, OBJECT_CLASS_SIGNATURE, OPTIMIZED_JOIN_POINT, OPTIMIZED_JOIN_POINT_INSTANCE_FIELD_NAME, ORIGINAL_METHOD_PREFIX, PROCEED_METHOD_NAME, PROCEED_METHOD_SIGNATURE, PUT_METHOD_NAME, PUT_METHOD_SIGNATURE, PUTFIELD_WRAPPER_METHOD_PREFIX, RESET_METHOD_NAME, RETURN_VALUE_FIELD_NAME, RUNTIME_EXCEPTION_CLASS_NAME, RUNTIME_EXCEPTION_INIT_METHOD_SIGNATURE, SEMICOLON, SERIAL_VERSION_UID_FIELD_NAME, SET_FIELD_VALUE_METHOD_NAME, SET_FIELD_VALUE_METHOD_SIGNATURE, SET_PARAMETER_VALUE_METHOD_NAME, SET_PARAMETER_VALUE_METHOD_SIGNATURE, SET_PARAMETER_VALUES_METHOD_NAME, SET_PARAMETER_VALUES_METHOD_SIGNATURE, SET_RETURN_VALUE_METHOD_NAME, SET_RETURN_VALUE_METHOD_SIGNATURE, SHORT_CLASS_INIT_METHOD_SIGNATURE, SHORT_CLASS_NAME, SHORT_VALUE_METHOD_NAME, SHORT_VALUE_METHOD_SIGNATURE, SIGNATURE_FACTORY_CLASS, SIGNATURE_FIELD_NAME, STACK_FRAME_COUNTER_FIELD_NAME, STATIC_INITIALIZATION_METHOD_NAME, STATIC_JOIN_POINT_CLASS_NAME, STATIC_JOIN_POINT_JAVA_CLASS_NAME, STATICINITIALIZATION_RTTI_IMPL_CLASS_NAME, STATICINITIALIZATION_RTTI_IMPL_INIT_SIGNATURE, STATICINITIALIZATION_SIGNATURE_IMPL_CLASS_NAME, STATICINITIALIZATION_SIGNATURE_IMPL_CLASS_SIGNATURE, STATICINITIALIZER_WRAPPER_METHOD_KEY, SYNTHETIC_MEMBER_PREFIX, THROWABLE_CLASS_NAME, WRAPPER_METHOD_PREFIX
 
Fields inherited from interface org.objectweb.asm.Constants
AALOAD, AASTORE, ACC_ABSTRACT, ACC_ANNOTATION, ACC_BRIDGE, ACC_DEPRECATED, ACC_ENUM, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_SYNTHETIC, ACC_TRANSIENT, ACC_VARARGS, ACC_VOLATILE, ACONST_NULL, ALOAD, ANEWARRAY, ARETURN, ARRAYLENGTH, ASTORE, ATHROW, BALOAD, BASTORE, BIPUSH, CALOAD, CASTORE, CHECKCAST, D2F, D2I, D2L, DADD, DALOAD, DASTORE, DCMPG, DCMPL, DCONST_0, DCONST_1, DDIV, DLOAD, DMUL, DNEG, DREM, DRETURN, DSTORE, DSUB, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, F2D, F2I, F2L, FADD, FALOAD, FASTORE, FCMPG, FCMPL, FCONST_0, FCONST_1, FCONST_2, FDIV, FLOAD, FMUL, FNEG, FREM, FRETURN, FSTORE, FSUB, GETFIELD, GETSTATIC, GOTO, I2B, I2C, I2D, I2F, I2L, I2S, IADD, IALOAD, IAND, IASTORE, ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, ICONST_M1, IDIV, IF_ACMPEQ, IF_ACMPNE, IF_ICMPEQ, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ICMPLT, IF_ICMPNE, IFEQ, IFGE, IFGT, IFLE, IFLT, IFNE, IFNONNULL, IFNULL, IINC, ILOAD, IMUL, INEG, INSTANCEOF, INVOKEINTERFACE, INVOKESPECIAL, INVOKESTATIC, INVOKEVIRTUAL, IOR, IREM, IRETURN, ISHL, ISHR, ISTORE, ISUB, IUSHR, IXOR, JSR, L2D, L2F, L2I, LADD, LALOAD, LAND, LASTORE, LCMP, LCONST_0, LCONST_1, LDC, LDIV, LLOAD, LMUL, LNEG, LOOKUPSWITCH, LOR, LREM, LRETURN, LSHL, LSHR, LSTORE, LSUB, LUSHR, LXOR, MONITORENTER, MONITOREXIT, MULTIANEWARRAY, NEW, NEWARRAY, NOP, POP, POP2, PUTFIELD, PUTSTATIC, RET, RETURN, SALOAD, SASTORE, SIPUSH, SWAP, T_BOOLEAN, T_BYTE, T_CHAR, T_DOUBLE, T_FLOAT, T_INT, T_LONG, T_SHORT, TABLESWITCH, V1_1, V1_2, V1_3, V1_4, V1_5
 
Constructor Summary
AbstractJoinPointCompiler(CompilationInfo.Model model)
          Creates a new join point compiler instance.
 
Method Summary
protected  void addReturnedValueToJoinPoint(org.objectweb.asm.CodeVisitor cv, int returnValueIndex, int joinPointInstanceIndex, boolean unwrap)
          Adds the return value to the RETURNED field.
protected  org.objectweb.asm.Label beginRuntimeCheck(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int joinPointInstanceIndex, AdviceInfo adviceInfo, int calleeIndex)
          Handles the if case for runtime check (target instanceof, cflow)
protected  String buildInvokeMethodSignature()
          Build up the signature of the 'invoke' methods.
 byte[] compile()
          Compiles a join point class, one specific class for each distinct join point.
protected  void createAfterAdviceInvocation(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, AdviceMethodInfo adviceMethodInfo, int joinPointInstanceIndex, int argStartIndex, int callerIndex, int calleeIndex, int specialArgIndex)
          Adds a single generic after advice invocation.
protected  void createAfterFinallyAdviceInvocations(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int argStartIndex, int joinPointInstanceIndex, int callerIndex, int calleeIndex)
          Adds after advice invocations.
protected  void createAfterReturningAdviceInvocations(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int argStartIndex, int joinPointInstanceIndex, int callerIndex, int calleeIndex)
          Adds after returning advice invocations.
protected  boolean createAndInitializeAspectField(AspectInfo aspectInfo, org.objectweb.asm.CodeVisitor cv)
          Create and initialize the aspect field for a specific aspect (qualified since it depends on the param, deployment model, container etc).
protected  void createArgumentArrayAt(org.objectweb.asm.CodeVisitor cv, int stackFreeIndex)
          Create and load a structure (f.e. array of Object) where args are stored, before setting the Rtti with it (See addParametersToRttiInstance).
static void createAspectInstantiation(org.objectweb.asm.CodeVisitor cv, AspectInfo aspectInfo, String joinPointClassName)
          Creates instantiation of aspects using the Aspects.aspectOf() methods which uses the AspectContainer impls.
static void createAspectReferenceField(org.objectweb.asm.ClassWriter cw, AspectInfo aspectInfo)
          Creates aspect reference field (static or non static field).
protected  void createBeforeAdviceInvocations(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int argStartIndex, int joinPointInstanceIndex, int callerIndex, int calleeIndex)
          Adds before advice invocations.
protected  void createClinit()
          Creates the clinit method for the join point.
protected  void createCopyMethod()
          Creates the copy method.
protected  void createEnclosingStaticJoinPoint(org.objectweb.asm.CodeVisitor cv)
          Add and initialize the static field for enclosing joint point static part
protected  void createFieldsCommonToAllJoinPoints()
          Creates join point specific fields.
protected abstract  void createGetRttiMethod()
          Creates the getRtti method
protected abstract  void createGetSignatureMethod()
          Creates the getSignature method
protected  void createInit()
          Creates the init method for the join point.
protected abstract  void createInlinedJoinPointInvocation(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int argStartIndex, int joinPointIndex)
          Optimized implementation that does not retrieve the parameters from the join point instance but is passed directly to the method from the input parameters in the 'invoke' method.
protected  void createInvocationLocalJoinPointInstance(org.objectweb.asm.CodeVisitor cv, int argStartIndex, int joinPointInstanceIndex, int callerIndex, int calleeIndex)
          Creates an "invocation local" join point instance, e.g. one join point per invocation.
 void createInvocationToAspectOf(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int joinPointIndex, int callerIndex, int calleeIndex, AspectInfo aspectInfo)
          Creates an invocation to Aspects.aspectOf(..).
protected  void createInvocationToProceedMethod(org.objectweb.asm.CodeVisitor cv, int joinPointInstanceIndex, int returnValueIndex)
          Creates an invocation to the proceed method.
protected  void createInvokeMethod()
          Creates the 'invoke' method.
protected abstract  void createJoinPointInvocation(org.objectweb.asm.CodeVisitor cv)
          Creates a call to the target join point, the parameter(s) to the join point are retrieved from the invocation local join point instance.
protected abstract  void createJoinPointSpecificFields()
          Creates join point specific fields.
protected  void createPartOfInvokeMethodWithAllAdviceTypes(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int joinPointInstanceIndex, int argStartIndex, int callerIndex, int calleeIndex)
           
protected  void createPartOfInvokeMethodWithoutAfterFinallyAndAfterThrowingAdviceTypes(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int joinPointInstanceIndex, int argStartIndex, int callerIndex, int calleeIndex)
           
protected  void createPartOfInvokeMethodWithoutAfterThrowingAdviceTypes(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int joinPointInstanceIndex, int argStartIndex, int callerIndex, int calleeIndex)
           
protected  void createProceedMethod()
          Create the proceed() method.
protected abstract  void createSignature(org.objectweb.asm.CodeVisitor cv)
          Creates the signature for the join point.
protected  void createStaticInitializer()
          Creates the static initialization method (not clinit) for the join point.
protected  void createUtilityMethods()
          Creates utility methods for the join point (getter, setters etc.).
protected  void endRuntimeCheck(org.objectweb.asm.CodeVisitor cv, AdviceInfo adviceInfo, org.objectweb.asm.Label label)
          Ends the ifLabel of a runtime check
protected  AdviceMethodInfo[] getAdviceMethodInfos(List aspectQualifiedNames, Set aspectInfos, AdviceInfo[] adviceInfos)
          Retrieves the advice method infos.
protected abstract  org.objectweb.asm.Type[] getJoinPointArgumentTypes()
          Returns the join points argument type(s).
protected abstract  org.objectweb.asm.Type getJoinPointReturnType()
          Returns the join points return type.
protected  boolean hasArguments()
          Return the number of argument the joinpoint has (excludes JoinPoint, Rtti, this / target) but is only the number of argument we will have in the rtti (advised method/ctor args or 1 for field / handler)
protected  void incrementStackFrameCounter(org.objectweb.asm.CodeVisitor cv)
          Handles the incrementation of the stack frame.
protected  void initializeInstanceLevelAspects(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int joinPointIndex, int callerIndex, int calleeIndex)
          Initializes instance level aspects, retrieves them from the target instance through the HasInstanceLevelAspect interfaces.
protected  void loadArgumentMemberFields(org.objectweb.asm.CodeVisitor cv, int argStartIndex)
          Loads the argument member fields.
protected  void loadArguments(org.objectweb.asm.CodeVisitor cv)
          Loads the arguments.
protected  void loadAspect(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int joinPointIndex, AspectInfo aspectInfo)
          Loads the aspect instance.
 void loadCallee(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int joinPointIndex, int calleeIndex)
          Helper method to load the callee on the stack
protected  void loadCaller(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int joinPointIndex, int callerIndex)
          Helper method to load the caller on the stack
protected  void loadJoinPointInstance(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int joinPointInstanceIndex)
          Loads the join point instance, takes static/non-static join point access into account.
protected  boolean requiresJoinPoint()
          Checks if at least one advice is using the non static JoinPoint explicitly
protected  boolean requiresJoinPoint(AdviceMethodInfo[] adviceMethodInfos)
          Checks if at least one advice is using non static JoinPoint explicitly
protected  boolean requiresProceedMethod()
          Checks if the join point requires a proceed() method.
protected  boolean requiresThisOrTarget()
          Checks if at least one advice is using this or target (bounded or runtime check)
protected  boolean requiresThisOrTarget(AdviceMethodInfo[] adviceMethodInfos)
          Checks if at least one advice is using target or this (bounded or runtime check)
protected  void resetStackFrameCounter(org.objectweb.asm.CodeVisitor cv)
          Resets the stack frame counter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TARGET_CLASS_FIELD_NAME

protected static final String TARGET_CLASS_FIELD_NAME
See Also:
Constant Field Values

THIS_CLASS_FIELD_NAME

protected static final String THIS_CLASS_FIELD_NAME
See Also:
Constant Field Values

DUMP_JIT_CLASSES

public static final boolean DUMP_JIT_CLASSES
See Also:
Constant Field Values

DUMP_DIR

protected static final String DUMP_DIR
See Also:
Constant Field Values

m_callerClassName

protected final String m_callerClassName

m_calleeClassName

protected final String m_calleeClassName

m_callerClassSignature

protected final String m_callerClassSignature

m_calleeClassSignature

protected final String m_calleeClassSignature

m_joinPointClassName

protected final String m_joinPointClassName

m_joinPointType

protected final int m_joinPointType

m_joinPointHash

protected final int m_joinPointHash

m_callerMethodName

protected final String m_callerMethodName

m_callerMethodDesc

protected final String m_callerMethodDesc

m_callerMethodModifiers

protected final int m_callerMethodModifiers

m_calleeMemberName

protected final String m_calleeMemberName

m_calleeMemberDesc

protected final String m_calleeMemberDesc

m_calleeMemberModifiers

protected final int m_calleeMemberModifiers

m_cw

protected org.objectweb.asm.ClassWriter m_cw

m_aspectInfos

protected AspectInfo[] m_aspectInfos

m_aspectModels

protected AspectModel[] m_aspectModels

m_aroundAdviceMethodInfos

protected AdviceMethodInfo[] m_aroundAdviceMethodInfos

m_beforeAdviceMethodInfos

protected AdviceMethodInfo[] m_beforeAdviceMethodInfos

m_afterFinallyAdviceMethodInfos

protected AdviceMethodInfo[] m_afterFinallyAdviceMethodInfos

m_afterReturningAdviceMethodInfos

protected AdviceMethodInfo[] m_afterReturningAdviceMethodInfos

m_afterThrowingAdviceMethodInfos

protected AdviceMethodInfo[] m_afterThrowingAdviceMethodInfos

m_customProceedMethodStructs

protected final List m_customProceedMethodStructs

m_hasAroundAdvices

protected boolean m_hasAroundAdvices

m_requiresThisOrTarget

protected boolean m_requiresThisOrTarget

m_requiresJoinPoint

protected boolean m_requiresJoinPoint

m_fieldNames

protected String[] m_fieldNames

m_argumentTypes

protected org.objectweb.asm.Type[] m_argumentTypes

m_returnType

protected org.objectweb.asm.Type m_returnType

m_isThisAdvisable

protected boolean m_isThisAdvisable
Constructor Detail

AbstractJoinPointCompiler

public AbstractJoinPointCompiler(CompilationInfo.Model model)
Creates a new join point compiler instance.

Parameters:
model - the compilation model
Method Detail

getAdviceMethodInfos

protected AdviceMethodInfo[] getAdviceMethodInfos(List aspectQualifiedNames,
                                                  Set aspectInfos,
                                                  AdviceInfo[] adviceInfos)
Retrieves the advice method infos.

Parameters:
aspectQualifiedNames -
aspectInfos -
adviceInfos -
Returns:

createJoinPointSpecificFields

protected abstract void createJoinPointSpecificFields()
Creates join point specific fields.


createSignature

protected abstract void createSignature(org.objectweb.asm.CodeVisitor cv)
Creates the signature for the join point.

Parameters:
cv -

createInlinedJoinPointInvocation

protected abstract void createInlinedJoinPointInvocation(org.objectweb.asm.CodeVisitor cv,
                                                         boolean isOptimizedJoinPoint,
                                                         int argStartIndex,
                                                         int joinPointIndex)
Optimized implementation that does not retrieve the parameters from the join point instance but is passed directly to the method from the input parameters in the 'invoke' method. Can only be used if no around advice exists.

Parameters:
cv -
argStartIndex - index on stack of first target method arg (0 or 1, depends of static target or not)

createJoinPointInvocation

protected abstract void createJoinPointInvocation(org.objectweb.asm.CodeVisitor cv)
Creates a call to the target join point, the parameter(s) to the join point are retrieved from the invocation local join point instance.

Parameters:
cv -

getJoinPointReturnType

protected abstract org.objectweb.asm.Type getJoinPointReturnType()
Returns the join points return type.

Returns:

getJoinPointArgumentTypes

protected abstract org.objectweb.asm.Type[] getJoinPointArgumentTypes()
Returns the join points argument type(s).

Returns:

createGetRttiMethod

protected abstract void createGetRttiMethod()
Creates the getRtti method


createGetSignatureMethod

protected abstract void createGetSignatureMethod()
Creates the getSignature method


compile

public byte[] compile()
Compiles a join point class, one specific class for each distinct join point. The compiled join point class inherits the base join point class.

Specified by:
compile in interface Compiler
Returns:
the generated, compiled and loaded join point class

createFieldsCommonToAllJoinPoints

protected void createFieldsCommonToAllJoinPoints()
Creates join point specific fields.


createClinit

protected void createClinit()
Creates the clinit method for the join point.


createInit

protected void createInit()
Creates the init method for the join point.


createStaticInitializer

protected void createStaticInitializer()
Creates the static initialization method (not clinit) for the join point.


createEnclosingStaticJoinPoint

protected void createEnclosingStaticJoinPoint(org.objectweb.asm.CodeVisitor cv)
Add and initialize the static field for enclosing joint point static part

Parameters:
cv -

createAndInitializeAspectField

protected boolean createAndInitializeAspectField(AspectInfo aspectInfo,
                                                 org.objectweb.asm.CodeVisitor cv)
Create and initialize the aspect field for a specific aspect (qualified since it depends on the param, deployment model, container etc).

Parameters:
aspectInfo -
cv -

createAspectReferenceField

public static void createAspectReferenceField(org.objectweb.asm.ClassWriter cw,
                                              AspectInfo aspectInfo)
Creates aspect reference field (static or non static field).

Parameters:
cw -
aspectInfo -

createAspectInstantiation

public static void createAspectInstantiation(org.objectweb.asm.CodeVisitor cv,
                                             AspectInfo aspectInfo,
                                             String joinPointClassName)
Creates instantiation of aspects using the Aspects.aspectOf() methods which uses the AspectContainer impls. We are using the THIS_CLASS classloader since the aspect can be visible from that one only f.e. for get/set/call

Parameters:
cv -
aspectInfo -
joinPointClassName -

createInvokeMethod

protected void createInvokeMethod()
Creates the 'invoke' method. If possible delegates to the target join point directly, e.g. does not invoke the 'proceed' method (Used when a join point has zero around advice).


initializeInstanceLevelAspects

protected void initializeInstanceLevelAspects(org.objectweb.asm.CodeVisitor cv,
                                              boolean isOptimizedJoinPoint,
                                              int joinPointIndex,
                                              int callerIndex,
                                              int calleeIndex)
Initializes instance level aspects, retrieves them from the target instance through the HasInstanceLevelAspect interfaces.

Use by 'perInstance', 'perThis' and 'perTarget' deployment models.

Parameters:
cv -
isOptimizedJoinPoint -
joinPointIndex -
callerIndex -
calleeIndex -

createPartOfInvokeMethodWithAllAdviceTypes

protected void createPartOfInvokeMethodWithAllAdviceTypes(org.objectweb.asm.CodeVisitor cv,
                                                          boolean isOptimizedJoinPoint,
                                                          int joinPointInstanceIndex,
                                                          int argStartIndex,
                                                          int callerIndex,
                                                          int calleeIndex)
Parameters:
cv -
isOptimizedJoinPoint -
joinPointInstanceIndex -
argStartIndex -
callerIndex -
calleeIndex -

createPartOfInvokeMethodWithoutAfterThrowingAdviceTypes

protected void createPartOfInvokeMethodWithoutAfterThrowingAdviceTypes(org.objectweb.asm.CodeVisitor cv,
                                                                       boolean isOptimizedJoinPoint,
                                                                       int joinPointInstanceIndex,
                                                                       int argStartIndex,
                                                                       int callerIndex,
                                                                       int calleeIndex)
Parameters:
cv -
isOptimizedJoinPoint -
joinPointInstanceIndex -
argStartIndex -
callerIndex -
calleeIndex -

createPartOfInvokeMethodWithoutAfterFinallyAndAfterThrowingAdviceTypes

protected void createPartOfInvokeMethodWithoutAfterFinallyAndAfterThrowingAdviceTypes(org.objectweb.asm.CodeVisitor cv,
                                                                                      boolean isOptimizedJoinPoint,
                                                                                      int joinPointInstanceIndex,
                                                                                      int argStartIndex,
                                                                                      int callerIndex,
                                                                                      int calleeIndex)
Parameters:
cv -
isOptimizedJoinPoint -
joinPointInstanceIndex -
argStartIndex -
callerIndex -
calleeIndex -

createInvocationToProceedMethod

protected void createInvocationToProceedMethod(org.objectweb.asm.CodeVisitor cv,
                                               int joinPointInstanceIndex,
                                               int returnValueIndex)
Creates an invocation to the proceed method.

Parameters:
cv -
joinPointInstanceIndex -
returnValueIndex -

createInvocationLocalJoinPointInstance

protected void createInvocationLocalJoinPointInstance(org.objectweb.asm.CodeVisitor cv,
                                                      int argStartIndex,
                                                      int joinPointInstanceIndex,
                                                      int callerIndex,
                                                      int calleeIndex)
Creates an "invocation local" join point instance, e.g. one join point per invocation. Needed for thread-safety when invoking around advice.

Parameters:
cv -
argStartIndex - index on stack of first target method arg (0 or 1, depends of static target or not)
joinPointInstanceIndex -
callerIndex -
calleeIndex -

createProceedMethod

protected void createProceedMethod()
Create the proceed() method.


createBeforeAdviceInvocations

protected void createBeforeAdviceInvocations(org.objectweb.asm.CodeVisitor cv,
                                             boolean isOptimizedJoinPoint,
                                             int argStartIndex,
                                             int joinPointInstanceIndex,
                                             int callerIndex,
                                             int calleeIndex)
Adds before advice invocations.

Parameters:
cv -
isOptimizedJoinPoint -
argStartIndex - index on stack of first target method arg (0 or 1, depends of static target or not)
joinPointInstanceIndex - >= 0 if STATIC_JOIN_POINT is NOT to be used (around advice)
callerIndex -
calleeIndex -

createAfterFinallyAdviceInvocations

protected void createAfterFinallyAdviceInvocations(org.objectweb.asm.CodeVisitor cv,
                                                   boolean isOptimizedJoinPoint,
                                                   int argStartIndex,
                                                   int joinPointInstanceIndex,
                                                   int callerIndex,
                                                   int calleeIndex)
Adds after advice invocations.

Parameters:
cv -
isOptimizedJoinPoint -
argStartIndex - index on stack of first target method arg (0 or 1, depends of static target or not)
joinPointInstanceIndex - >= 0 if STATIC_JOIN_POINT is NOT to be used (around advice)
callerIndex -
calleeIndex -

createAfterReturningAdviceInvocations

protected void createAfterReturningAdviceInvocations(org.objectweb.asm.CodeVisitor cv,
                                                     boolean isOptimizedJoinPoint,
                                                     int argStartIndex,
                                                     int joinPointInstanceIndex,
                                                     int callerIndex,
                                                     int calleeIndex)
Adds after returning advice invocations.

Parameters:
cv -
isOptimizedJoinPoint -
argStartIndex - index on stack of first target method arg (0 or 1, depends of static target or not)
joinPointInstanceIndex - >= 0 if STATIC_JOIN_POINT is NOT to be used (around advice)
callerIndex -
calleeIndex -

createAfterAdviceInvocation

protected void createAfterAdviceInvocation(org.objectweb.asm.CodeVisitor cv,
                                           boolean isOptimizedJoinPoint,
                                           AdviceMethodInfo adviceMethodInfo,
                                           int joinPointInstanceIndex,
                                           int argStartIndex,
                                           int callerIndex,
                                           int calleeIndex,
                                           int specialArgIndex)
Adds a single generic after advice invocation.

Parameters:
cv -
isOptimizedJoinPoint -
adviceMethodInfo -
joinPointInstanceIndex -
argStartIndex -
callerIndex -
calleeIndex -
specialArgIndex - for afterReturning / Throwing when binding is used

addReturnedValueToJoinPoint

protected void addReturnedValueToJoinPoint(org.objectweb.asm.CodeVisitor cv,
                                           int returnValueIndex,
                                           int joinPointInstanceIndex,
                                           boolean unwrap)
Adds the return value to the RETURNED field.

Parameters:
cv -
returnValueIndex -
joinPointInstanceIndex -
unwrap - set to true if already wrapped on the stack (within proceed() code)

loadJoinPointInstance

protected void loadJoinPointInstance(org.objectweb.asm.CodeVisitor cv,
                                     boolean isOptimizedJoinPoint,
                                     int joinPointInstanceIndex)
Loads the join point instance, takes static/non-static join point access into account.

Parameters:
cv -
isOptimizedJoinPoint -
joinPointInstanceIndex -

loadArgumentMemberFields

protected void loadArgumentMemberFields(org.objectweb.asm.CodeVisitor cv,
                                        int argStartIndex)
Loads the argument member fields.

Parameters:
cv -
argStartIndex -

loadArguments

protected void loadArguments(org.objectweb.asm.CodeVisitor cv)
Loads the arguments.

Parameters:
cv -

resetStackFrameCounter

protected void resetStackFrameCounter(org.objectweb.asm.CodeVisitor cv)
Resets the stack frame counter.

Parameters:
cv -

incrementStackFrameCounter

protected void incrementStackFrameCounter(org.objectweb.asm.CodeVisitor cv)
Handles the incrementation of the stack frame.

Parameters:
cv -

createArgumentArrayAt

protected final void createArgumentArrayAt(org.objectweb.asm.CodeVisitor cv,
                                           int stackFreeIndex)
Create and load a structure (f.e. array of Object) where args are stored, before setting the Rtti with it (See addParametersToRttiInstance). The structure is stored at the given stackFreeIndex.

We provide here a default implementation that is suitable for method and constructor call and execution. See createParameterWrappedAt for field get/set and handler compiler (no array of argument needed)

Parameters:
cv -
stackFreeIndex -

createUtilityMethods

protected void createUtilityMethods()
Creates utility methods for the join point (getter, setters etc.).


createCopyMethod

protected void createCopyMethod()
Creates the copy method.

TODO refactor and put in subclasses


buildInvokeMethodSignature

protected String buildInvokeMethodSignature()
Build up the signature of the 'invoke' methods.

Returns:

hasArguments

protected final boolean hasArguments()
Return the number of argument the joinpoint has (excludes JoinPoint, Rtti, this / target) but is only the number of argument we will have in the rtti (advised method/ctor args or 1 for field / handler)

Returns:

requiresThisOrTarget

protected boolean requiresThisOrTarget()
Checks if at least one advice is using this or target (bounded or runtime check)

Returns:
true if so

requiresJoinPoint

protected boolean requiresJoinPoint()
Checks if at least one advice is using the non static JoinPoint explicitly

Returns:
true if so

requiresThisOrTarget

protected boolean requiresThisOrTarget(AdviceMethodInfo[] adviceMethodInfos)
Checks if at least one advice is using target or this (bounded or runtime check)

Parameters:
adviceMethodInfos -
Returns:
true if so

requiresJoinPoint

protected boolean requiresJoinPoint(AdviceMethodInfo[] adviceMethodInfos)
Checks if at least one advice is using non static JoinPoint explicitly

Parameters:
adviceMethodInfos -
Returns:
true if so

beginRuntimeCheck

protected org.objectweb.asm.Label beginRuntimeCheck(org.objectweb.asm.CodeVisitor cv,
                                                    boolean isOptimizedJoinPoint,
                                                    int joinPointInstanceIndex,
                                                    AdviceInfo adviceInfo,
                                                    int calleeIndex)
Handles the if case for runtime check (target instanceof, cflow)

Parameters:
cv -
isOptimizedJoinPoint -
joinPointInstanceIndex -
adviceInfo -
Returns:
the label for endIf or null if the adviceInfo did not required runtime check

endRuntimeCheck

protected void endRuntimeCheck(org.objectweb.asm.CodeVisitor cv,
                               AdviceInfo adviceInfo,
                               org.objectweb.asm.Label label)
Ends the ifLabel of a runtime check

Parameters:
cv -
adviceInfo -
label - if null, then do nothing (means we did not had a runtime check)

loadCallee

public void loadCallee(org.objectweb.asm.CodeVisitor cv,
                       boolean isOptimizedJoinPoint,
                       int joinPointIndex,
                       int calleeIndex)
Helper method to load the callee on the stack

Parameters:
cv -
isOptimizedJoinPoint -
joinPointIndex -
calleeIndex -

loadCaller

protected void loadCaller(org.objectweb.asm.CodeVisitor cv,
                          boolean isOptimizedJoinPoint,
                          int joinPointIndex,
                          int callerIndex)
Helper method to load the caller on the stack

Parameters:
cv -
isOptimizedJoinPoint -
joinPointIndex -
callerIndex -

loadAspect

protected void loadAspect(org.objectweb.asm.CodeVisitor cv,
                          boolean isOptimizedJoinPoint,
                          int joinPointIndex,
                          AspectInfo aspectInfo)
Loads the aspect instance.

Parameters:
cv -
isOptimizedJoinPoint -
joinPointIndex -
aspectInfo -

createInvocationToAspectOf

public void createInvocationToAspectOf(org.objectweb.asm.CodeVisitor cv,
                                       boolean isOptimizedJoinPoint,
                                       int joinPointIndex,
                                       int callerIndex,
                                       int calleeIndex,
                                       AspectInfo aspectInfo)
Creates an invocation to Aspects.aspectOf(..).

Parameters:
cv -
isOptimizedJoinPoint -
joinPointIndex -
callerIndex -
calleeIndex -
aspectInfo -

requiresProceedMethod

protected boolean requiresProceedMethod()
Checks if the join point requires a proceed() method.

Returns:


Copyright © 2002-2005 Jonas Bonér, Alexandre Vasseur. All Rights Reserved.