Top Inners Fields Constructors Methods
org.aspectj.weaver.bcel

pack-priv Class BcelClassWeaver

extends Object
implements IClassWeaver
Class Inheritance
All Implemented Interfaces
org.aspectj.weaver.IClassWeaver
Imports
java.lang.reflect.Modifier, java.util.ArrayList, .Collections, .Comparator, .HashMap, .HashSet, .Iterator, .LinkedHashSet, .List, .Map, .Objects, .Properties, .Set, org.aspectj.apache.bcel.Constants, org.aspectj.apache.bcel.classfile.BootstrapMethods, .ConstantPool, .Method, org.aspectj.apache.bcel.classfile.annotation.AnnotationGen, org.aspectj.apache.bcel.generic.FieldGen, .FieldInstruction, .Instruction, .InstructionBranch, .InstructionCP, .InstructionConstants, .InstructionFactory, .InstructionHandle, .InstructionLV, .InstructionList, .InstructionSelect, .InstructionTargeter, .InvokeInstruction, .LineNumberTag, .LocalVariableTag, .MULTIANEWARRAY, .MethodGen, .ObjectType, .RET, .Tag, .Type, org.aspectj.asm.AsmManager, org.aspectj.bridge.IMessage, .ISourceLocation, .Message, .MessageUtil, .WeaveMessage, org.aspectj.bridge.context.CompilationAndWeavingContext, .ContextToken, org.aspectj.util.PartialOrder, org.aspectj.weaver.AjAttribute, .AjcMemberMaker, .AnnotationAJ, .BCException, .ConcreteTypeMunger, .IClassWeaver, .IntMap, .Member, .MissingResolvedTypeWithKnownSignature, .NameMangler, .NewConstructorTypeMunger, .NewFieldTypeMunger, .NewMethodTypeMunger, .ResolvedMember, .ResolvedMemberImpl, .ResolvedType, .ResolvedTypeMunger, .Shadow, .ShadowMunger, .UnresolvedType, .UnresolvedTypeVariableReferenceType, .WeaverStateInfo, .World, org.aspectj.weaver.model.AsmRelationshipProvider, org.aspectj.weaver.patterns.DeclareAnnotation, .ExactTypePattern, org.aspectj.weaver.tools.Trace, .TraceFactory

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
private static class

Field Summary

Modifier and TypeField and Description
private final List<ConcreteTypeMunger>
private final Set<ResolvedMember>
private final List<LazyMethodGen>
private final Map<ResolvedType, BcelClassWeaver.IfaceInitList>
private List<BcelClassWeaver.IfaceInitList>
private final List<ConcreteTypeMunger>
private boolean
private static boolean
private static boolean
private final LazyClassGen
private final ConstantPool
private final InstructionFactory
private List<ShadowMunger>[]
private final List<BcelShadow>
initializationShadows

This holds the initialization and pre-initialization shadows for this class that were actually matched by mungers (if no match, then we don't even create the shadows really).

private boolean
private final List<ConcreteTypeMunger>
private final Map<ResolvedMember, ResolvedMember>
private final List<ShadowMunger>
private static final String
private static Trace
private final BcelObjectType
private final List<ConcreteTypeMunger>
private final BcelWorld

Constructor Summary

AccessConstructor and Description
private
BcelClassWeaver(BcelWorld world, LazyClassGen clazz, List<ShadowMunger> shadowMungers, List<ConcreteTypeMunger> typeMungers, List<ConcreteTypeMunger> lateTypeMungers)

Method Summary

Modifier and TypeMethod and Description
public boolean
public void
public void
public void
private boolean
private boolean
public static boolean
calculateAnyRequiredBridgeMethods(BcelWorld world, LazyClassGen clazz)

We need to determine if any methods in this type require bridge methods - this method should only be called if necessary to do this calculation, i.e. we are on a 1.5 VM (where covariance/generics exist) and the type hierarchy for the specified class has changed (via decp/itd).

private boolean
public static void

Returns:

the method being overridden or null if none is found
checkForOverride
(ResolvedType typeToCheck, String mname, String mparams, String mrettype, int mmods, String mpkg, UnresolvedType[] methodParamsArray, List<ResolvedMember> overriddenMethodsCollector)

This method recurses up a specified type looking for a method that overrides the one passed in.

private void
checkUnusedDeclareAts(Set<DeclareAnnotation> unusedDecaTs, boolean isDeclareAtField)

Report an error if the reason a "declare @method/ctor/field" was not used was because the member specified does not exist.

private static void
createBridgeMethod(BcelWorld world, LazyMethodGen whatToBridgeToMethodGen, LazyClassGen clazz, ResolvedMember theBridgeMethod)

Create a single bridge method called 'theBridgeMethod' that bridges to 'whatToBridgeTo'

private boolean
doesAlreadyHaveAnnotation(ResolvedMember rm, DeclareAnnotation deca, List<Integer> reportedProblems, boolean reportError)

Check if a resolved member (field/method/ctor) already has an annotation, if it does then put out a warning and return true

private boolean
private boolean
dontAddTwice(DeclareAnnotation decaF, AnnotationAJ[] dontAddMeTwice)

private Set<String>
private ResolvedMember
findResolvedMemberNamed(ResolvedType type, String methodName)

For some named resolved type, this method looks for a member with a particular name - it should only be used when you truly believe there is only one member with that name in the type as it returns the first one it finds.

private ResolvedMember
findResolvedMemberNamed(ResolvedType
the type to search for the member
type
,
String
the name of the method to find
methodName
,
UnresolvedType[]
the method parameters that the discovered method should have
params
)

Find the specified member in the specified type.

private InstructionHandle
findSuperOrThisCall(LazyMethodGen mg)

Returns null if this is not a Java constructor, and then we won't weave into it at all

private void
fixAnnotationsForResolvedMember(ResolvedMember
the sig we want it to pretend to be 'int A.m()' or somesuch ITD like thing
rm
,
ResolvedMember
the real sig 'blah.ajc$xxx'
declaredSig
)

For a given resolvedmember, this will discover the real annotations for it.

private void
fixParameterNamesForResolvedMember(ResolvedMember
the sig we want it to pretend to be 'int A.m()' or somesuch ITD like thing
rm
,
ResolvedMember
the real sig 'blah.ajc$xxx'
declaredSig
)

For a given resolvedmember, this will discover the real annotations for it.

private static InstructionList
genArgumentStores(LazyMethodGen
the method we will inline from. Used to get the signature.
donor
,
LazyMethodGen
the method we will inline into. Used to get the frame size so we can allocate fresh locations.
recipient
,
IntMap
an empty environment we populate with a map from donor frame to recipient frame.
frameEnv
,
InstructionFactory
an instruction factory for recipient
fact
)

generate the argument stores in preparation for inlining.

private InstructionList
genInitInstructions(List<ConcreteTypeMunger> list, boolean isStatic)

first sorts the mungers, then gens the initializers in the right order

pack-priv static InstructionList
genInlineInstructions(LazyMethodGen
the method from which we will copy (and adjust frame and jumps) instructions.
donor
,
LazyMethodGen
the method the instructions will go into. Used to get the frame size so we can allocate new frame locations for locals in donor.
recipient
,
IntMap
an environment to map from donor frame to recipient frame, initially populated with argument locations.
frameEnv
,
InstructionFactory
an instruction factory for recipient
fact
,
boolean keepReturns)

generate the instructions to be inlined.

private LazyMethodGen
getCalledMethod(InstructionHandle
The InvokeInstruction instructionHandle pointing to the called method.
ih
)

get a called method: Assumes the called method is in this class, and the reference to it is exact (a la INVOKESPECIAL).

private List<ConcreteTypeMunger>
getITDSubset(LazyClassGen clazz, ResolvedTypeMunger.Kind wantedKind)

Get a subset of all the type mungers defined on this aspect

public LazyClassGen
private List<DeclareAnnotation>
getMatchingSubset(List<DeclareAnnotation> declareAnnotations, ResolvedType type)

Looks through a list of declare annotation statements and only returns those that could possibly match on a field/method/ctor in type.

public boolean
public BcelWorld
private void
private void
indexShadowMungers()

Process the shadow mungers into array 'buckets', each bucket represents a shadow kind and contains a list of shadowmungers that could potentially apply at that shadow kind.

private void
public static void
inlineMethod(LazyMethodGen
the method we want to inline
donor
,
LazyMethodGen
the method containing the call we want to inline
recipient
,
InstructionHandle
the instructionHandle in recipient's body holding the call we want to inline.
call
)

inline a particular call in bytecode.

private boolean
private boolean
private static ResolvedMember

Returns:

method that is overriding if it
isOverriding
(ResolvedType typeToCheck, ResolvedMember methodThatMightBeGettingOverridden, String mname, String mrettype, int mmods, boolean inSamePackage, UnresolvedType[] methodParamsArray)

Check if a particular method is overriding another - refactored into this helper so it can be used from multiple places.

private boolean
pack-priv static boolean

Returns:

true if there is an overrides rather than a 'hides' relationship
isVisibilityOverride
(int methodMods, ResolvedMember inheritedMethod, boolean inSamePackage)

Looks at the visibility modifiers between two methods, and knows whether they are from classes in the same package, and decides whether one overrides the other.

public LazyMethodGen
public LazyMethodGen
protected static LazyMethodGen
private boolean
private void
match(LazyMethodGen mg, InstructionHandle ih, BcelShadow enclosingShadow, List<BcelShadow> shadowAccumulator)

private boolean
match(BcelShadow shadow, List<BcelShadow> shadowAccumulator)

private void
matchGetInstruction(LazyMethodGen mg, InstructionHandle ih, BcelShadow enclosingShadow, List<BcelShadow> shadowAccumulator)

private boolean
matchInit(LazyMethodGen mg, List<BcelShadow> shadowAccumulator)

private void
private void
matchSetInstruction(LazyMethodGen mg, InstructionHandle ih, BcelShadow enclosingShadow, List<BcelShadow> shadowAccumulator)

private void
positionAndImplement(List<BcelShadow> initializationShadows)

private void
private AnnotationAJ[]
removeFromAnnotationsArray(AnnotationAJ[] annotations, AnnotationAJ annotation)

Remove an annotation from the supplied array, if it is in there.

private void
private void
public void
setReweavableMode(boolean mode)

private boolean
private boolean
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public static void
transformSynchronizedMethod(LazyMethodGen synchronizedMethod)

Input method is a synchronized method, we remove the bit flag for synchronized and then insert a try..finally block Some jumping through firey hoops required - depending on the input code level (1.5 or not) we may or may not be able to use the LDC instruction that takes a class literal (doesnt on <1.5).

public static boolean
weave(BcelWorld world, LazyClassGen clazz, List<ShadowMunger> shadowMungers, List<ConcreteTypeMunger> typeMungers, List<ConcreteTypeMunger> lateTypeMungers, boolean inReweavableMode)

public boolean

Returns:

true if the class was modified
weave
()

Implements org.aspectj.weaver.IClassWeaver.weave.

Weave a class and indicate through the return value whether the class was modified.
private boolean
weaveAtFieldRepeatedly(List<DeclareAnnotation> decaFs, List<ConcreteTypeMunger> itdFields, List<Integer> reportedErrors)

Applies some set of declare @field constructs (List<declareannotation>) to some bunch of ITDfields (List<bceltypemunger>.

private boolean
weaveAtMethodOnITDSRepeatedly(List<DeclareAnnotation> decaMCs, List<ConcreteTypeMunger> itdsForMethodAndConstructor, List<Integer> reportedErrors)

Applies some set of declare @method/@ctor constructs (List<declareannotation>) to some bunch of ITDmembers (List<bceltypemunger>.

private boolean
weaveDeclareAtField(LazyClassGen clazz)

Weave any declare @field statements into the fields of the supplied class.

private boolean
weaveDeclareAtMethodCtor(LazyClassGen clazz)

Weave any declare @method/@ctor statements into the members of the supplied class

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait