private AnnotationGen buildBaseAnnotationType(ConstantPool cp,World world, String typename) { String annoname = typename; if (annoname.startsWith("@")) { annoname= annoname.substring(1); } ResolvedType annotationType = UnresolvedType.forName(annoname).resolve(world); if (!annotationType.isAnnotation()) { reportError("declare is not specifying an annotation type :"+typename); return null; } if (!annotationType.isAnnotationWithRuntimeRetention()) { reportError("declare is using an annotation type that does not have runtime retention: "+typename); return null; } List<NameValuePair> elems = new ArrayList<NameValuePair>(); return new AnnotationGen(new ObjectType(annoname), elems, true, cp); }
/** * Checks for an @target() on the annotation and if found ensures it allows the annotation to be attached to the target type * that matched. */ private boolean checkTargetOK(DeclareAnnotation decA, ResolvedType onType, AnnotationAJ annoX) { if (annoX.specifiesTarget()) { if ((onType.isAnnotation() && !annoX.allowedOnAnnotationType()) || (!annoX.allowedOnRegularType())) { return false; } } return true; }
/** * Match based on given type pattern, only classes can be matched * * @param matchType * @param aspectType * @return true if match */ public boolean matches(ResolvedType matchType, ResolvedType aspectType) { // match only on class if (matchType.isEnum() || matchType.isInterface() || matchType.isAnnotation()) { return false; } return typePattern.matchesStatically(matchType); }
/** * Match based on given type pattern, only classes can be matched * * @param matchType * @param aspectType * @return true if match */ public boolean matches(ResolvedType matchType, ResolvedType aspectType) { // match only on class if (matchType.isEnum() || matchType.isInterface() || matchType.isAnnotation()) { return false; } return typePattern.matchesStatically(matchType); }
protected void verifyIsAnnotationType(ResolvedType type, IScope scope) { if (!type.isAnnotation()) { IMessage m = MessageUtil.error(WeaverMessages.format(WeaverMessages.REFERENCE_TO_NON_ANNOTATION_TYPE, type.getName()), getSourceLocation()); scope.getWorld().getMessageHandler().handleMessage(m); resolved = false; } }
/** * @return true if the supplied type is of the category specified for this type pattern */ private boolean isRightCategory(ResolvedType type) { switch (category) { case CLASS: return type.isClass(); case INTERFACE: return type.isInterface(); case ASPECT: return type.isAspect(); case ANONYMOUS: return type.isAnonymous(); case INNER: return type.isNested(); case ENUM: return type.isEnum(); case ANNOTATION: return type.isAnnotation(); case FINAL: return Modifier.isFinal(type.getModifiers()); } return false; }
public void resolveBinding(World world) { if (resolved) { return; } resolved = true; formalType = world.resolve(formalType); annotationType = world.resolve(annotationType); ResolvedType annoType = (ResolvedType) annotationType; if (!annoType.isAnnotation()) { IMessage m = MessageUtil .error(WeaverMessages.format(WeaverMessages.REFERENCE_TO_NON_ANNOTATION_TYPE, annoType.getName()), getSourceLocation()); world.getMessageHandler().handleMessage(m); resolved = false; } }
public void resolveBinding(World world) { if (resolved) { return; } resolved = true; annotationType = annotationType.resolve(world); ResolvedType resolvedAnnotationType = (ResolvedType) annotationType; if (!resolvedAnnotationType.isAnnotation()) { IMessage m = MessageUtil.error(WeaverMessages.format(WeaverMessages.REFERENCE_TO_NON_ANNOTATION_TYPE, annotationType .getName()), getSourceLocation()); world.getMessageHandler().handleMessage(m); resolved = false; } if (annotationType.isTypeVariableReference()) { return; // we'll deal with this next check when the type var is actually bound... } verifyRuntimeRetention(world, resolvedAnnotationType); }
break; } else { if (t.isAnnotation()) { if (v.indexOf("(") != -1) { throw new RuntimeException(
private boolean mungeFieldHost(BcelClassWeaver weaver, MethodDelegateTypeMunger.FieldHostTypeMunger munger) { LazyClassGen gen = weaver.getLazyClassGen(); if (gen.getType().isAnnotation() || gen.getType().isEnum()) { // don't signal error as it could be a consequence of a wild type // pattern return false; } // boolean shouldApply = munger.matches(weaver.getLazyClassGen().getType(), aspectType); // why // do // this? ResolvedMember host = AjcMemberMaker.itdAtDeclareParentsField(weaver.getLazyClassGen().getType(), munger.getSignature() .getType(), aspectType); FieldGen field = makeFieldGen(weaver.getLazyClassGen(), host); field.setModifiers(field.getModifiers() | BcelField.AccSynthetic); weaver.getLazyClassGen().addField(field, null); return true; }
/** * Checks for an @target() on the annotation and if found ensures it allows the annotation to be attached to the target type * that matched. */ private boolean verifyTargetIsOK(DeclareAnnotation decA, ResolvedType onType, AnnotationAJ annoX, boolean outputProblems) { boolean problemReported = false; if (annoX.specifiesTarget()) { if ((onType.isAnnotation() && !annoX.allowedOnAnnotationType()) || (!annoX.allowedOnRegularType())) { if (outputProblems) { if (decA.isExactPattern()) { world.getMessageHandler().handleMessage( MessageUtil.error( WeaverMessages.format(WeaverMessages.INCORRECT_TARGET_FOR_DECLARE_ANNOTATION, onType.getName(), annoX.getTypeName(), annoX.getValidTargets()), decA.getSourceLocation())); } else { if (world.getLint().invalidTargetForAnnotation.isEnabled()) { world.getLint().invalidTargetForAnnotation.signal(new String[] { onType.getName(), annoX.getTypeName(), annoX.getValidTargets() }, decA.getSourceLocation(), new ISourceLocation[] { onType.getSourceLocation() }); } } } problemReported = true; } } return problemReported; }
if (reportErrors && isWildChild && targetType.isAnnotation()) { world.getLint().annotationAsTargetForDecpIgnored.signal(targetType.toString(), getSourceLocation()); if (targetType.isAnnotation() && parentType.isInterface()) { if (reportErrors && !isWildChild) { world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.CANT_DECP_ON_ANNOTATION_TO_IMPL_INTERFACE, if (targetType.isAnnotation() && parentType.isClass()) { if (reportErrors && !isWildChild) { world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.CANT_DECP_ON_ANNOTATION_TO_EXTEND_CLASS,
if (typePattern instanceof ExactTypePattern) { ExactTypePattern et = (ExactTypePattern) typePattern; if (!et.getExactType().resolve(scope.getWorld()).isAnnotation()) { IMessage m = MessageUtil.error( WeaverMessages.format(WeaverMessages.REFERENCE_TO_NON_ANNOTATION_TYPE, et.getExactType().getName()),
if (onType.isAnnotation()) { signalError(WeaverMessages.ITDC_ON_ANNOTATION_NOT_ALLOWED, weaver, onType); return false;
if (onType.isAnnotation()) { signalError(WeaverMessages.ITDF_ON_ANNOTATION_NOT_ALLOWED, weaver, onType); return false;
if (onType.isAnnotation()) { signalError(WeaverMessages.ITDM_ON_ANNOTATION_NOT_ALLOWED, classWeaver, onType); return false;
if (gen.getType().isAnnotation() || gen.getType().isEnum()) {