/** * Only does the check if the munger requires it (@AJ aspects don't) * * @param munger * @return */ protected boolean checkMunger(ShadowMunger munger) { if (munger.mustCheckExceptions()) { for (Iterator<ResolvedType> i = munger.getThrownExceptions().iterator(); i.hasNext();) { if (!checkCanThrow(munger, i.next())) { return false; } } } return true; }
public void addMunger(ShadowMunger munger) { if (checkMunger(munger)) { if (mungers == Collections.EMPTY_LIST) { mungers = new ArrayList<ShadowMunger>(); } this.mungers.add(munger); } }
protected FuzzyBoolean matchInternal(Shadow shadow) { arguments.resolve(shadow.getIWorld()); FuzzyBoolean ret = arguments.matches(shadow.getIWorld().resolve(shadow.getArgTypes())); return ret; }
public UnresolvedType[] getGenericArgTypes() { if (isShadowForArrayConstructionJoinpoint()) { return getArgumentTypesForArrayConstructionShadow(); } if (isShadowForMonitor()) { return UnresolvedType.ARRAY_WITH_JUST_OBJECT; } if (getKind() == FieldSet) { return new UnresolvedType[] { getResolvedSignature().getGenericReturnType() }; } return getResolvedSignature().getGenericParameterTypes(); }
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)); }
protected static IProgramElement getNode(AsmManager model, Shadow shadow) { Member enclosingMember = shadow.getEnclosingCodeSignature(); enclosingNode = lookupMember(model.getHierarchy(), shadow.getEnclosingType(), enclosingMember); } else { UnresolvedType type = enclosingMember.getDeclaringType(); enclosingNode = lookupMember(model.getHierarchy(), shadow.getEnclosingType(), enclosingMember); } else { enclosingNode = lookupMember(model.getHierarchy(), shadow.getEnclosingType(), actualEnclosingMember); enclosingNode = lookupMember(model.getHierarchy(), shadow.getEnclosingType(), enclosingMember); Lint.Kind err = shadow.getIWorld().getLint().shadowNotInStructure; if (err.isEnabled()) { err.signal(shadow.toString(), shadow.getSourceLocation()); Member shadowSig = shadow.getSignature(); if (shadow.getKind() == Shadow.MethodCall || shadow.getKind() == Shadow.ConstructorCall || !shadowSig.equals(enclosingMember)) { IProgramElement bodyNode = findOrCreateCodeNode(model, enclosingNode, shadowSig, shadow);
@Override public boolean match(Shadow shadow, World world) { if (super.match(shadow, world)) { if (shadow.getKind() == Shadow.ExceptionHandler) { if (kind.isAfter() || kind == AdviceKind.Around) { world.showMessage(IMessage.WARNING, WeaverMessages.format(WeaverMessages.ONLY_BEFORE_ON_HANDLER), getSourceLocation(), shadow.getSourceLocation()); return false; if (shadow.getKind() == Shadow.SynchronizationLock || shadow.getKind() == Shadow.SynchronizationUnlock) { if (kind == AdviceKind.Around getSourceLocation(), shadow.getSourceLocation()); return false; ResolvedType shadowReturnType = shadow.getReturnType().resolve(world); boolean matches = (resolvedExtraParameterType.isConvertableFrom(shadowReturnType) && shadow.getKind() .hasReturnValue()); if (matches && resolvedExtraParameterType.isParameterizedType()) { UnresolvedType[] shadowThrows = shadow.getSignature().getExceptions(world); boolean matches = false; for (int i = 0; i < shadowThrows.length && !matches; i++) { return shadow.hasTarget(); } else if (kind == AdviceKind.PerThisEntry) { if (shadow.getEnclosingCodeSignature().getName().equals("<init>")) { if (world.resolve(shadow.getEnclosingType()).isGroovyObject()) { return false;
private ResolvedType[] getArgumentsToMatchAgainst(Shadow shadow) { if (shadow.isShadowForArrayConstructionJoinpoint()) { return shadow.getArgumentTypesForArrayConstructionShadow(); ResolvedType[] argumentsToMatchAgainst = shadow.getIWorld().resolve(shadow.getGenericArgTypes()); if (shadow.getKind() == Shadow.AdviceExecution) { int numExtraArgs = 0; for (int i = 0; i < argumentsToMatchAgainst.length; i++) { argumentsToMatchAgainst = argsSubset; } else if (shadow.getKind() == Shadow.ConstructorExecution) { if (shadow.getMatchingSignature().getParameterTypes().length < argumentsToMatchAgainst.length) { int newArgLength = shadow.getMatchingSignature().getParameterTypes().length; ResolvedType[] argsSubset = new ResolvedType[newArgLength]; System.arraycopy(argumentsToMatchAgainst, 0, argsSubset, 0, newArgLength);
protected Test findResidueInternal(Shadow shadow, ExposedState state) { int len = shadow.getArgCount(); UnresolvedType argType = shadow.getArgType(argsIndex); ResolvedType rArgType = argType.resolve(shadow.getIWorld()); 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() }); ResolvedType rAnnType = ap.getAnnotationType().resolve(shadow.getIWorld()); if (ap instanceof BindingAnnotationTypePattern) { BindingAnnotationTypePattern btp = (BindingAnnotationTypePattern) ap; Var annvar = shadow.getArgAnnotationVar(argsIndex, rAnnType); state.set(btp.getFormalIndex(), annvar); ret = Test.makeAnd(ret, Test.makeHasAnnotation(shadow.getArgVar(argsIndex), rAnnType));
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()) { typeToExpose.getSimpleBaseName(), shadow.toResolvedString(world) }, getSourceLocation(), new ISourceLocation[] { shadow.getSourceLocation() }); ret = Test.makeAnd(ret, exposeStateForVar(shadow.getArgVar(i), type, state, shadow.getIWorld()));
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); }
if (shadow.getKind() == Shadow.SynchronizationUnlock) { if (advice.lastReportedMonitorExitJoinpointLocation == null) { advice.lastReportedMonitorExitJoinpointLocation = shadow.getSourceLocation(); } else { if (areTheSame(shadow.getSourceLocation(), advice.lastReportedMonitorExitJoinpointLocation)) { advice.lastReportedMonitorExitJoinpointLocation = shadow.getSourceLocation(); String advisedType = shadow.getEnclosingType().getName(); String advisingType = advice.getConcreteAspect().getName(); Message msg = null; 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 { boolean runtimeTest = advice.hasDynamicTests(); String joinPointDescription = shadow.toString(); msg = WeaveMessage .constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_ADVISES, new String[] { joinPointDescription, advisedType, beautifyLocation(shadow.getSourceLocation()), description, advisingType, beautifyLocation(munger.getSourceLocation()), (runtimeTest ? " [with runtime test]" : "") }, advisedType, advisingType);
Expr myInstance = Expr.makeCallExpr(AjcMemberMaker.perTypeWithinLocalAspectOf(shadow.getEnclosingType(), inAspect/*
return shadow.toString(); } else if (key.equalsIgnoreCase("joinpoint.kind")) { return shadow.getKind().getName(); } else if (key.equalsIgnoreCase("joinpoint.enclosingclass")) { return shadow.getEnclosingType().getName(); } else if (key.equalsIgnoreCase("joinpoint.enclosingmember.name")) { Member member = shadow.getEnclosingCodeSignature(); if (member==null) { return ""; Member member = shadow.getEnclosingCodeSignature(); if (member==null) { return ""; return shadow.getSignature().toString(); } else if (key.equalsIgnoreCase("joinpoint.signature.declaringtype")) { return shadow.getSignature().getDeclaringType().toString(); } else if (key.equalsIgnoreCase("joinpoint.signature.name")) { 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());
@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); }
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); }
ResolvedType type = shadow.getEnclosingType().resolve(world); if (excludedTypes != null && excludedTypes.contains(type)) { return false;
@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); }