diff options
author | aclement <aclement> | 2005-12-04 13:40:06 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-12-04 13:40:06 +0000 |
commit | b17970f20c9040c3455a02b353a8e7fbc1914024 (patch) | |
tree | 294fffc53f21c504f3f1c20dbdf490439a9bf3a1 /org.aspectj.ajdt.core | |
parent | ff57abb3598f3922370eabfbe08a6bc8655bf6b9 (diff) | |
download | aspectj-b17970f20c9040c3455a02b353a8e7fbc1914024.tar.gz aspectj-b17970f20c9040c3455a02b353a8e7fbc1914024.zip |
fixes for 117882
Diffstat (limited to 'org.aspectj.ajdt.core')
-rw-r--r-- | org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java index e743af75e..966f2c564 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java @@ -54,8 +54,10 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TagBits; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.problem.ProblemReporter; +import org.aspectj.weaver.AnnotationX; import org.aspectj.weaver.AsmRelationshipProvider; import org.aspectj.weaver.ConcreteTypeMunger; +import org.aspectj.weaver.FakeAnnotation; import org.aspectj.weaver.ReferenceType; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.TypeVariable; @@ -726,6 +728,9 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC } TypeBinding tb = factory.makeTypeBinding(aspectType); + + + // TODO asc determine if there really is a problem here (see comment below) // ClassCastException here means we probably have either a parameterized type or a raw type, we need the @@ -739,6 +744,54 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC Annotation[] toAdd = methodDecl.annotations; // this is what to add abits = toAdd[0].resolvedType.getAnnotationTagBits(); + if (sourceType instanceof BinaryTypeBinding) { + // In this case we can't access the source type binding to add a new annotation, so let's put something + // on the weaver type temporarily + ResolvedType theTargetType = factory.fromEclipse(sourceType); + TypeBinding theAnnotationType = toAdd[0].resolvedType; + String name = new String(theAnnotationType.qualifiedPackageName())+"."+new String(theAnnotationType.sourceName()); + String sig = new String(theAnnotationType.signature()); + if (theTargetType.hasAnnotation(UnresolvedType.forSignature(sig))) { + CompilationAndWeavingContext.leavingPhase(tok); + return false; + } + + // FIXME asc tidy up this code that duplicates whats below! + // Simple checks on the bits + boolean giveupnow = false; + if (((abits & TagBits.AnnotationTargetMASK)!=0)) { + if ( isAnnotationTargettingSomethingOtherThanAnnotationOrNormal(abits)) { + // error will have been already reported + giveupnow = true; + } else if ( (sourceType.isAnnotationType() && (abits & TagBits.AnnotationForAnnotationType)==0) || + (!sourceType.isAnnotationType() && (abits & TagBits.AnnotationForType)==0) ) { + + if (reportProblems) { + if (decA.isExactPattern()) { + factory.showMessage(IMessage.ERROR, + WeaverMessages.format(WeaverMessages.INCORRECT_TARGET_FOR_DECLARE_ANNOTATION,rtx.getName(),toAdd[0].type,stringifyTargets(abits)), + decA.getSourceLocation(), null); + } + // dont put out the lint - the weaving process will do that +// else { +// if (factory.getWorld().getLint().invalidTargetForAnnotation.isEnabled()) { +// factory.getWorld().getLint().invalidTargetForAnnotation.signal(new String[]{rtx.getName(),toAdd[0].type.toString(),stringifyTargets(abits)},decA.getSourceLocation(),null); +// } +// } + } + giveupnow=true; + } + } + if (giveupnow) { + CompilationAndWeavingContext.leavingPhase(tok); + return false; + } + + theTargetType.addAnnotation(new AnnotationX(new FakeAnnotation(name,sig,(abits & TagBits.AnnotationRuntimeRetention)!=0),factory.getWorld())); + CompilationAndWeavingContext.leavingPhase(tok); + return true; + } + Annotation currentAnnotations[] = sourceType.scope.referenceContext.annotations; if (currentAnnotations!=null) for (int i = 0; i < currentAnnotations.length; i++) { @@ -797,6 +850,10 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC CompilationAndWeavingContext.leavingPhase(tok); return true; } + + private boolean isAnnotationTargettingSomethingOtherThanAnnotationOrNormal(long abits) { + return (abits & (TagBits.AnnotationForAnnotationType | TagBits.AnnotationForType))==0; + } private void reportDeclareParentsMessage(WeaveMessage.WeaveMessageKind wmk,SourceTypeBinding sourceType,ResolvedType parent) { |