protected void clearLintSuppressions(World inWorld, Collection<Lint.Kind> toClear) { inWorld.getLint().clearSuppressions(toClear); }
protected void suppressLintWarnings(World inWorld) { if (suppressedLintKinds == null) { if (signature instanceof BcelMethod) { this.suppressedLintKinds = Utility.getSuppressedWarnings(signature.getAnnotations(), inWorld.getLint()); } else { this.suppressedLintKinds = Collections.emptyList(); return; } } inWorld.getLint().suppressKinds(suppressedLintKinds); }
/** * Set the lint properties for this parser from the given properties set. * * @param properties */ public void setLintProperties(Properties properties) { getWorld().getLint().setFromProperties(properties); }
/** * Set the lint properties for this parser from the given properties set. * * @param properties */ public void setLintProperties(Properties properties) { getWorld().getLint().setFromProperties(properties); }
private void raiseCantFindType(String key) { if (!world.getLint().cantFindType.isEnabled()) { return; } if (issuedCantFindTypeError) { return; } String message = WeaverMessages.format(key, getName()); message += "\n" + CompilationAndWeavingContext.getCurrentContext(); world.getLint().cantFindType.signal(message, null); // MessageUtil.error(world.getMessageHandler(),message); issuedCantFindTypeError = true; }
public void warnOnModifiedSerialVersionUID(ISourceLocation sourceLocation, String reason) { if (isSerializable && !hasSerialVersionUIDField) { getWorld().getLint().needsSerialVersionUIDField.signal(new String[] { myType.getResolvedTypeX().getName().toString(), reason }, sourceLocation, null); } }
private void reportUnmatchedTargetKindMessage(AnnotationTargetKind[] annotationTargetKinds, PatternNode node, IScope scope, boolean checkMatchesMemberKindName) { StringBuffer targetNames = new StringBuffer("{"); for (int i = 0; i < annotationTargetKinds.length; i++) { AnnotationTargetKind targetKind = annotationTargetKinds[i]; if (checkMatchesMemberKindName && kind.getName().equals(targetKind.getName())) { return; } if (i < (annotationTargetKinds.length - 1)) { targetNames.append("ElementType." + targetKind.getName() + ","); } else { targetNames.append("ElementType." + targetKind.getName() + "}"); } } scope.getWorld().getLint().unmatchedTargetKind.signal(new String[] { node.toString(), targetNames.toString() }, getSourceLocation(), new ISourceLocation[0]); }
public void raiseWarningOnMissingInterfaceWhilstFindingMethods() { if (issuedMissingInterfaceWarning) { return; } String message = WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_INTERFACE_METHODS, getName(), signature); message += "\n" + CompilationAndWeavingContext.getCurrentContext(); world.getLint().cantFindTypeAffectingJoinPointMatch.signal(message, null); // MessageUtil.warn(world.getMessageHandler(),message); issuedMissingInterfaceWarning = true; }
public void raiseWarningOnJoinPointSignature(String signature) { if (issuedJoinPointWarning) { return; } String message = WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_JOINPOINT, getName(), signature); message += "\n" + CompilationAndWeavingContext.getCurrentContext(); world.getLint().cantFindTypeAffectingJoinPointMatch.signal(message, null); // MessageUtil.warn(world.getMessageHandler(),message); issuedJoinPointWarning = true; }
private void raiseCantFindType(String key, String insert) { if (issuedCantFindTypeError) { return; } String message = WeaverMessages.format(key, getName(), insert); message += "\n" + CompilationAndWeavingContext.getCurrentContext(); world.getLint().cantFindType.signal(message, null); // MessageUtil.error(world.getMessageHandler(),message); issuedCantFindTypeError = true; }
public boolean match(ResolvedType typeX) { if (!child.matchesStatically(typeX)) { return false; } if (typeX.getWorld().getLint().typeNotExposedToWeaver.isEnabled() && !typeX.isExposedToWeaver()) { typeX.getWorld().getLint().typeNotExposedToWeaver.signal(typeX.getName(), getSourceLocation()); } return true; }
/** * For declare atType. */ public boolean matches(ResolvedType type) { if (!typePattern.matchesStatically(type)) { return false; } if (type.getWorld().getLint().typeNotExposedToWeaver.isEnabled() && !type.isExposedToWeaver()) { type.getWorld().getLint().typeNotExposedToWeaver.signal(type.getName(), getSourceLocation()); } return true; }
public void errorOnAddedField(FieldGen field, ISourceLocation sourceLocation) { if (isSerializable && !hasSerialVersionUIDField) { getWorld().getLint().serialVersionUIDBroken.signal( new String[] { myType.getResolvedTypeX().getName(), field.getName() }, sourceLocation, null); } }
/** * Raises an [Xlint:cantFindType] message if the declaring type cannot be found or an [Xlint:unresolvableMember] message if the * type can be found (bug 149908) */ private void reportDidntFindMember(World world) { if (reportedCantFindDeclaringType || reportedUnresolvableMember) { return; } ResolvedType rType = getDeclaringType().resolve(world); if (rType.isMissing()) { world.getLint().cantFindType.signal(WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE, rType.getName()), null); reportedCantFindDeclaringType = true; } else { world.getLint().unresolvableMember.signal(getName(), null); reportedUnresolvableMember = true; } }
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); }
@Override public ShadowMunger concretize(ResolvedType fromType, World world, PerClause clause) { if (!world.areAllLintIgnored()) { suppressLintWarnings(world); } ShadowMunger ret = super.concretize(fromType, world, clause); if (!world.areAllLintIgnored()) { clearLintSuppressions(world, this.suppressedLintKinds); } IfFinder ifinder = new IfFinder(); ret.getPointcut().accept(ifinder, null); boolean hasGuardTest = ifinder.hasIf && getKind() != AdviceKind.Around; boolean isAround = getKind() == AdviceKind.Around; if ((getExtraParameterFlags() & ThisJoinPoint) != 0) { if (!isAround && !hasGuardTest && world.getLint().noGuardForLazyTjp.isEnabled()) { // can't build tjp lazily, no suitable test... // ... only want to record it once against the advice(bug 133117) world.getLint().noGuardForLazyTjp.signal("", getSourceLocation()); } } return ret; }
/** * 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() }); } } }
/** * For a TypeVariableReferenceType the delegate is the delegate for the first bound. */ @Override public ReferenceTypeDelegate getDelegate() { if (this.delegate == null) { ResolvedType resolvedFirstBound = typeVariable.getFirstBound().resolve(world); BoundedReferenceTypeDelegate brtd = null; if (resolvedFirstBound.isMissing()) { brtd = new BoundedReferenceTypeDelegate((ReferenceType) world.resolve(UnresolvedType.OBJECT)); setDelegate(brtd); // set now because getSourceLocation() below will cause a recursive step to discover the delegate world.getLint().cantFindType.signal( "Unable to find type for generic bound. Missing type is " + resolvedFirstBound.getName(), getSourceLocation()); } else { brtd = new BoundedReferenceTypeDelegate((ReferenceType) resolvedFirstBound); setDelegate(brtd); } } return this.delegate; }
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); }