org.aspectj.weaver.patterns
Class HasMemberTypePatternForPerThisMatching

java.lang.Object
  extended by org.aspectj.weaver.patterns.PatternNode
      extended by org.aspectj.weaver.patterns.TypePattern
          extended by org.aspectj.weaver.patterns.HasMemberTypePattern
              extended by org.aspectj.weaver.patterns.HasMemberTypePatternForPerThisMatching
All Implemented Interfaces:
IHasPosition, IHasSourceLocation

public class HasMemberTypePatternForPerThisMatching
extends HasMemberTypePattern

pr354470. This is a special subtype of HasMemberTypePattern. In order to optimize this situation:

 aspect X perthis(transactional()) {
pointcut transactional: execution(@Foo * *(..));

When this occurs we obviously only want an aspect instance when there is a method annotated with @Foo. For a regular execution pointcut we couldn't really do this due to the multiple joinpoint signatures for each joinpoint (and so lots of types get the ajcMightHaveAspect interface). However, for an execution pointcut involving an annotation we can do something clever. Annotations must match against the first primary joinpoint signature - so when computing the type pattern to use for matching when processing the perthis() clause above, we can use the HasMemberTypePattern - because that effectively does what we want. We want an aspect instance if the type hasmethod(...) with the appropriate annotation. This would be great... but breaks in the face of ITDs. If the method that hasmethod() would match is introduced via an ITD we come unstuck, the code in HasMemberTypePattern.hasMethod() does look at ITDs but it won't see annotations, they aren't visible (at least through EclipseResolvedMember objects). And so this subclass is created to say 'if the supertype thinks it is a match, great, but if it doesnt then if there are ITDs on the target, they might match so just say 'true''. Note that returning true is just confirming whether the 'mightHaveAspect' interface (and friends) are getting added.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.aspectj.weaver.patterns.TypePattern
TypePattern.MatchKind
 
Field Summary
 
Fields inherited from class org.aspectj.weaver.patterns.TypePattern
AND, annotationPattern, ANY, ANY_KEY, ANY_WITH_ANNO, BINDING, DYNAMIC, ELLIPSIS, ELLIPSIS_KEY, EXACT, HAS_MEMBER, includeSubtypes, isVarArgs, NO, NO_KEY, NOT, OR, STATIC, TYPE_CATEGORY, typeParameters, WILD
 
Fields inherited from class org.aspectj.weaver.patterns.PatternNode
end, sourceContext, start
 
Constructor Summary
HasMemberTypePatternForPerThisMatching(SignaturePattern aSignaturePattern)
           
 
Method Summary
protected  boolean hasMethod(ResolvedType type)
           
 void write(CompressingDataOutputStream s)
           
 
Methods inherited from class org.aspectj.weaver.patterns.HasMemberTypePattern
accept, equals, getSignaturePattern, hashCode, matchesExactly, matchesExactly, matchesInstanceof, parameterizeWith, read, resolveBindings, toString
 
Methods inherited from class org.aspectj.weaver.patterns.TypePattern
couldEverMatchSameTypesAs, getAnnotationPattern, getExactType, getTypeParameters, hasFailedResolution, isArray, isBangVoid, isEllipsis, isIncludeSubtypes, isStar, isStarAnnotation, isVarArgs, isVoid, matches, matchesStatically, matchesSubtypes, matchesSubtypes, notExactType, postRead, remapAdviceFormals, resolve, resolveExactType, setAnnotationTypePattern, setIsVarArgs, setTypeParameters
 
Methods inherited from class org.aspectj.weaver.patterns.PatternNode
copyLocationFrom, getEnd, getFileName, getSourceContext, getSourceLocation, getStart, readLocation, setLocation, traverse, writeLocation
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HasMemberTypePatternForPerThisMatching

public HasMemberTypePatternForPerThisMatching(SignaturePattern aSignaturePattern)
Method Detail

hasMethod

protected boolean hasMethod(ResolvedType type)
Overrides:
hasMethod in class HasMemberTypePattern

write

public void write(CompressingDataOutputStream s)
           throws java.io.IOException
Overrides:
write in class HasMemberTypePattern
Throws:
java.io.IOException