aboutsummaryrefslogtreecommitdiffstats
path: root/org.aspectj.matcher
diff options
context:
space:
mode:
authorAndy Clement <andrew.clement@gmail.com>2012-09-19 16:35:53 -0700
committerAndy Clement <andrew.clement@gmail.com>2012-09-19 16:35:53 -0700
commit0d69bd3eba361bcfb1ba013466841ee3611b3531 (patch)
tree49ca4cf07cca3123b7495d5da83c7a58dd376b63 /org.aspectj.matcher
parentb9c7a190f452cf888854e4fa6599269a5a2c0212 (diff)
downloadaspectj-0d69bd3eba361bcfb1ba013466841ee3611b3531.tar.gz
aspectj-0d69bd3eba361bcfb1ba013466841ee3611b3531.zip
389752: annotation value matching fixes - multiple anno values correctly resolved now and enum values compared correctly
Diffstat (limited to 'org.aspectj.matcher')
-rw-r--r--org.aspectj.matcher/src/org/aspectj/weaver/EnumAnnotationValue.java4
-rw-r--r--org.aspectj.matcher/src/org/aspectj/weaver/StandardAnnotation.java4
-rw-r--r--org.aspectj.matcher/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java40
3 files changed, 29 insertions, 19 deletions
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/EnumAnnotationValue.java b/org.aspectj.matcher/src/org/aspectj/weaver/EnumAnnotationValue.java
index d28b901b6..f15968b8d 100644
--- a/org.aspectj.matcher/src/org/aspectj/weaver/EnumAnnotationValue.java
+++ b/org.aspectj.matcher/src/org/aspectj/weaver/EnumAnnotationValue.java
@@ -27,6 +27,10 @@ public class EnumAnnotationValue extends AnnotationValue {
}
public String stringify() {
+ return typeSignature+value;
+ }
+
+ public String getValue() {
return value;
}
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/StandardAnnotation.java b/org.aspectj.matcher/src/org/aspectj/weaver/StandardAnnotation.java
index 5682b353b..475b0977f 100644
--- a/org.aspectj.matcher/src/org/aspectj/weaver/StandardAnnotation.java
+++ b/org.aspectj.matcher/src/org/aspectj/weaver/StandardAnnotation.java
@@ -120,8 +120,8 @@ public class StandardAnnotation extends AbstractAnnotationAJ {
AnnotationValue[] avs = aav.getValues();
Set<String> targets = new HashSet<String>();
for (int i = 0; i < avs.length; i++) {
- AnnotationValue value = avs[i];
- targets.add(value.stringify());
+ EnumAnnotationValue value = (EnumAnnotationValue)avs[i];
+ targets.add(value.getValue());
}
return targets;
}
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java
index 401fc55d7..62dd896ee 100644
--- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java
+++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java
@@ -82,10 +82,10 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
// - the value names are for valid annotation fields
// - the specified values are of the correct type
// - for enums, check the specified values can be resolved in the specified scope
+ Map<String,String> replacementValues = new HashMap<String,String>();
Set<String> keys = annotationValues.keySet();
ResolvedMember[] ms = annotationType.getDeclaredMethods();
- for (Iterator<String> kIter = keys.iterator(); kIter.hasNext();) {
- String k = kIter.next();
+ for (String k: keys) {
String key = k;
// a trailing ! indicates the the user expressed key!=value rather than key=value as a match constraint
if (k.endsWith("!")) {
@@ -109,13 +109,15 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
String typename = v.substring(0, pos);
ResolvedType rt = scope.lookupType(typename, this).resolve(scope.getWorld());
v = rt.getSignature() + v.substring(pos + 1); // from 'Color.RED' to 'Lp/Color;RED'
- annotationValues.put(k, v);
+ replacementValues.put(k, v);
+ break;
}
} else if (t.isPrimitiveType()) {
if (t.getSignature() == "I") {
try {
int value = Integer.parseInt(v);
- annotationValues.put(k, Integer.toString(value));
+ replacementValues.put(k, Integer.toString(value));
+ break;
} catch (NumberFormatException nfe) {
IMessage m = MessageUtil.error(
WeaverMessages.format(WeaverMessages.INVALID_ANNOTATION_VALUE, v, "int"),
@@ -125,7 +127,8 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
} else if (t.getSignature() == "F") {
try {
float value = Float.parseFloat(v);
- annotationValues.put(k, Float.toString(value));
+ replacementValues.put(k, Float.toString(value));
+ break;
} catch (NumberFormatException nfe) {
IMessage m = MessageUtil.error(
WeaverMessages.format(WeaverMessages.INVALID_ANNOTATION_VALUE, v, "float"),
@@ -145,7 +148,8 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
} else if (t.getSignature() == "S") {
try {
short value = Short.parseShort(v);
- annotationValues.put(k, Short.toString(value));
+ replacementValues.put(k, Short.toString(value));
+ break;
} catch (NumberFormatException nfe) {
IMessage m = MessageUtil.error(
WeaverMessages.format(WeaverMessages.INVALID_ANNOTATION_VALUE, v, "short"),
@@ -154,8 +158,8 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
}
} else if (t.getSignature() == "J") {
try {
- long value = Long.parseLong(v);
- annotationValues.put(k, Long.toString(value));
+ replacementValues.put(k, Long.toString(Long.parseLong(v)));
+ break;
} catch (NumberFormatException nfe) {
IMessage m = MessageUtil.error(
WeaverMessages.format(WeaverMessages.INVALID_ANNOTATION_VALUE, v, "long"),
@@ -164,8 +168,8 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
}
} else if (t.getSignature() == "D") {
try {
- double value = Double.parseDouble(v);
- annotationValues.put(k, Double.toString(value));
+ replacementValues.put(k, Double.toString(Double.parseDouble(v)));
+ break;
} catch (NumberFormatException nfe) {
IMessage m = MessageUtil.error(
WeaverMessages.format(WeaverMessages.INVALID_ANNOTATION_VALUE, v, "double"),
@@ -174,8 +178,8 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
}
} else if (t.getSignature() == "B") {
try {
- byte value = Byte.parseByte(v);
- annotationValues.put(k, Byte.toString(value));
+ replacementValues.put(k, Byte.toString(Byte.parseByte(v)));
+ break;
} catch (NumberFormatException nfe) {
IMessage m = MessageUtil.error(
WeaverMessages.format(WeaverMessages.INVALID_ANNOTATION_VALUE, v, "byte"),
@@ -189,7 +193,8 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
getSourceLocation());
scope.getWorld().getMessageHandler().handleMessage(m);
} else {
- annotationValues.put(k, v.substring(1, 2));
+ replacementValues.put(k, v.substring(1, 2));
+ break;
}
} else {
throw new RuntimeException("Not implemented for " + t);
@@ -204,7 +209,8 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
getSourceLocation());
scope.getWorld().getMessageHandler().handleMessage(m);
}
- annotationValues.put(k, rt.getSignature());
+ replacementValues.put(k, rt.getSignature());
+ break;
} else {
if (t.isAnnotation()) {
if (v.indexOf("(") != -1) {
@@ -219,7 +225,8 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
"Unable to resolve type '" + v + "' specified for value '" + k + "'", getSourceLocation());
scope.getWorld().getMessageHandler().handleMessage(m);
}
- annotationValues.put(k, rt.getSignature());
+ replacementValues.put(k, rt.getSignature());
+ break;
} else {
throw new RuntimeException("Compiler limitation: annotation value support not implemented for type "
+ t);
@@ -231,10 +238,9 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
IMessage m = MessageUtil.error(WeaverMessages.format(WeaverMessages.UNKNOWN_ANNOTATION_VALUE, annotationType, k),
getSourceLocation());
scope.getWorld().getMessageHandler().handleMessage(m);
- } else {
- break;
}
}
+ annotationValues.putAll(replacementValues);
}
@Override