|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.aspectwerkz.transform.inlining.compiler.AbstractJoinPointCompiler
public abstract class AbstractJoinPointCompiler
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
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 |
---|
protected static final String TARGET_CLASS_FIELD_NAME
protected static final String THIS_CLASS_FIELD_NAME
public static final boolean DUMP_JIT_CLASSES
protected static final String DUMP_DIR
protected final String m_callerClassName
protected final String m_calleeClassName
protected final String m_callerClassSignature
protected final String m_calleeClassSignature
protected final String m_joinPointClassName
protected final int m_joinPointType
protected final int m_joinPointHash
protected final String m_callerMethodName
protected final String m_callerMethodDesc
protected final int m_callerMethodModifiers
protected final String m_calleeMemberName
protected final String m_calleeMemberDesc
protected final int m_calleeMemberModifiers
protected org.objectweb.asm.ClassWriter m_cw
protected AspectInfo[] m_aspectInfos
protected AspectModel[] m_aspectModels
protected AdviceMethodInfo[] m_aroundAdviceMethodInfos
protected AdviceMethodInfo[] m_beforeAdviceMethodInfos
protected AdviceMethodInfo[] m_afterFinallyAdviceMethodInfos
protected AdviceMethodInfo[] m_afterReturningAdviceMethodInfos
protected AdviceMethodInfo[] m_afterThrowingAdviceMethodInfos
protected final List m_customProceedMethodStructs
protected boolean m_hasAroundAdvices
protected boolean m_requiresThisOrTarget
protected boolean m_requiresJoinPoint
protected String[] m_fieldNames
protected org.objectweb.asm.Type[] m_argumentTypes
protected org.objectweb.asm.Type m_returnType
protected boolean m_isThisAdvisable
Constructor Detail |
---|
public AbstractJoinPointCompiler(CompilationInfo.Model model)
model
- the compilation modelMethod Detail |
---|
protected AdviceMethodInfo[] getAdviceMethodInfos(List aspectQualifiedNames, Set aspectInfos, AdviceInfo[] adviceInfos)
aspectQualifiedNames
- aspectInfos
- adviceInfos
-
protected abstract void createJoinPointSpecificFields()
protected abstract void createSignature(org.objectweb.asm.CodeVisitor cv)
cv
- protected abstract void createInlinedJoinPointInvocation(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int argStartIndex, int joinPointIndex)
cv
- argStartIndex
- index on stack of first target method arg (0 or 1, depends of static target or not)protected abstract void createJoinPointInvocation(org.objectweb.asm.CodeVisitor cv)
cv
- protected abstract org.objectweb.asm.Type getJoinPointReturnType()
protected abstract org.objectweb.asm.Type[] getJoinPointArgumentTypes()
protected abstract void createGetRttiMethod()
protected abstract void createGetSignatureMethod()
public byte[] compile()
compile
in interface Compiler
protected void createFieldsCommonToAllJoinPoints()
protected void createClinit()
protected void createInit()
protected void createStaticInitializer()
protected void createEnclosingStaticJoinPoint(org.objectweb.asm.CodeVisitor cv)
cv
- protected boolean createAndInitializeAspectField(AspectInfo aspectInfo, org.objectweb.asm.CodeVisitor cv)
aspectInfo
- cv
- public static void createAspectReferenceField(org.objectweb.asm.ClassWriter cw, AspectInfo aspectInfo)
cw
- aspectInfo
- public static void createAspectInstantiation(org.objectweb.asm.CodeVisitor cv, AspectInfo aspectInfo, String joinPointClassName)
cv
- aspectInfo
- joinPointClassName
- protected void createInvokeMethod()
protected void initializeInstanceLevelAspects(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int joinPointIndex, int callerIndex, int calleeIndex)
HasInstanceLevelAspect
interfaces.
Use by 'perInstance', 'perThis' and 'perTarget' deployment models.
cv
- isOptimizedJoinPoint
- joinPointIndex
- callerIndex
- calleeIndex
- protected void createPartOfInvokeMethodWithAllAdviceTypes(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int joinPointInstanceIndex, int argStartIndex, int callerIndex, int calleeIndex)
cv
- isOptimizedJoinPoint
- joinPointInstanceIndex
- argStartIndex
- callerIndex
- calleeIndex
- protected void createPartOfInvokeMethodWithoutAfterThrowingAdviceTypes(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int joinPointInstanceIndex, int argStartIndex, int callerIndex, int calleeIndex)
cv
- isOptimizedJoinPoint
- joinPointInstanceIndex
- argStartIndex
- callerIndex
- calleeIndex
- protected void createPartOfInvokeMethodWithoutAfterFinallyAndAfterThrowingAdviceTypes(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int joinPointInstanceIndex, int argStartIndex, int callerIndex, int calleeIndex)
cv
- isOptimizedJoinPoint
- joinPointInstanceIndex
- argStartIndex
- callerIndex
- calleeIndex
- protected void createInvocationToProceedMethod(org.objectweb.asm.CodeVisitor cv, int joinPointInstanceIndex, int returnValueIndex)
cv
- joinPointInstanceIndex
- returnValueIndex
- protected void createInvocationLocalJoinPointInstance(org.objectweb.asm.CodeVisitor cv, int argStartIndex, int joinPointInstanceIndex, int callerIndex, int calleeIndex)
cv
- argStartIndex
- index on stack of first target method arg (0 or 1, depends of static target or
not)joinPointInstanceIndex
- callerIndex
- calleeIndex
- protected void createProceedMethod()
protected void createBeforeAdviceInvocations(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int argStartIndex, int joinPointInstanceIndex, int callerIndex, int calleeIndex)
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
- protected void createAfterFinallyAdviceInvocations(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int argStartIndex, int joinPointInstanceIndex, int callerIndex, int calleeIndex)
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
- protected void createAfterReturningAdviceInvocations(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int argStartIndex, int joinPointInstanceIndex, int callerIndex, int calleeIndex)
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
- protected void createAfterAdviceInvocation(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, AdviceMethodInfo adviceMethodInfo, int joinPointInstanceIndex, int argStartIndex, int callerIndex, int calleeIndex, int specialArgIndex)
cv
- isOptimizedJoinPoint
- adviceMethodInfo
- joinPointInstanceIndex
- argStartIndex
- callerIndex
- calleeIndex
- specialArgIndex
- for afterReturning / Throwing when binding is usedprotected void addReturnedValueToJoinPoint(org.objectweb.asm.CodeVisitor cv, int returnValueIndex, int joinPointInstanceIndex, boolean unwrap)
cv
- returnValueIndex
- joinPointInstanceIndex
- unwrap
- set to true if already wrapped on the stack (within proceed() code)protected void loadJoinPointInstance(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int joinPointInstanceIndex)
cv
- isOptimizedJoinPoint
- joinPointInstanceIndex
- protected void loadArgumentMemberFields(org.objectweb.asm.CodeVisitor cv, int argStartIndex)
cv
- argStartIndex
- protected void loadArguments(org.objectweb.asm.CodeVisitor cv)
cv
- protected void resetStackFrameCounter(org.objectweb.asm.CodeVisitor cv)
cv
- protected void incrementStackFrameCounter(org.objectweb.asm.CodeVisitor cv)
cv
- protected final void createArgumentArrayAt(org.objectweb.asm.CodeVisitor cv, int stackFreeIndex)
cv
- stackFreeIndex
- protected void createUtilityMethods()
protected void createCopyMethod()
protected String buildInvokeMethodSignature()
protected final boolean hasArguments()
protected boolean requiresThisOrTarget()
protected boolean requiresJoinPoint()
protected boolean requiresThisOrTarget(AdviceMethodInfo[] adviceMethodInfos)
adviceMethodInfos
-
protected boolean requiresJoinPoint(AdviceMethodInfo[] adviceMethodInfos)
adviceMethodInfos
-
protected org.objectweb.asm.Label beginRuntimeCheck(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int joinPointInstanceIndex, AdviceInfo adviceInfo, int calleeIndex)
cv
- isOptimizedJoinPoint
- joinPointInstanceIndex
- adviceInfo
-
protected void endRuntimeCheck(org.objectweb.asm.CodeVisitor cv, AdviceInfo adviceInfo, org.objectweb.asm.Label label)
cv
- adviceInfo
- label
- if null, then do nothing (means we did not had a runtime check)public void loadCallee(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int joinPointIndex, int calleeIndex)
cv
- isOptimizedJoinPoint
- joinPointIndex
- calleeIndex
- protected void loadCaller(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int joinPointIndex, int callerIndex)
cv
- isOptimizedJoinPoint
- joinPointIndex
- callerIndex
- protected void loadAspect(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int joinPointIndex, AspectInfo aspectInfo)
cv
- isOptimizedJoinPoint
- joinPointIndex
- aspectInfo
- public void createInvocationToAspectOf(org.objectweb.asm.CodeVisitor cv, boolean isOptimizedJoinPoint, int joinPointIndex, int callerIndex, int calleeIndex, AspectInfo aspectInfo)
cv
- isOptimizedJoinPoint
- joinPointIndex
- callerIndex
- calleeIndex
- aspectInfo
- protected boolean requiresProceedMethod()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |