/** * returns the resolved signature of the thing under this shadow * */ public ResolvedMember getResolvedSignature() { if (resolvedSignature == null) { resolvedSignature = signature.resolve(getIWorld()); } return resolvedSignature; }
/** Actually implement the (non-empty) mungers associated with this shadow */ private void implementMungers() { World world = getIWorld(); for (ShadowMunger munger : mungers) { if (munger.implementOn(this)) { world.reportMatch(munger, this); } } }
public ResolvedType[] getArgumentTypesForArrayConstructionShadow() { String s = signature.getDeclaringType().getSignature(); int pos = s.indexOf("["); int dims = 1; while (pos < s.length()) { pos++; if (pos < s.length()) { dims += (s.charAt(pos) == '[' ? 1 : 0); } } ResolvedType intType = UnresolvedType.INT.resolve(this.getIWorld()); if (dims == 1) { return new ResolvedType[] { intType }; } ResolvedType[] someInts = new ResolvedType[dims]; for (int i = 0; i < dims; i++) { someInts[i] = intType; } return someInts; }
protected FuzzyBoolean matchInternal(Shadow shadow) { Member member = shadow.getEnclosingCodeSignature(); ResolvedMember rMember = member.resolve(shadow.getIWorld()); if (rMember == null) { if (member.getName().startsWith(NameMangler.PREFIX)) { return FuzzyBoolean.NO; } shadow.getIWorld().getLint().unresolvableMember.signal(member.toString(), getSourceLocation()); return FuzzyBoolean.NO; } annotationTypePattern.resolve(shadow.getIWorld()); return annotationTypePattern.matches(rMember); }
protected FuzzyBoolean matchInternal(Shadow shadow) { if (shadow.getKind() != Shadow.ExceptionHandler) { return FuzzyBoolean.NO; } exceptionType.resolve(shadow.getIWorld()); // we know we have exactly one parameter since we're checking an exception handler return exceptionType.matches(shadow.getSignature().getParameterTypes()[0].resolve(shadow.getIWorld()), TypePattern.STATIC); }
protected FuzzyBoolean matchInternal(Shadow shadow) { // This will not match code in local or anonymous classes as if // they were withincode of the outer signature return FuzzyBoolean.fromBoolean(signature.matches(shadow.getEnclosingCodeSignature(), shadow.getIWorld(), false)); }
@Override protected FuzzyBoolean matchInternal(Shadow shadow) { if (!couldMatch(shadow)) { return FuzzyBoolean.NO; } ResolvedType toMatchAgainst = (isThis ? shadow.getThisType() : shadow.getTargetType()).resolve(shadow.getIWorld()); annotationTypePattern.resolve(shadow.getIWorld()); if (annotationTypePattern.matchesRuntimeType(toMatchAgainst).alwaysTrue()) { return FuzzyBoolean.YES; } else { // a subtype may match at runtime return FuzzyBoolean.MAYBE; } }
protected FuzzyBoolean matchInternal(Shadow shadow) { ResolvedType enclosingType = shadow.getIWorld().resolve(shadow.getEnclosingType(), true); if (enclosingType.isMissing()) { shadow.getIWorld().getLint().cantFindType.signal(new String[] { WeaverMessages.format( WeaverMessages.CANT_FIND_TYPE_WITHINPCD, shadow.getEnclosingType().getName()) }, shadow.getSourceLocation(), new ISourceLocation[] { getSourceLocation() }); } typePattern.resolve(shadow.getIWorld()); return isWithinType(enclosingType); }
@Override protected FuzzyBoolean matchInternal(Shadow shadow) { ResolvedType enclosingType = shadow.getIWorld().resolve(shadow.getEnclosingType(), true); if (enclosingType.isMissing()) { shadow.getIWorld().getLint().cantFindType.signal(new String[] { WeaverMessages.format( WeaverMessages.CANT_FIND_TYPE_WITHINPCD, shadow.getEnclosingType().getName()) }, shadow.getSourceLocation(), new ISourceLocation[] { getSourceLocation() }); // IMessage msg = new Message( // WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_WITHINPCD, // shadow.getEnclosingType().getName()), // shadow.getSourceLocation(),true,new ISourceLocation[]{getSourceLocation()}); // shadow.getIWorld().getMessageHandler().handleMessage(msg); } annotationTypePattern.resolve(shadow.getIWorld()); return annotationTypePattern.matches(enclosingType); }
/** * Residue is the remainder of the pointcut match that couldn't be performed with the purely static information at compile time * and this method returns the residue of a pointcut at a particular shadow. */ @Override protected Test findResidueInternal(Shadow shadow, ExposedState state) { if (!couldMatch(shadow)) { return Literal.FALSE; } // if no preference is specified, just say TRUE which means no residue if (typePattern == TypePattern.ANY) { return Literal.TRUE; } Var var = isThis ? shadow.getThisVar() : shadow.getTargetVar(); return exposeStateForVar(var, typePattern, state, shadow.getIWorld()); }
@Override protected FuzzyBoolean matchInternal(Shadow shadow) { ResolvedType enclosingType = shadow.getIWorld().resolve(shadow.getEnclosingType(), true); if (enclosingType.isMissing()) { // PTWIMPL ?? Add a proper message IMessage msg = new Message("Cant find type pertypewithin matching...", shadow.getSourceLocation(), true, new ISourceLocation[] { getSourceLocation() }); shadow.getIWorld().getMessageHandler().handleMessage(msg); } // See pr106554 - we can't put advice calls in an interface when the // advice is defined // in a pertypewithin aspect - the JPs only exist in the static // initializer and can't // call the localAspectOf() method. if (enclosingType.isInterface()) { return FuzzyBoolean.NO; } if (!(enclosingType.canBeSeenBy(inAspect) || inAspect.isPrivilegedAspect())) { return FuzzyBoolean.NO; } typePattern.resolve(shadow.getIWorld()); return isWithinType(enclosingType); }
private void sortMungers() { List sorted = PartialOrder.sort(mungers); // Bunch of code to work out whether to report xlints for advice that isn't ordered at this Joinpoint possiblyReportUnorderedAdvice(sorted); if (sorted == null) { // this means that we have circular dependencies for (ShadowMunger m : mungers) { getIWorld().getMessageHandler().handleMessage( MessageUtil.error(WeaverMessages.format(WeaverMessages.CIRCULAR_DEPENDENCY, this), m.getSourceLocation())); } } mungers = sorted; }
ResolvedType[] argumentsToMatchAgainst = shadow.getIWorld().resolve(shadow.getGenericArgTypes());
@Override protected FuzzyBoolean matchInternal(Shadow shadow) { if (!couldMatch(shadow)) { return FuzzyBoolean.NO; } UnresolvedType typeToMatch = isThis ? shadow.getThisType() : shadow.getTargetType(); // optimization for case of this(Object) or target(Object) // works for an ExactTypePattern (and we know there are no annotations to match here of course) if (typePattern.getExactType().equals(ResolvedType.OBJECT)) { return FuzzyBoolean.YES; } return typePattern.matches(typeToMatch.resolve(shadow.getIWorld()), TypePattern.DYNAMIC); }
@Override protected FuzzyBoolean matchInternal(Shadow shadow) { if (shadow.getKind() != kind) { return FuzzyBoolean.NO; } if (shadow.getKind() == Shadow.SynchronizationLock && kind == Shadow.SynchronizationLock) { return FuzzyBoolean.YES; } if (shadow.getKind() == Shadow.SynchronizationUnlock && kind == Shadow.SynchronizationUnlock) { return FuzzyBoolean.YES; } if (!signature.matches(shadow.getMatchingSignature(), shadow.getIWorld(), this.kind == Shadow.MethodCall)) { if (kind == Shadow.MethodCall) { warnOnConfusingSig(shadow); // warnOnBridgeMethod(shadow); } return FuzzyBoolean.NO; } return FuzzyBoolean.YES; }
protected boolean checkCanThrow(ShadowMunger munger, ResolvedType resolvedTypeX) { if (getKind() == ExceptionHandler) { // XXX much too lenient rules here, need to walk up exception handlers return true; } if (!isDeclaredException(resolvedTypeX, getSignature())) { getIWorld().showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.CANT_THROW_CHECKED, resolvedTypeX, this), // from // advice // in // \ // '" // + // munger // . // + // "\'" // , getSourceLocation(), munger.getSourceLocation()); } return true; }
/** * The guard here is going to be the hasAnnotation() test - if it gets through (which we cannot determine until runtime) then we * must have a TypeAnnotationAccessVar in place - this means we must *always* have one in place. */ @Override protected Test findResidueInternal(Shadow shadow, ExposedState state) { if (!couldMatch(shadow)) { return Literal.FALSE; } boolean alwaysMatches = match(shadow).alwaysTrue(); Var var = isThis ? shadow.getThisVar() : shadow.getTargetVar(); Var annVar = null; // Are annotations being bound? UnresolvedType annotationType = annotationTypePattern.annotationType; if (annotationTypePattern instanceof BindingAnnotationTypePattern) { BindingAnnotationTypePattern btp = (BindingAnnotationTypePattern) annotationTypePattern; annotationType = btp.annotationType; annVar = isThis ? shadow.getThisAnnotationVar(annotationType) : shadow.getTargetAnnotationVar(annotationType); if (annVar == null) { throw new RuntimeException("Impossible!"); } state.set(btp.getFormalIndex(), annVar); } if (alwaysMatches && (annVar == null)) {// change check to verify if its the 'generic' annVar that is being used return Literal.TRUE; } else { ResolvedType rType = annotationType.resolve(shadow.getIWorld()); return Test.makeHasAnnotation(var, rType); } }
UnresolvedType argType = shadow.getGenericArgTypes()[i]; TypePattern type = patterns[i]; ResolvedType argRTX = shadow.getIWorld().resolve(argType, true); if (!(type instanceof BindingTypePattern)) { if (argRTX.isMissing()) { shadow.getIWorld().getLint().cantFindType.signal(new String[] { WeaverMessages.format( WeaverMessages.CANT_FIND_TYPE_ARG_TYPE, argType.getName()) }, shadow.getSourceLocation(), new ISourceLocation[] { getSourceLocation() }); World world = shadow.getIWorld(); ResolvedType typeToExpose = type.getExactType().resolve(world); if (typeToExpose.isParameterizedType()) { ret = Test.makeAnd(ret, exposeStateForVar(shadow.getArgVar(i), type, state, shadow.getIWorld()));