Top Description Inners Fields Constructors Methods
org.aspectj.weaver.patterns

public Class WildTypePattern

extends TypePattern
Class Inheritance
Imports
java.io.IOException, java.util.ArrayList, .List, .Map, .StringTokenizer, org.aspectj.bridge.IMessage, .ISourceLocation, .Message, .MessageUtil, org.aspectj.util.FileUtil, .FuzzyBoolean, org.aspectj.weaver.AjAttribute, .BCException, .BoundedReferenceType, .CompressingDataOutputStream, .IHasPosition, .ISourceContext, .ReferenceType, .ResolvedType, .TypeFactory, .TypeVariable, .TypeVariableReference, .UnresolvedType, .UnresolvedTypeVariableReferenceType, .VersionedDataInputStream, .WeaverMessages, .World

The PatternParser always creates WildTypePatterns for type patterns in pointcut expressions (apart from *, which is sometimes directly turned into TypePattern.ANY). resolveBindings() tries to work out what we've really got and turn it into a type pattern that we can use for matching. This will normally be either an ExactTypePattern or a WildTypePattern. Here's how the process pans out for various generic and parameterized patterns: (see GenericsWildTypePatternResolvingTestCase) Foo where Foo exists and is generic Parser creates WildTypePattern namePatterns={Foo} resolveBindings resolves Foo to RT(Foo - raw) return ExactTypePattern(LFoo;) Foo<String> where Foo exists and String meets the bounds Parser creates WildTypePattern namePatterns = {Foo}, typeParameters=WTP{String} resolveBindings resolves typeParameters to ExactTypePattern(String) resolves Foo to RT(Foo) returns ExactTypePattern(PFoo<String>; - parameterized) Foo<Str*> where Foo exists and takes one bound Parser creates WildTypePattern namePatterns = {Foo}, typeParameters=WTP{Str*} resolveBindings resolves typeParameters to WTP{Str*} resolves Foo to RT(Foo) returns WildTypePattern(name = Foo, typeParameters = WTP{Str*} isGeneric=false) Fo*<String> Parser creates WildTypePattern namePatterns = {Fo*}, typeParameters=WTP{String} resolveBindings resolves typeParameters to ETP{String} returns WildTypePattern(name = Fo*, typeParameters = ETP{String} isGeneric=false) Foo<?> Foo<? extends Number> Foo<? extends Number+> Foo<? super Number>

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
WildTypePattern.VerifyBoundsForTypePattern

By capturing the verification in this class, rather than performing it in verifyTypeParameters(), we can cope with situations where the interactions between generics and declare parents would otherwise cause us problems.

Field Summary

Modifier and TypeField and Description
pack-priv TypePattern[]
public static boolean
pack-priv int
pack-priv int
private boolean
private static final String
private static final String
pack-priv String[]
private boolean
pack-priv String[]
pack-priv TypePattern
private NamePattern[]
pack-priv TypePattern
private static final byte
Inherited from org.aspectj.weaver.patterns.TypePattern:
ANDannotationPatternANYANY_KEYANY_WITH_ANNOBINDINGDYNAMICELLIPSISELLIPSIS_KEYEXACTHAS_MEMBERincludeSubtypesisVarArgsNONO_KEYNOTORSTATICTYPE_CATEGORYtypeParametersWILD

Constructor Summary

AccessConstructor and Description
pack-priv
WildTypePattern(NamePattern[] namePatterns, boolean includeSubtypes, int dim, boolean isVarArgs, TypePatternList typeParams)

public
WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim)

public
WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos)

public
WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg)

public
WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg, TypePatternList typeParams, TypePattern upperBound, TypePattern[] additionalInterfaceBounds, TypePattern lowerBound)

public
WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg, TypePatternList typeParams)

Method Summary

Modifier and TypeMethod and Description
public Object
protected 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 NamePattern
public TypePattern[]
public int
getDimensions()

Overrides org.aspectj.weaver.patterns.TypePattern.getDimensions.

Used in conjunction with checks on 'isStar()' to tell you if this pattern represents '*' or '*[]' which are different !
public TypePattern
public NamePattern[]
public TypePattern
public boolean
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
private boolean
innerMatchesExactly(String s, boolean isAnonymous, boolean convertDollar)

private static boolean
inStar(final NamePattern[] pattern, final char[][] target, int pi, int ti, final int pLeft, int tLeft, int starsLeft)

public boolean
private boolean
public boolean
private int
private UnresolvedType
lookupTypeInScope(IScope scope, String typeName, IHasPosition location)

private ResolvedType
lookupTypeInWorld(World world, String typeName)

private ResolvedType
lookupTypeInWorldIncludingPrefixes(World world, String typeName, String[] prefixes)

Searches the world for the ResolvedType with the given typeName.

protected boolean
private boolean
protected boolean
protected boolean
private boolean
matchesExactlyByName(String targetTypeName, boolean isAnonymous, boolean isNested)

public FuzzyBoolean
private boolean
public boolean

Returns:

boolean
maybeExtractName
(String string)

Method maybeExtractName.

public String
maybeGetCleanName()

If this type pattern has no '*' or '..' in it

public String
maybeGetSimpleName()

If this type pattern has no '.' or '*' in it, then return a simple string otherwise, this will return null;

private TypePattern
maybeResolveToAnyPattern(IScope scope, Bindings bindings, boolean allowBinding, boolean requireExactType)

private TypePattern
maybeResolveToBindingTypePattern(IScope scope, Bindings bindings, boolean allowBinding, boolean requireExactType)

private static boolean
outOfStar(final NamePattern[] pattern, final char[][] target, int pi, int ti, int pLeft, int tLeft, final int starsLeft)

public TypePattern
parameterizeWith(Map<String, UnresolvedType> typeVariableMap, World w)

Implements abstract org.aspectj.weaver.patterns.TypePattern.parameterizeWith.

return a version of this type pattern in which all type variable references have been replaced by their corresponding entry in the map.
private String[]

Returns:

those possible matches which I match exactly the last element of
preMatch
(String[] possibleMatches)

public static TypePattern
public static TypePattern
public static TypePattern
public TypePattern
resolveBindings(IScope scope, Bindings bindings, boolean allowBinding, boolean requireExactType)

Overrides org.aspectj.weaver.patterns.TypePattern.resolveBindings.

Need to determine if I'm really a pattern or a reference to a formal We may wish to further optimize the case of pattern vs. non-pattern We will be replaced by what we return
private TypePattern
resolveBindingsForExactType(IScope scope, UnresolvedType aType, String fullyQualifiedName, boolean requireExactType)

private TypePattern
resolveBindingsForMissingType(ResolvedType typeFoundInWholeWorldSearch, String nameWeLookedFor, IScope scope, Bindings bindings, boolean allowBinding, boolean requireExactType)

private TypePattern
resolveBindingsForTypeVariable(IScope scope, UnresolvedTypeVariableReferenceType tvrType)

We resolved the type to a type variable declared in the pointcut designator.

private TypePattern
resolveBindingsFromFullyQualifiedTypeName(String fullyQualifiedName, IScope scope, Bindings bindings, boolean allowBinding, boolean requireExactType)

private TypePattern
private TypePattern
resolveParameterizedType(IScope scope, UnresolvedType aType, boolean requireExactType)

public void
public static char[][]
splitNames(String s, boolean convertDollar)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
private boolean
verifyTypeParameters(ResolvedType baseType, IScope scope, boolean requireExactType)

When this method is called, we have resolved the base type to an exact type.

public void
Inherited from org.aspectj.weaver.patterns.TypePattern:
getAnnotationPatterngetExactTypegetTypeParametersisBangVoidisEllipsisisIncludeSubtypesisStarAnnotationisVarArgsisVoidmatchesmatchesStaticallymatchesSubtypesmatchesSubtypesnotExactTypepostReadremapAdviceFormalsresolveresolveExactTypesetAnnotationTypePatternsetTypeParameters

Field Detail

additionalInterfaceBoundsback to summary
pack-priv TypePattern[] additionalInterfaceBounds
boundscheckingoffback to summary
public static boolean boundscheckingoff
dimback to summary
pack-priv int dim
ellipsisCountback to summary
pack-priv int ellipsisCount
failedResolutionback to summary
private boolean failedResolution
GENERIC_WILDCARD_CHARACTERback to summary
private static final String GENERIC_WILDCARD_CHARACTER
GENERIC_WILDCARD_SIGNATURE_CHARACTERback to summary
private static final String GENERIC_WILDCARD_SIGNATURE_CHARACTER
importedPrefixesback to summary
pack-priv String[] importedPrefixes
isGenericback to summary
private boolean isGeneric
knownMatchesback to summary
pack-priv String[] knownMatches
lowerBoundback to summary
pack-priv TypePattern lowerBound
namePatternsback to summary
private NamePattern[] namePatterns
upperBoundback to summary
pack-priv TypePattern upperBound
VERSIONback to summary
private static final byte VERSION

Constructor Detail

WildTypePatternback to summary
pack-priv WildTypePattern(NamePattern[] namePatterns, boolean includeSubtypes, int dim, boolean isVarArgs, TypePatternList typeParams)
WildTypePatternback to summary
public WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim)
WildTypePatternback to summary
public WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos)
WildTypePatternback to summary
public WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg)
WildTypePatternback to summary
public WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg, TypePatternList typeParams, TypePattern upperBound, TypePattern[] additionalInterfaceBounds, TypePattern lowerBound)
WildTypePatternback to summary
public WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg, TypePatternList typeParams)

Method Detail

acceptback to summary
public Object accept(PatternNodeVisitor visitor, Object data)

Implements abstract org.aspectj.weaver.patterns.PatternNode.accept.

Annotations
@Override
couldEverMatchSameTypesAsback to summary
protected boolean couldEverMatchSameTypesAs(TypePattern other)

Overrides org.aspectj.weaver.patterns.TypePattern.couldEverMatchSameTypesAs.

Annotations
@Override
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
extractNameback to summary
public NamePattern extractName()
getAdditionalIntefaceBoundsback to summary
public TypePattern[] getAdditionalIntefaceBounds()
getDimensionsback to summary
public int getDimensions()

Overrides org.aspectj.weaver.patterns.TypePattern.getDimensions.

Used in conjunction with checks on 'isStar()' to tell you if this pattern represents '*' or '*[]' which are different !

getLowerBoundback to summary
public TypePattern getLowerBound()
getNamePatternsback to summary
public NamePattern[] getNamePatterns()
getUpperBoundback to summary
public TypePattern getUpperBound()
hasFailedResolutionback to summary
public boolean hasFailedResolution()

Overrides org.aspectj.weaver.patterns.TypePattern.hasFailedResolution.

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
innerMatchesExactlyback to summary
private boolean innerMatchesExactly(String s, boolean isAnonymous, boolean convertDollar)
inStarback to summary
private static boolean inStar(final NamePattern[] pattern, final char[][] target, int pi, int ti, final int pLeft, int tLeft, int starsLeft)
isArrayback to summary
public boolean isArray()

Overrides org.aspectj.weaver.patterns.TypePattern.isArray.

Annotations
@Override
isNamePatternStarback to summary
private boolean isNamePatternStar()
isStarback to summary
public boolean isStar()

Overrides org.aspectj.weaver.patterns.TypePattern.isStar.

Annotations
@Override
lastIndexOfDotOrDollarback to summary
private int lastIndexOfDotOrDollar(String string)
lookupTypeInScopeback to summary
private UnresolvedType lookupTypeInScope(IScope scope, String typeName, IHasPosition location)
lookupTypeInWorldback to summary
private ResolvedType lookupTypeInWorld(World world, String typeName)
lookupTypeInWorldIncludingPrefixesback to summary
private ResolvedType lookupTypeInWorldIncludingPrefixes(World world, String typeName, String[] prefixes)

Searches the world for the ResolvedType with the given typeName. If one isn't found then for each of the supplied prefixes, it prepends the typeName with the prefix and searches the world for the ResolvedType with this new name. If one still isn't found then a MissingResolvedTypeWithKnownSignature is returned with the originally requested typeName (this ensures the typeName makes sense).

matchesArrayback to summary
protected boolean matchesArray(UnresolvedType type)

Implements abstract org.aspectj.weaver.patterns.TypePattern.matchesArray.

Annotations
@Override
matchesBoundsback to summary
private boolean matchesBounds(ResolvedType aType, TypePattern.MatchKind staticOrDynamic)
matchesExactlyback to summary
protected boolean matchesExactly(ResolvedType type)

Implements abstract org.aspectj.weaver.patterns.TypePattern.matchesExactly.

Annotations
@Override
See Also
org.aspectj.weaver.patterns.TypePattern#matchesExactly(ResolvedType)
matchesExactlyback to summary
protected boolean matchesExactly(ResolvedType type, ResolvedType annotatedType)

Implements abstract org.aspectj.weaver.patterns.TypePattern.matchesExactly.

Annotations
@Override
matchesExactlyByNameback to summary
private boolean matchesExactlyByName(String targetTypeName, boolean isAnonymous, boolean isNested)
matchesInstanceofback to summary
public FuzzyBoolean matchesInstanceof(ResolvedType type)

Implements abstract org.aspectj.weaver.patterns.TypePattern.matchesInstanceof.

Annotations
@Override
See Also
org.aspectj.weaver.patterns.TypePattern#matchesInstanceof(ResolvedType)
matchesParametersback to summary
private boolean matchesParameters(ResolvedType aType, TypePattern.MatchKind staticOrDynamic)
maybeExtractNameback to summary
public boolean maybeExtractName(String string)

Method maybeExtractName.

Returns:boolean

boolean

maybeGetCleanNameback to summary
public String maybeGetCleanName()

If this type pattern has no '*' or '..' in it

maybeGetSimpleNameback to summary
public String maybeGetSimpleName()

If this type pattern has no '.' or '*' in it, then return a simple string otherwise, this will return null;

maybeResolveToAnyPatternback to summary
private TypePattern maybeResolveToAnyPattern(IScope scope, Bindings bindings, boolean allowBinding, boolean requireExactType)
maybeResolveToBindingTypePatternback to summary
private TypePattern maybeResolveToBindingTypePattern(IScope scope, Bindings bindings, boolean allowBinding, boolean requireExactType)
outOfStarback to summary
private static boolean outOfStar(final NamePattern[] pattern, final char[][] target, int pi, int ti, int pLeft, int tLeft, final int starsLeft)
parameterizeWithback to summary
public TypePattern parameterizeWith(Map<String, UnresolvedType> typeVariableMap, World w)

Implements abstract org.aspectj.weaver.patterns.TypePattern.parameterizeWith.

Doc from org.aspectj.weaver.patterns.TypePattern.parameterizeWith.

return a version of this type pattern in which all type variable references have been replaced by their corresponding entry in the map.

Annotations
@Override
preMatchback to summary
private String[] preMatch(String[] possibleMatches)
Returns:String[]

those possible matches which I match exactly the last element of

readback to summary
public static TypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException

Hides org.aspectj.weaver.patterns.TypePattern.read.

readTypePattern150back to summary
public static TypePattern readTypePattern150(VersionedDataInputStream s, ISourceContext context) throws IOException
readTypePatternOldStyleback to summary
public static TypePattern readTypePatternOldStyle(VersionedDataInputStream s, ISourceContext context) throws IOException
resolveBindingsback to summary
public TypePattern resolveBindings(IScope scope, Bindings bindings, boolean allowBinding, boolean requireExactType)

Overrides org.aspectj.weaver.patterns.TypePattern.resolveBindings.

Need to determine if I'm really a pattern or a reference to a formal We may wish to further optimize the case of pattern vs. non-pattern We will be replaced by what we return

Annotations
@Override
resolveBindingsForExactTypeback to summary
private TypePattern resolveBindingsForExactType(IScope scope, UnresolvedType aType, String fullyQualifiedName, boolean requireExactType)
resolveBindingsForMissingTypeback to summary
private TypePattern resolveBindingsForMissingType(ResolvedType typeFoundInWholeWorldSearch, String nameWeLookedFor, IScope scope, Bindings bindings, boolean allowBinding, boolean requireExactType)
resolveBindingsForTypeVariableback to summary
private TypePattern resolveBindingsForTypeVariable(IScope scope, UnresolvedTypeVariableReferenceType tvrType)

We resolved the type to a type variable declared in the pointcut designator. Now we have to create either an exact type pattern or a wild type pattern for it, with upper and lower bounds set accordingly. XXX none of this stuff gets serialized yet

resolveBindingsFromFullyQualifiedTypeNameback to summary
private TypePattern resolveBindingsFromFullyQualifiedTypeName(String fullyQualifiedName, IScope scope, Bindings bindings, boolean allowBinding, boolean requireExactType)
resolveGenericWildcardback to summary
private TypePattern resolveGenericWildcard(IScope scope, UnresolvedType aType)
resolveParameterizedTypeback to summary
private TypePattern resolveParameterizedType(IScope scope, UnresolvedType aType, boolean requireExactType)
setIsVarArgsback to summary
public void setIsVarArgs(boolean isVarArgs)

Overrides org.aspectj.weaver.patterns.TypePattern.setIsVarArgs.

Annotations
@Override
splitNamesback to summary
public static char[][] splitNames(String s, boolean convertDollar)
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
verifyTypeParametersback to summary
private boolean verifyTypeParameters(ResolvedType baseType, IScope scope, boolean requireExactType)

When this method is called, we have resolved the base type to an exact type. We also have a set of type patterns for the parameters. Time to perform some basic checks: - can the base type be parameterized? (is it generic) - can the type parameter pattern list match the number of parameters on the base type - do all parameter patterns meet the bounds of the respective type variables If any of these checks fail, a warning message is issued and we return false.

writeback to summary
public void write(CompressingDataOutputStream s) throws IOException

Implements abstract org.aspectj.weaver.patterns.PatternNode.write.

Annotations
@Override
org.aspectj.weaver.patterns back to summary

pack-priv Class WildTypePattern.VerifyBoundsForTypePattern

extends Object
implements IVerificationRequired
Class Inheritance
  • java.lang.Object
  • org.aspectj.weaver.patterns.WildTypePattern.VerifyBoundsForTypePattern
All Implemented Interfaces
org.aspectj.weaver.patterns.IVerificationRequired

By capturing the verification in this class, rather than performing it in verifyTypeParameters(), we can cope with situations where the interactions between generics and declare parents would otherwise cause us problems. For example, if verifying as we go along we may report a problem which would have been fixed by a declare parents that we haven't looked at yet. If we create and store a verification object, we can verify this later when the type system is considered 'complete'

Field Summary

Modifier and TypeField and Description
private final ResolvedType
private final boolean
private final IScope
private final ISourceLocation
private TypePatternList

Constructor Summary

AccessConstructor and Description
public
VerifyBoundsForTypePattern(IScope scope, ResolvedType genericType, boolean requireExactType, TypePatternList typeParameters, ISourceLocation sLoc)

Method Summary

Modifier and TypeMethod and Description
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

genericTypeback to summary
private final ResolvedType genericType
requireExactTypeback to summary
private final boolean requireExactType
scopeback to summary
private final IScope scope
sLocback to summary
private final ISourceLocation sLoc
typeParametersback to summary
private TypePatternList typeParameters

Constructor Detail

VerifyBoundsForTypePatternback to summary
public VerifyBoundsForTypePattern(IScope scope, ResolvedType genericType, boolean requireExactType, TypePatternList typeParameters, ISourceLocation sLoc)

Method Detail

verifyback to summary
public void verify()

Implements org.aspectj.weaver.patterns.IVerificationRequired.verify.