Top Fields Constructors Methods
org.aspectj.weaver.bcel

public Class BcelTypeMunger

extends ConcreteTypeMunger
Class Inheritance
Known Direct Subclasses
org.aspectj.weaver.bcel.BcelAccessForInlineMunger, org.aspectj.weaver.bcel.BcelCflowCounterFieldAdder, org.aspectj.weaver.bcel.BcelCflowStackFieldAdder, org.aspectj.weaver.bcel.BcelPerClauseAspectAdder
Imports
java.lang.reflect.Modifier, java.util.ArrayList, .HashMap, .HashSet, .Iterator, .List, .Map, .Set, org.aspectj.apache.bcel.Constants, org.aspectj.apache.bcel.classfile.ClassFormatException, .ConstantPool, .Signature, org.aspectj.apache.bcel.classfile.annotation.AnnotationGen, org.aspectj.apache.bcel.generic.FieldGen, .InstructionBranch, .InstructionConstants, .InstructionFactory, .InstructionHandle, .InstructionList, .InvokeInstruction, .Type, org.aspectj.asm.AsmManager, .IProgramElement, org.aspectj.bridge.IMessage, .ISourceLocation, .Message, .MessageUtil, .WeaveMessage, org.aspectj.bridge.context.CompilationAndWeavingContext, .ContextToken, org.aspectj.weaver.AjcMemberMaker, .AnnotationAJ, .AnnotationOnTypeMunger, .BCException, .ConcreteTypeMunger, .Member, .MemberUtils, .MethodDelegateTypeMunger, .NameMangler, .NewConstructorTypeMunger, .NewFieldTypeMunger, .NewMemberClassTypeMunger, .NewMethodTypeMunger, .NewParentTypeMunger, .PerObjectInterfaceTypeMunger, .PrivilegedAccessMunger, .ResolvedMember, .ResolvedMemberImpl, .ResolvedType, .ResolvedTypeMunger, .Shadow, .TypeVariableReference, .UnresolvedType, .WeaverMessages, .WeaverStateInfo, .World, org.aspectj.weaver.model.AsmRelationshipProvider, org.aspectj.weaver.patterns.DeclareAnnotation, .Pointcut

Field Summary

Modifier and TypeField and Description
private volatile int
Inherited from org.aspectj.weaver.ConcreteTypeMunger:
aspectTypemunger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
private void
private void
private void
public boolean
attemptToModifySuperCalls(BcelClassWeaver weaver, LazyClassGen newParentTarget, ResolvedType newParent)

The main part of implementing declare parents extends.

private void
private boolean
couldMatch(BcelObjectType bcelObjectType, Pointcut pointcut)

private void
createAnyBridgeMethodsForCovariance(BcelClassWeaver weaver, NewMethodTypeMunger munger, ResolvedMember unMangledInterMethod, ResolvedType onType, LazyClassGen gen, Type[] paramTypes)

Create any bridge method required because of covariant returns being used.

private void
createBridge(BcelClassWeaver weaver, ResolvedMember unMangledInterMethod, LazyClassGen classGen, ResolvedMember toBridgeTo)

private void
createBridgeIfNecessary(BcelClassWeaver classWeaver, NewMethodTypeMunger munger, ResolvedMember unMangledInterMethod, LazyClassGen classGen)

private void
createBridgeMethod(BcelWorld world, NewMethodTypeMunger munger, ResolvedMember
the method to bridge 'to' that we have already created in the 'subtype'
unMangledInterMethod
,
LazyClassGen
the class in which to put the bridge method
clazz
,
Type[]
Parameter types for the bridge method, passed in as an optimization since the caller is likely to have already created them.
paramTypes
,
ResolvedMember theBridgeMethod)

Create a bridge method for a particular munger.

private void
private String
createReadableCtorSig(ResolvedType newParent, ConstantPool cpg, InvokeInstruction invokeSpecial)

Creates a nice signature for the ctor, something like "(int,Integer,String)"

private Signature
createSignatureAttribute(ConstantPool cp, String signature)

Helper method to create a signature attribute based on a string signature: e.g. "Ljava/lang/Object;LI<ljava lang double;>;"

private boolean
enforceDecpRule1_abstractMethodsImplemented(BcelClassWeaver weaver, ISourceLocation mungerLoc, LazyClassGen newParentTarget, ResolvedType newParent)

Rule 1: For the declare parents to be allowed, the target type must override and implement inherited abstract methods (if the type is not declared abstract)

private boolean
private boolean
private boolean
private boolean
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public void
error(BcelClassWeaver weaver, String text, ISourceLocation primaryLoc, ISourceLocation[] extraLocs)

private LazyMethodGen
findMatchingMethod(LazyClassGen type, ResolvedMember searchMethod)

Search the specified type for a particular method - do not use the return value in the comparison as it is not considered for overriding.

private ResolvedMember
private ResolvedMember
getRealMemberForITDFromAspect(ResolvedType aspectType, ResolvedMember lookingFor, boolean isCtorRelated)

private String
public List<String>
getTypeVariableAliases()

Returns a list of type variable aliases used in this munger.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
private static LazyMethodGen
makeDispatcher(LazyClassGen onGen, String dispatchName, ResolvedMember superMethod, BcelWorld world, boolean isSuper)

protected FieldGen
protected LazyMethodGen
public boolean
private boolean
private boolean
private boolean
private boolean
private boolean
private boolean
private boolean
private boolean
mungeNewParent(BcelClassWeaver weaver, NewParentTypeMunger typeTransformer)

For a long time, AspectJ did not allow binary weaving of declare parents.

private boolean
private boolean
private boolean
public ConcreteTypeMunger
parameterizedFor(ResolvedType target)

Implements abstract org.aspectj.weaver.ConcreteTypeMunger.parameterizedFor.

For an ITD made on a generic type that shares type variables with that target type, this method will tailor the ITD for a particular usage of the generic type - either in its raw or parameterized form.
public ConcreteTypeMunger
public boolean
private void
private void
signalError(String msgString, BcelClassWeaver weaver)

private String
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from org.aspectj.weaver.ConcreteTypeMunger:
compareToequivalentToexistsToSupportShadowMungingfallbackCompareTogetAspectTypegetMatchingSyntheticMembergetMungergetSignaturegetSourceLocationgetWorldisLateMungerisTargetTypeParameterizedmatches

Field Detail

hashCodeback to summary
private volatile int hashCode

Constructor Detail

BcelTypeMungerback to summary
public BcelTypeMunger(ResolvedTypeMunger munger, ResolvedType aspectType)

Method Detail

addFieldGetterback to summary
private void addFieldGetter(LazyClassGen gen, ResolvedMember field, ResolvedMember accessMethod)
addFieldSetterback to summary
private void addFieldSetter(LazyClassGen gen, ResolvedMember field, ResolvedMember accessMethod)
addMethodDispatchback to summary
private void addMethodDispatch(LazyClassGen gen, ResolvedMember method, ResolvedMember accessMethod)
addNeededSuperCallMethodsback to summary
private void addNeededSuperCallMethods(BcelClassWeaver weaver, ResolvedType onType, Set<ResolvedMember> neededSuperCalls)
attemptToModifySuperCallsback to summary
public boolean attemptToModifySuperCalls(BcelClassWeaver weaver, LazyClassGen newParentTarget, ResolvedType newParent)

The main part of implementing declare parents extends. Modify super ctor calls to target the new type.

copyOverParameterAnnotationsback to summary
private void copyOverParameterAnnotations(LazyMethodGen receiverMethod, ResolvedMember donorMethod)
couldMatchback to summary
private boolean couldMatch(BcelObjectType bcelObjectType, Pointcut pointcut)
createAnyBridgeMethodsForCovarianceback to summary
private void createAnyBridgeMethodsForCovariance(BcelClassWeaver weaver, NewMethodTypeMunger munger, ResolvedMember unMangledInterMethod, ResolvedType onType, LazyClassGen gen, Type[] paramTypes)

Create any bridge method required because of covariant returns being used. This method is used in the case where an ITD is applied to some type and it may be in an override relationship with a method from the supertype - but due to covariance there is a mismatch in return values. Example of when required: Super defines: Object m(String s) Sub defines: String m(String s) then we need a bridge method in Sub called 'Object m(String s)' that forwards to 'String m(String s)'

createBridgeback to summary
private void createBridge(BcelClassWeaver weaver, ResolvedMember unMangledInterMethod, LazyClassGen classGen, ResolvedMember toBridgeTo)
createBridgeIfNecessaryback to summary
private void createBridgeIfNecessary(BcelClassWeaver classWeaver, NewMethodTypeMunger munger, ResolvedMember unMangledInterMethod, LazyClassGen classGen)
createBridgeMethodback to summary
private void createBridgeMethod(BcelWorld world, NewMethodTypeMunger munger, ResolvedMember unMangledInterMethod, LazyClassGen clazz, Type[] paramTypes, ResolvedMember theBridgeMethod)

Create a bridge method for a particular munger.

Parameters
unMangledInterMethod:ResolvedMember

the method to bridge 'to' that we have already created in the 'subtype'

clazz:LazyClassGen

the class in which to put the bridge method

paramTypes:Type[]

Parameter types for the bridge method, passed in as an optimization since the caller is likely to have already created them.

createBridgeMethodForITDFback to summary
private void createBridgeMethodForITDF(BcelClassWeaver weaver, LazyClassGen gen, ResolvedMember itdfieldSetter, ResolvedMember bridgingSetter)
createReadableCtorSigback to summary
private String createReadableCtorSig(ResolvedType newParent, ConstantPool cpg, InvokeInstruction invokeSpecial)

Creates a nice signature for the ctor, something like "(int,Integer,String)"

createSignatureAttributeback to summary
private Signature createSignatureAttribute(ConstantPool cp, String signature)

Helper method to create a signature attribute based on a string signature: e.g. "Ljava/lang/Object;LI;"

enforceDecpRule1_abstractMethodsImplementedback to summary
private boolean enforceDecpRule1_abstractMethodsImplemented(BcelClassWeaver weaver, ISourceLocation mungerLoc, LazyClassGen newParentTarget, ResolvedType newParent)

Rule 1: For the declare parents to be allowed, the target type must override and implement inherited abstract methods (if the type is not declared abstract)

enforceDecpRule2_cantExtendFinalClassback to summary
private boolean enforceDecpRule2_cantExtendFinalClass(BcelClassWeaver weaver, ISourceLocation transformerLoc, LazyClassGen targetType, ResolvedType newParent)

Rule 2. Can't extend final types

enforceDecpRule3_visibilityChangesback to summary
private boolean enforceDecpRule3_visibilityChanges(BcelClassWeaver weaver, ResolvedType newParent, ResolvedMember superMethod, LazyMethodGen subMethod)

Rule 3. Can't narrow visibility of methods when overriding

enforceDecpRule4_compatibleReturnTypesback to summary
private boolean enforceDecpRule4_compatibleReturnTypes(BcelClassWeaver weaver, ResolvedMember superMethod, LazyMethodGen subMethod)

Rule 4. Can't have incompatible return types

enforceDecpRule5_cantChangeFromStaticToNonstaticback to summary
private boolean enforceDecpRule5_cantChangeFromStaticToNonstatic(BcelClassWeaver weaver, ISourceLocation mungerLoc, ResolvedMember superMethod, LazyMethodGen subMethod)

Rule5. Method overrides can't change the staticality (word?) - you can't override and make an instance method static or override and make a static method an instance method.

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
errorback to summary
public void error(BcelClassWeaver weaver, String text, ISourceLocation primaryLoc, ISourceLocation[] extraLocs)
findMatchingMethodback to summary
private LazyMethodGen findMatchingMethod(LazyClassGen type, ResolvedMember searchMethod)

Search the specified type for a particular method - do not use the return value in the comparison as it is not considered for overriding.

getConstructorWithSignatureback to summary
private ResolvedMember getConstructorWithSignature(ResolvedType type, String searchSig)
getRealMemberForITDFromAspectback to summary
private ResolvedMember getRealMemberForITDFromAspect(ResolvedType aspectType, ResolvedMember lookingFor, boolean isCtorRelated)
getShortnameback to summary
private String getShortname(String path)
getTypeVariableAliasesback to summary
public List<String> getTypeVariableAliases()

Returns a list of type variable aliases used in this munger. For example, if the ITD is 'int I<A,B>.m(List<A> las,List<B> lbs) {}' then this returns a list containing the strings "A" and "B".

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
makeDispatcherback to summary
private static LazyMethodGen makeDispatcher(LazyClassGen onGen, String dispatchName, ResolvedMember superMethod, BcelWorld world, boolean isSuper)
makeFieldGenback to summary
protected FieldGen makeFieldGen(LazyClassGen gen, ResolvedMember member)
makeMethodGenback to summary
protected LazyMethodGen makeMethodGen(LazyClassGen gen, ResolvedMember member)
mungeback to summary
public boolean munge(BcelClassWeaver weaver)
mungeFieldHostback to summary
private boolean mungeFieldHost(BcelClassWeaver weaver, MethodDelegateTypeMunger.FieldHostTypeMunger munger)
mungeMethodDelegateback to summary
private boolean mungeMethodDelegate(BcelClassWeaver weaver, MethodDelegateTypeMunger munger)
mungeNewAnnotationOnTypeback to summary
private boolean mungeNewAnnotationOnType(BcelClassWeaver weaver, AnnotationOnTypeMunger munger)
mungeNewConstructorback to summary
private boolean mungeNewConstructor(BcelClassWeaver weaver, NewConstructorTypeMunger newConstructorTypeMunger)
mungeNewFieldback to summary
private boolean mungeNewField(BcelClassWeaver weaver, NewFieldTypeMunger munger)
mungeNewMemberTypeback to summary
private boolean mungeNewMemberType(BcelClassWeaver classWeaver, NewMemberClassTypeMunger munger)
mungeNewMethodback to summary
private boolean mungeNewMethod(BcelClassWeaver classWeaver, NewMethodTypeMunger munger)
mungeNewParentback to summary
private boolean mungeNewParent(BcelClassWeaver weaver, NewParentTypeMunger typeTransformer)

For a long time, AspectJ did not allow binary weaving of declare parents. This restriction is now lifted but could do with more testing!

mungePerObjectInterfaceback to summary
private boolean mungePerObjectInterface(BcelClassWeaver weaver, PerObjectInterfaceTypeMunger munger)
mungePerTypeWithinTransformerback to summary
private boolean mungePerTypeWithinTransformer(BcelClassWeaver weaver)
mungePrivilegedAccessback to summary
private boolean mungePrivilegedAccess(BcelClassWeaver weaver, PrivilegedAccessMunger munger)
parameterizedForback to summary
public ConcreteTypeMunger parameterizedFor(ResolvedType target)

Implements abstract org.aspectj.weaver.ConcreteTypeMunger.parameterizedFor.

Doc from org.aspectj.weaver.ConcreteTypeMunger.parameterizedFor.

For an ITD made on a generic type that shares type variables with that target type, this method will tailor the ITD for a particular usage of the generic type - either in its raw or parameterized form.

Annotations
@Override
parameterizeWithback to summary
public ConcreteTypeMunger parameterizeWith(Map<String, UnresolvedType> m, World w)

Implements abstract org.aspectj.weaver.ConcreteTypeMunger.parameterizeWith.

Annotations
@Override
shouldOverwriteback to summary
public boolean shouldOverwrite()

Overrides org.aspectj.weaver.ConcreteTypeMunger.shouldOverwrite.

Annotations
@Override
signalErrorback to summary
private void signalError(String msgid, BcelClassWeaver weaver, UnresolvedType onType)
signalErrorback to summary
private void signalError(String msgString, BcelClassWeaver weaver)
stringifyMemberback to summary
private String stringifyMember(ResolvedMember member)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override