aboutsummaryrefslogtreecommitdiffstats
path: root/org.aspectj.matcher/src
diff options
context:
space:
mode:
authoraclement <aclement>2011-05-31 22:10:57 +0000
committeraclement <aclement>2011-05-31 22:10:57 +0000
commit04b202690dc428ff0d380fda0c5971d3916e0420 (patch)
tree41fbb78c01cafd9cfd1261baf9abe699fff8f653 /org.aspectj.matcher/src
parentf7956943289caa2c39c7787c84a1402411c3c31a (diff)
downloadaspectj-04b202690dc428ff0d380fda0c5971d3916e0420.tar.gz
aspectj-04b202690dc428ff0d380fda0c5971d3916e0420.zip
serializing formal name
Diffstat (limited to 'org.aspectj.matcher/src')
-rw-r--r--org.aspectj.matcher/src/org/aspectj/weaver/patterns/AnnotationTypePattern.java3
-rw-r--r--org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExactAnnotationFieldTypePattern.java39
2 files changed, 34 insertions, 8 deletions
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AnnotationTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AnnotationTypePattern.java
index 88b84867d..0f610fc49 100644
--- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AnnotationTypePattern.java
+++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AnnotationTypePattern.java
@@ -73,6 +73,7 @@ public abstract class AnnotationTypePattern extends PatternNode {
public static final byte WILD = 8;
public static final byte EXACTFIELD = 9;
public static final byte BINDINGFIELD = 10;
+ public static final byte BINDINGFIELD2 = 11;
public static AnnotationTypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException {
byte key = s.readByte();
@@ -93,6 +94,8 @@ public abstract class AnnotationTypePattern extends PatternNode {
return ExactAnnotationFieldTypePattern.read(s, context);
case BINDINGFIELD:
return BindingAnnotationFieldTypePattern.read(s, context);
+ case BINDINGFIELD2:
+ return BindingAnnotationFieldTypePattern.read2(s, context);
case ELLIPSIS_KEY:
return ELLIPSIS;
case ANY_KEY:
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExactAnnotationFieldTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExactAnnotationFieldTypePattern.java
index 41b276075..627b622eb 100644
--- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExactAnnotationFieldTypePattern.java
+++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExactAnnotationFieldTypePattern.java
@@ -93,9 +93,11 @@ public class ExactAnnotationFieldTypePattern extends ExactAnnotationTypePattern
ResolvedType formalBindingType = formalBinding.getType().resolve(scope.getWorld());
- if (!(formalBindingType.isEnum() || formalBindingType.getSignature().equals("Ljava/lang/String;"))) {
- scope.message(IMessage.ERROR, this, "The field within the annotation must be an enum or string. '"
- + formalBinding.getType() + "' is not (compiler limitation)");
+ String bindingTypeSignature = formalBindingType.getSignature();
+ if (!(formalBindingType.isEnum() || bindingTypeSignature.equals("Ljava/lang/String;") || bindingTypeSignature.equals("I"))) {
+ scope.message(IMessage.ERROR, this,
+ "The field within the annotation must be an enum, string or int. '" + formalBinding.getType()
+ + "' is not (compiler limitation)");
}
bindingPattern = true;
@@ -103,14 +105,34 @@ public class ExactAnnotationFieldTypePattern extends ExactAnnotationTypePattern
ReferenceType theAnnotationType = (ReferenceType) annotationType;
ResolvedMember[] annotationFields = theAnnotationType.getDeclaredMethods();
field = null;
+ boolean looksAmbiguous = false;
for (int i = 0; i < annotationFields.length; i++) {
ResolvedMember resolvedMember = annotationFields[i];
if (resolvedMember.getReturnType().equals(formalBinding.getType())) {
if (field != null) {
- scope.message(IMessage.ERROR, this, "The field type '" + formalBinding.getType()
- + "' is ambiguous for annotation type '" + theAnnotationType.getName() + "'");
+ boolean haveProblem = true;
+ // use the name to differentiate
+ if (field.getName().equals(formalName)) {
+ // don't use this new field
+ haveProblem = false;
+ } else if (resolvedMember.getName().equals(formalName)) {
+ // ok, let's use this one
+ field = resolvedMember;
+ haveProblem = false;
+ }
+ if (haveProblem) {
+ looksAmbiguous = true;
+ }
+ } else {
+ field = resolvedMember;
}
- field = resolvedMember;
+ }
+ }
+ if (looksAmbiguous) {
+ // did we find something that does match by name?
+ if (field == null || !field.getName().equals(formalName)) {
+ scope.message(IMessage.ERROR, this, "The field type '" + formalBinding.getType()
+ + "' is ambiguous for annotation type '" + theAnnotationType.getName() + "'");
}
}
if (field == null) {
@@ -118,9 +140,10 @@ public class ExactAnnotationFieldTypePattern extends ExactAnnotationTypePattern
+ theAnnotationType.getName() + "'");
}
- BindingAnnotationFieldTypePattern binding = new BindingAnnotationFieldTypePattern(formalBinding.getType(), formalBinding
- .getIndex(), theAnnotationType);
+ BindingAnnotationFieldTypePattern binding = new BindingAnnotationFieldTypePattern(formalBinding.getType(),
+ formalBinding.getIndex(), theAnnotationType);
binding.copyLocationFrom(this);
+ binding.formalName = this.formalName;
bindings.register(binding, scope);
binding.resolveBinding(scope.getWorld());
return binding;