org.aspectj.weaver.bcel
Class BcelShadow

java.lang.Object
  extended by org.aspectj.weaver.Shadow
      extended by org.aspectj.weaver.bcel.BcelShadow

public class BcelShadow
extends Shadow


Nested Class Summary
 
Nested classes/interfaces inherited from class org.aspectj.weaver.Shadow
Shadow.Kind
 
Field Summary
static boolean appliedLazyTjpOptimization
           
 
Fields inherited from class org.aspectj.weaver.Shadow
ADVICE_EXECUTION, AdviceExecution, AdviceExecutionBit, ALL_SHADOW_KINDS_BITS, CONSTRUCTOR_CALL, CONSTRUCTOR_EXECUTION, ConstructorCall, ConstructorCallBit, ConstructorExecution, ConstructorExecutionBit, EXCEPTION_HANDLER, ExceptionHandler, ExceptionHandlerBit, FIELD_GET, FIELD_SET, FieldGet, FieldGetBit, FieldSet, FieldSetBit, Initialization, INITIALIZATION, InitializationBit, MAX_SHADOW_KIND, METHOD_CALL, METHOD_EXECUTION, MethodCall, MethodCallBit, MethodExecution, MethodExecutionBit, NO_SHADOW_KINDS_BITS, PreInitialization, PREINITIALIZATION, PreInitializationBit, SHADOW_KINDS, shadowId, StaticInitialization, STATICINITIALIZATION, StaticInitializationBit, SYNCHRONIZATION_LOCK, SYNCHRONIZATION_UNLOCK, SynchronizationLock, SynchronizationLockBit, SynchronizationUnlock, SynchronizationUnlockBit
 
Constructor Summary
BcelShadow(BcelWorld world, Shadow.Kind kind, Member signature, LazyMethodGen enclosingMethod, BcelShadow enclosingShadow)
          This generates an unassociated shadow, rooted in a particular method but not rooted to any particular point in the code.
 
Method Summary
 void addAdvicePreventingLazyTjp(org.aspectj.weaver.bcel.BcelAdvice advice)
           
 boolean arg0HoldsThis()
          Is arg0 occupied with the value of this
 BcelShadow copyInto(LazyMethodGen recipient, BcelShadow enclosing)
           
 void ensureInitializedArgVar(int argNumber)
           
 UnresolvedType ensureTargetTypeIsCorrect(UnresolvedType tx)
           
 BcelVar genTempVar(UnresolvedType typeX)
           
 BcelVar genTempVar(UnresolvedType typeX, java.lang.String localName)
           
 java.lang.String getActualTargetType()
           
 Var getArgAnnotationVar(int i, UnresolvedType forAnnotationType)
           
 Var getArgVar(int i)
           
 LazyClassGen getEnclosingClass()
           
 Member getEnclosingCodeSignature()
           
 LazyMethodGen getEnclosingMethod()
           
 Shadow getEnclosingShadow()
           
 ResolvedType getEnclosingType()
           
 InstructionFactory getFactory()
           
 World getIWorld()
           
 Var getKindedAnnotationVar(UnresolvedType forAnnotationType)
           
 org.aspectj.weaver.bcel.ShadowRange getRange()
           
 Member getRealEnclosingCodeSignature()
           
 int getSourceLine()
           
 ISourceLocation getSourceLocation()
           
 Var getTargetAnnotationVar(UnresolvedType forAnnotationType)
           
 Var getTargetVar()
          a var referencing the target
 Var getThisAnnotationVar(UnresolvedType forAnnotationType)
           
 BcelVar getThisEnclosingJoinPointStaticPartBcelVar()
          Get the Var for the enclosingJpStaticPart
 Var getThisEnclosingJoinPointStaticPartVar()
           
 BcelVar getThisJoinPointStaticPartBcelVar()
          Get the Var for the jpStaticPart
 BcelVar getThisJoinPointStaticPartBcelVar(boolean isEnclosingJp)
          Get the Var for the xxxxJpStaticPart, xxx = this or enclosing
 Var getThisJoinPointStaticPartVar()
           
 Var getThisJoinPointVar()
           
 Var getThisVar()
          a var referencing this
 Var getWithinAnnotationVar(UnresolvedType forAnnotationType)
           
 Var getWithinCodeAnnotationVar(UnresolvedType forAnnotationType)
           
 BcelWorld getWorld()
           
 void init()
           
 void initializeArgAnnotationVars()
           
 void initializeArgVars()
          Initialize all the available arguments at the shadow.
 void initializeForAroundClosure()
           
 void initializeKindedAnnotationVars()
          By determining what "kind" of shadow we are, we can find out the annotations on the appropriate element (method, field, constructor, type).
 void initializeTargetAnnotationVars()
           
 void initializeTargetVar()
           
 void initializeThisAnnotationVars()
           
 void initializeWithinAnnotationVars()
           
 void initializeWithinCodeAnnotationVars()
           
 void initIfaceInitializer(InstructionHandle end)
           
 boolean isFallsThrough()
           
static BcelShadow makeAdviceExecution(BcelWorld world, LazyMethodGen enclosingMethod)
           
static BcelShadow makeArrayConstructorCall(BcelWorld world, LazyMethodGen enclosingMethod, InstructionHandle arrayInstruction, BcelShadow enclosingShadow)
           
static BcelShadow makeConstructorCall(BcelWorld world, LazyMethodGen enclosingMethod, InstructionHandle callHandle, BcelShadow enclosingShadow)
           
static BcelShadow makeConstructorExecution(BcelWorld world, LazyMethodGen enclosingMethod, InstructionHandle justBeforeStart)
           
static BcelShadow makeExceptionHandler(BcelWorld world, ExceptionRange exceptionRange, LazyMethodGen enclosingMethod, InstructionHandle startOfHandler, BcelShadow enclosingShadow)
          Make the shadow for an exception handler.
static BcelShadow makeFieldGet(BcelWorld world, ResolvedMember field, LazyMethodGen enclosingMethod, InstructionHandle getHandle, BcelShadow enclosingShadow)
           
static BcelShadow makeFieldSet(BcelWorld world, ResolvedMember field, LazyMethodGen enclosingMethod, InstructionHandle setHandle, BcelShadow enclosingShadow)
           
static BcelShadow makeIfaceInitialization(BcelWorld world, LazyMethodGen constructor, Member interfaceConstructorSignature)
          create an init join point associated w/ an interface in the body of a constructor
static BcelShadow makeMethodCall(BcelWorld world, LazyMethodGen enclosingMethod, InstructionHandle callHandle, BcelShadow enclosingShadow)
           
static BcelShadow makeMethodExecution(BcelWorld world, LazyMethodGen enclosingMethod)
           
static BcelShadow makeMethodExecution(BcelWorld world, LazyMethodGen enclosingMethod, boolean lazyInit)
           
static BcelShadow makeMonitorEnter(BcelWorld world, LazyMethodGen enclosingMethod, InstructionHandle monitorInstruction, BcelShadow enclosingShadow)
           
static BcelShadow makeMonitorExit(BcelWorld world, LazyMethodGen enclosingMethod, InstructionHandle monitorInstruction, BcelShadow enclosingShadow)
           
static BcelShadow makeShadowForMethod(BcelWorld world, LazyMethodGen enclosingMethod, Shadow.Kind kind, Member sig)
           
static BcelShadow makeShadowForMethodCall(BcelWorld world, LazyMethodGen enclosingMethod, InstructionHandle callHandle, BcelShadow enclosingShadow, Shadow.Kind kind, ResolvedMember sig)
           
static BcelShadow makeStaticInitialization(BcelWorld world, LazyMethodGen enclosingMethod)
           
static BcelShadow makeUnfinishedInitialization(BcelWorld world, LazyMethodGen constructor)
          Create an initialization join point associated with a constructor, but not with any body of code yet.
static BcelShadow makeUnfinishedPreinitialization(BcelWorld world, LazyMethodGen constructor)
           
 void requireThisJoinPoint(boolean hasGuardTest, boolean isAround)
           
static void retargetAllBranches(InstructionHandle from, InstructionHandle to)
           
 void setActualTargetType(java.lang.String className)
           
 void setRange(org.aspectj.weaver.bcel.ShadowRange range)
           
 boolean terminatesWithReturn()
          If the end of my range has no real instructions following then my context needs a return at the end.
 void weaveAfter(org.aspectj.weaver.bcel.BcelAdvice munger)
           
 void weaveAfterReturning(org.aspectj.weaver.bcel.BcelAdvice munger)
          The basic strategy here is to add a set of instructions at the end of the shadow range that dispatch the advice, and then return whatever the shadow was going to return anyway.
 void weaveAfterThrowing(org.aspectj.weaver.bcel.BcelAdvice munger, UnresolvedType catchType)
           
 void weaveAroundClosure(org.aspectj.weaver.bcel.BcelAdvice munger, boolean hasDynamicTest)
           
 void weaveAroundInline(org.aspectj.weaver.bcel.BcelAdvice munger, boolean hasDynamicTest)
           
 void weaveCflowEntry(org.aspectj.weaver.bcel.BcelAdvice munger, Member cflowField)
           
 void weavePerObjectEntry(org.aspectj.weaver.bcel.BcelAdvice munger, BcelVar onVar)
           
 void weavePerTypeWithinAspectInitialization(org.aspectj.weaver.bcel.BcelAdvice munger, UnresolvedType t)
          Causes the aspect instance to be *set* for later retrievable through localAspectof()/aspectOf()
 void weaveSoftener(org.aspectj.weaver.bcel.BcelAdvice munger, UnresolvedType catchType)
           
 
Methods inherited from class org.aspectj.weaver.Shadow
addMunger, getArgCount, getArgType, getArgTypes, getArgumentTypesForArrayConstructionShadow, getGenericArgTypes, getKind, getMatchingSignature, getMungers, getResolvedSignature, getReturnType, getSignature, getTargetType, getThisType, hasTarget, hasThis, howMany, implement, isShadowForArrayConstructionJoinpoint, isShadowForMonitor, setMatchingSignature, toResolvedString, toSet, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

appliedLazyTjpOptimization

public static boolean appliedLazyTjpOptimization
Constructor Detail

BcelShadow

public BcelShadow(BcelWorld world,
                  Shadow.Kind kind,
                  Member signature,
                  LazyMethodGen enclosingMethod,
                  BcelShadow enclosingShadow)
This generates an unassociated shadow, rooted in a particular method but not rooted to any particular point in the code. It should be given to a rooted ShadowRange in the ShadowRange.associateWithShadow(BcelShadow) method.

Method Detail

copyInto

public BcelShadow copyInto(LazyMethodGen recipient,
                           BcelShadow enclosing)

getIWorld

public World getIWorld()
Specified by:
getIWorld in class Shadow

addAdvicePreventingLazyTjp

public void addAdvicePreventingLazyTjp(org.aspectj.weaver.bcel.BcelAdvice advice)

getRange

public org.aspectj.weaver.bcel.ShadowRange getRange()

setRange

public void setRange(org.aspectj.weaver.bcel.ShadowRange range)

getSourceLine

public int getSourceLine()

getEnclosingType

public ResolvedType getEnclosingType()
Specified by:
getEnclosingType in class Shadow

getEnclosingClass

public LazyClassGen getEnclosingClass()

getWorld

public BcelWorld getWorld()

makeConstructorExecution

public static BcelShadow makeConstructorExecution(BcelWorld world,
                                                  LazyMethodGen enclosingMethod,
                                                  InstructionHandle justBeforeStart)

makeStaticInitialization

public static BcelShadow makeStaticInitialization(BcelWorld world,
                                                  LazyMethodGen enclosingMethod)

makeExceptionHandler

public static BcelShadow makeExceptionHandler(BcelWorld world,
                                              ExceptionRange exceptionRange,
                                              LazyMethodGen enclosingMethod,
                                              InstructionHandle startOfHandler,
                                              BcelShadow enclosingShadow)
Make the shadow for an exception handler. Currently makes an empty shadow that only allows before advice to be woven into it.


makeIfaceInitialization

public static BcelShadow makeIfaceInitialization(BcelWorld world,
                                                 LazyMethodGen constructor,
                                                 Member interfaceConstructorSignature)
create an init join point associated w/ an interface in the body of a constructor


initIfaceInitializer

public void initIfaceInitializer(InstructionHandle end)

makeUnfinishedInitialization

public static BcelShadow makeUnfinishedInitialization(BcelWorld world,
                                                      LazyMethodGen constructor)
Create an initialization join point associated with a constructor, but not with any body of code yet. If this is actually matched, it's range will be set when we inline self constructors.

Parameters:
constructor - The constructor starting this initialization.

makeUnfinishedPreinitialization

public static BcelShadow makeUnfinishedPreinitialization(BcelWorld world,
                                                         LazyMethodGen constructor)

makeMethodExecution

public static BcelShadow makeMethodExecution(BcelWorld world,
                                             LazyMethodGen enclosingMethod,
                                             boolean lazyInit)

init

public void init()

makeMethodExecution

public static BcelShadow makeMethodExecution(BcelWorld world,
                                             LazyMethodGen enclosingMethod)

makeShadowForMethod

public static BcelShadow makeShadowForMethod(BcelWorld world,
                                             LazyMethodGen enclosingMethod,
                                             Shadow.Kind kind,
                                             Member sig)

makeAdviceExecution

public static BcelShadow makeAdviceExecution(BcelWorld world,
                                             LazyMethodGen enclosingMethod)

makeConstructorCall

public static BcelShadow makeConstructorCall(BcelWorld world,
                                             LazyMethodGen enclosingMethod,
                                             InstructionHandle callHandle,
                                             BcelShadow enclosingShadow)

makeArrayConstructorCall

public static BcelShadow makeArrayConstructorCall(BcelWorld world,
                                                  LazyMethodGen enclosingMethod,
                                                  InstructionHandle arrayInstruction,
                                                  BcelShadow enclosingShadow)

makeMonitorEnter

public static BcelShadow makeMonitorEnter(BcelWorld world,
                                          LazyMethodGen enclosingMethod,
                                          InstructionHandle monitorInstruction,
                                          BcelShadow enclosingShadow)

makeMonitorExit

public static BcelShadow makeMonitorExit(BcelWorld world,
                                         LazyMethodGen enclosingMethod,
                                         InstructionHandle monitorInstruction,
                                         BcelShadow enclosingShadow)

makeMethodCall

public static BcelShadow makeMethodCall(BcelWorld world,
                                        LazyMethodGen enclosingMethod,
                                        InstructionHandle callHandle,
                                        BcelShadow enclosingShadow)

makeShadowForMethodCall

public static BcelShadow makeShadowForMethodCall(BcelWorld world,
                                                 LazyMethodGen enclosingMethod,
                                                 InstructionHandle callHandle,
                                                 BcelShadow enclosingShadow,
                                                 Shadow.Kind kind,
                                                 ResolvedMember sig)

makeFieldGet

public static BcelShadow makeFieldGet(BcelWorld world,
                                      ResolvedMember field,
                                      LazyMethodGen enclosingMethod,
                                      InstructionHandle getHandle,
                                      BcelShadow enclosingShadow)

makeFieldSet

public static BcelShadow makeFieldSet(BcelWorld world,
                                      ResolvedMember field,
                                      LazyMethodGen enclosingMethod,
                                      InstructionHandle setHandle,
                                      BcelShadow enclosingShadow)

retargetAllBranches

public static void retargetAllBranches(InstructionHandle from,
                                       InstructionHandle to)

terminatesWithReturn

public boolean terminatesWithReturn()
If the end of my range has no real instructions following then my context needs a return at the end.


arg0HoldsThis

public boolean arg0HoldsThis()
Is arg0 occupied with the value of this


getThisVar

public Var getThisVar()
Description copied from class: Shadow
a var referencing this

Specified by:
getThisVar in class Shadow

getThisAnnotationVar

public Var getThisAnnotationVar(UnresolvedType forAnnotationType)
Specified by:
getThisAnnotationVar in class Shadow

getTargetVar

public Var getTargetVar()
Description copied from class: Shadow
a var referencing the target

Specified by:
getTargetVar in class Shadow

getTargetAnnotationVar

public Var getTargetAnnotationVar(UnresolvedType forAnnotationType)
Specified by:
getTargetAnnotationVar in class Shadow

getArgVar

public Var getArgVar(int i)
Specified by:
getArgVar in class Shadow

getArgAnnotationVar

public Var getArgAnnotationVar(int i,
                               UnresolvedType forAnnotationType)
Specified by:
getArgAnnotationVar in class Shadow

getKindedAnnotationVar

public Var getKindedAnnotationVar(UnresolvedType forAnnotationType)
Specified by:
getKindedAnnotationVar in class Shadow

getWithinAnnotationVar

public Var getWithinAnnotationVar(UnresolvedType forAnnotationType)
Specified by:
getWithinAnnotationVar in class Shadow

getWithinCodeAnnotationVar

public Var getWithinCodeAnnotationVar(UnresolvedType forAnnotationType)
Specified by:
getWithinCodeAnnotationVar in class Shadow

getThisJoinPointStaticPartVar

public final Var getThisJoinPointStaticPartVar()
Specified by:
getThisJoinPointStaticPartVar in class Shadow

getThisEnclosingJoinPointStaticPartVar

public final Var getThisEnclosingJoinPointStaticPartVar()
Specified by:
getThisEnclosingJoinPointStaticPartVar in class Shadow

requireThisJoinPoint

public void requireThisJoinPoint(boolean hasGuardTest,
                                 boolean isAround)

getThisJoinPointVar

public Var getThisJoinPointVar()
Specified by:
getThisJoinPointVar in class Shadow

getThisJoinPointStaticPartBcelVar

public BcelVar getThisJoinPointStaticPartBcelVar()
Get the Var for the jpStaticPart

Returns:

getThisJoinPointStaticPartBcelVar

public BcelVar getThisJoinPointStaticPartBcelVar(boolean isEnclosingJp)
Get the Var for the xxxxJpStaticPart, xxx = this or enclosing

Parameters:
isEnclosingJp - true to have the enclosingJpStaticPart
Returns:

getThisEnclosingJoinPointStaticPartBcelVar

public BcelVar getThisEnclosingJoinPointStaticPartBcelVar()
Get the Var for the enclosingJpStaticPart

Returns:

getEnclosingCodeSignature

public Member getEnclosingCodeSignature()
Specified by:
getEnclosingCodeSignature in class Shadow

getRealEnclosingCodeSignature

public Member getRealEnclosingCodeSignature()

initializeTargetVar

public void initializeTargetVar()

ensureTargetTypeIsCorrect

public UnresolvedType ensureTargetTypeIsCorrect(UnresolvedType tx)

ensureInitializedArgVar

public void ensureInitializedArgVar(int argNumber)

initializeArgVars

public void initializeArgVars()
Initialize all the available arguments at the shadow. This means creating a copy of them that we can then use for advice calls (the copy ensures we are not affected by other advice changing the values). This method initializes all arguments whereas the method ensureInitializedArgVar will only ensure a single argument is setup.


initializeForAroundClosure

public void initializeForAroundClosure()

initializeThisAnnotationVars

public void initializeThisAnnotationVars()

initializeTargetAnnotationVars

public void initializeTargetAnnotationVars()

initializeArgAnnotationVars

public void initializeArgAnnotationVars()

initializeKindedAnnotationVars

public void initializeKindedAnnotationVars()
By determining what "kind" of shadow we are, we can find out the annotations on the appropriate element (method, field, constructor, type). Then create one BcelVar entry in the map for each annotation, keyed by annotation type.


initializeWithinAnnotationVars

public void initializeWithinAnnotationVars()

initializeWithinCodeAnnotationVars

public void initializeWithinCodeAnnotationVars()

weaveAfter

public void weaveAfter(org.aspectj.weaver.bcel.BcelAdvice munger)

weaveAfterReturning

public void weaveAfterReturning(org.aspectj.weaver.bcel.BcelAdvice munger)
The basic strategy here is to add a set of instructions at the end of the shadow range that dispatch the advice, and then return whatever the shadow was going to return anyway. To achieve this, we note all the return statements in the advice, and replace them with code that: 1) stores the return value on top of the stack in a temp var 2) jumps to the start of our advice block 3) restores the return value at the end of the advice block before ultimately returning We also need to bind the return value into a returning parameter, if the advice specified one.


weaveAfterThrowing

public void weaveAfterThrowing(org.aspectj.weaver.bcel.BcelAdvice munger,
                               UnresolvedType catchType)

weaveSoftener

public void weaveSoftener(org.aspectj.weaver.bcel.BcelAdvice munger,
                          UnresolvedType catchType)

weavePerObjectEntry

public void weavePerObjectEntry(org.aspectj.weaver.bcel.BcelAdvice munger,
                                BcelVar onVar)

weavePerTypeWithinAspectInitialization

public void weavePerTypeWithinAspectInitialization(org.aspectj.weaver.bcel.BcelAdvice munger,
                                                   UnresolvedType t)
Causes the aspect instance to be *set* for later retrievable through localAspectof()/aspectOf()


weaveCflowEntry

public void weaveCflowEntry(org.aspectj.weaver.bcel.BcelAdvice munger,
                            Member cflowField)

weaveAroundInline

public void weaveAroundInline(org.aspectj.weaver.bcel.BcelAdvice munger,
                              boolean hasDynamicTest)

weaveAroundClosure

public void weaveAroundClosure(org.aspectj.weaver.bcel.BcelAdvice munger,
                               boolean hasDynamicTest)

genTempVar

public BcelVar genTempVar(UnresolvedType typeX)

genTempVar

public BcelVar genTempVar(UnresolvedType typeX,
                          java.lang.String localName)

getFactory

public InstructionFactory getFactory()

getSourceLocation

public ISourceLocation getSourceLocation()
Specified by:
getSourceLocation in class Shadow

getEnclosingShadow

public Shadow getEnclosingShadow()

getEnclosingMethod

public LazyMethodGen getEnclosingMethod()

isFallsThrough

public boolean isFallsThrough()

setActualTargetType

public void setActualTargetType(java.lang.String className)

getActualTargetType

public java.lang.String getActualTargetType()