if (advice.lastReportedMonitorExitJoinpointLocation == null) { advice.lastReportedMonitorExitJoinpointLocation = shadow.getSourceLocation(); } else { if (areTheSame(shadow.getSourceLocation(), advice.lastReportedMonitorExitJoinpointLocation)) { advice.lastReportedMonitorExitJoinpointLocation = shadow.getSourceLocation(); if (advice.getKind().equals(AdviceKind.Softener)) { msg = WeaveMessage.constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_SOFTENS, new String[] { advisedType, beautifyLocation(shadow.getSourceLocation()), advisingType, beautifyLocation(munger.getSourceLocation()) }, advisedType, advisingType); } else { msg = WeaveMessage .constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_ADVISES, new String[] { joinPointDescription, advisedType, beautifyLocation(shadow.getSourceLocation()), description, advisingType, beautifyLocation(munger.getSourceLocation()), (runtimeTest ? " [with runtime test]" : "") }, advisedType, advisingType);
return shadow.getSignature().getName(); } else if (key.equalsIgnoreCase("joinpoint.sourcelocation.sourcefile")) { ISourceLocation loc = shadow.getSourceLocation(); if ((loc != null) && (loc.getSourceFile() != null)) { return loc.getSourceFile().toString(); ISourceLocation loc = shadow.getSourceLocation(); if (loc != null) { return Integer.toString(loc.getLine());
String aspect2 = element.substring(element.indexOf(":") + 1); getIWorld().getLint().unorderedAdviceAtShadow.signal(new String[] { this.toString(), aspect1, aspect2 }, this.getSourceLocation(), null);
@Override protected Test findResidueInternal(Shadow shadow, ExposedState state) { if (annotationTypePattern instanceof BindingAnnotationTypePattern) { BindingAnnotationTypePattern btp = (BindingAnnotationTypePattern) annotationTypePattern; UnresolvedType annotationType = btp.annotationType; Var var = shadow.getWithinAnnotationVar(annotationType); // This should not happen, we shouldn't have gotten this far // if we weren't going to find the annotation if (var == null) { throw new BCException("Impossible! annotation=[" + annotationType + "] shadow=[" + shadow + " at " + shadow.getSourceLocation() + "] pointcut is at [" + getSourceLocation() + "]"); } state.set(btp.getFormalIndex(), var); } return match(shadow).alwaysTrue() ? Literal.TRUE : Literal.FALSE; }
.equals(node.getBytecodeName())) && shadowSig.getSignature().equals(node.getBytecodeSignature()) && sourceLinesMatch(node.getSourceLocation(), shadow.getSourceLocation())) { return node; ISourceLocation sl = shadow.getSourceLocation();
protected Test findResidueInternal(Shadow shadow, ExposedState state) { if (annotationTypePattern instanceof BindingAnnotationTypePattern) { BindingAnnotationTypePattern btp = (BindingAnnotationTypePattern) annotationTypePattern; UnresolvedType annotationType = btp.annotationType; Var var = shadow.getWithinCodeAnnotationVar(annotationType); // This should not happen, we shouldn't have gotten this far // if we weren't going to find the annotation if (var == null) { throw new BCException("Impossible! annotation=[" + annotationType + "] shadow=[" + shadow + " at " + shadow.getSourceLocation() + "] pointcut is at [" + getSourceLocation() + "]"); } state.set(btp.getFormalIndex(), var); } if (matchInternal(shadow).alwaysTrue()) { return Literal.TRUE; } else { return Literal.FALSE; } }
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; }
protected FuzzyBoolean matchInternal(Shadow shadow) { // ??? this is not maximally efficient // Check we'll be able to do the residue! // this bit is for pr145693 - we cannot match at all if one of the types is missing, we will be unable // to create the residue if (slots != null) { for (Slot slot: slots) { ResolvedType rt = slot.formalType; if (rt.isMissing()) { ISourceLocation[] locs = new ISourceLocation[] { getSourceLocation() }; Message m = new Message(WeaverMessages.format(WeaverMessages.MISSING_TYPE_PREVENTS_MATCH, rt.getName()), "", Message.WARNING, shadow.getSourceLocation(), null, locs); rt.getWorld().getMessageHandler().handleMessage(m); return FuzzyBoolean.NO; } } } return FuzzyBoolean.MAYBE; }
@Override public void reportCheckerMatch(Checker checker, Shadow shadow) { IMessage iMessage = new Message(checker.getMessage(shadow), shadow.toString(), checker.isError() ? IMessage.ERROR : IMessage.WARNING, shadow.getSourceLocation(), null, new ISourceLocation[] { checker.getSourceLocation() }, true, 0, -1, -1); getMessageHandler().handleMessage(iMessage); if (getCrossReferenceHandler() != null) { getCrossReferenceHandler() .addCrossReference( checker.getSourceLocation(), shadow.getSourceLocation(), (checker.isError() ? IRelationship.Kind.DECLARE_ERROR.getName() : IRelationship.Kind.DECLARE_WARNING .getName()), false); } if (getModel() != null) { AsmRelationshipProvider.addDeclareErrorOrWarningRelationship(getModelAsAsmManager(), shadow, checker); } }
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 public void reportMatch(ShadowMunger munger, Shadow shadow) { if (getCrossReferenceHandler() != null) { getCrossReferenceHandler().addCrossReference(munger.getSourceLocation(), // What is being applied shadow.getSourceLocation(), // Where is it being applied determineRelKind(munger).getName(), // What kind of advice? ((Advice) munger).hasDynamicTests() // Is a runtime test being stuffed in the code? ); } if (!getMessageHandler().isIgnoring(IMessage.WEAVEINFO)) { reportWeavingMessage(munger, shadow); } if (getModel() != null) { AsmRelationshipProvider.addAdvisedRelationship(getModelAsAsmManager(), shadow, munger); } }
@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); }
@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); }
if (kind.isAfter() || kind == AdviceKind.Around) { world.showMessage(IMessage.WARNING, WeaverMessages.format(WeaverMessages.ONLY_BEFORE_ON_HANDLER), getSourceLocation(), shadow.getSourceLocation()); return false; getSourceLocation(), shadow.getSourceLocation()); return false; if (shadow.getKind() == Shadow.PreInitialization) { world.showMessage(IMessage.WARNING, WeaverMessages.format(WeaverMessages.AROUND_ON_PREINIT), getSourceLocation(), shadow.getSourceLocation()); return false; } else if (shadow.getKind() == Shadow.Initialization) { world.showMessage(IMessage.WARNING, WeaverMessages.format(WeaverMessages.AROUND_ON_INIT), getSourceLocation(), shadow.getSourceLocation()); return false; } else if (shadow.getKind() == Shadow.StaticInitialization && shadow.getEnclosingType().resolve(world).isInterface()) { world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.AROUND_ON_INTERFACE_STATICINIT, shadow .getEnclosingType().getName()), getSourceLocation(), shadow.getSourceLocation()); return false; } else { String s = shadow.toString(); String s2 = WeaverMessages.format(WeaverMessages.NON_VOID_RETURN, s); world.showMessage(IMessage.ERROR, s2, getSourceLocation(), shadow.getSourceLocation()); return false; world.getLint().uncheckedAdviceConversion.signal(
/** * In after returning advice if we are binding the extra parameter to a parameterized type we may not be able to do a type-safe * conversion. * * @param resolvedExtraParameterType the type in the after returning declaration * @param shadowReturnType the type at the shadow * @param world */ private void maybeIssueUncheckedMatchWarning(ResolvedType afterReturningType, ResolvedType shadowReturnType, Shadow shadow, World world) { boolean inDoubt = !afterReturningType.isAssignableFrom(shadowReturnType); if (inDoubt && world.getLint().uncheckedArgument.isEnabled()) { String uncheckedMatchWith = afterReturningType.getSimpleBaseName(); if (shadowReturnType.isParameterizedType() && (shadowReturnType.getRawType() == afterReturningType.getRawType())) { uncheckedMatchWith = shadowReturnType.getSimpleName(); } if (!Utils.isSuppressing(getSignature().getAnnotations(), "uncheckedArgument")) { world.getLint().uncheckedArgument.signal(new String[] { afterReturningType.getSimpleName(), uncheckedMatchWith, afterReturningType.getSimpleBaseName(), shadow.toResolvedString(world) }, getSourceLocation(), new ISourceLocation[] { shadow.getSourceLocation() }); } } }
return; if (affectedShadow.getSourceLocation() == null || deow.getSourceLocation() == null) { return;
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.getLint().uncheckedArgument.signal(new String[] { typeToExpose.getSimpleName(), uncheckedMatchWith, typeToExpose.getSimpleBaseName(), shadow.toResolvedString(world) }, getSourceLocation(), new ISourceLocation[] { shadow.getSourceLocation() });
Lint.Kind err = shadow.getIWorld().getLint().shadowNotInStructure; if (err.isEnabled()) { err.signal(shadow.toString(), shadow.getSourceLocation());
if (rArgType.isMissing()) { shadow.getIWorld().getLint().cantFindType.signal(new String[] { WeaverMessages.format( WeaverMessages.CANT_FIND_TYPE_ARG_TYPE, argType.getName()) }, shadow.getSourceLocation(), new ISourceLocation[] { getSourceLocation() });
shadow.getIWorld().getLint().unmatchedSuperTypeInCall.signal(new String[] { shadow.getSignature().getDeclaringType().toString(), signature.getDeclaringType().toString() }, this.getSourceLocation(), new ISourceLocation[] { shadow.getSourceLocation() });