aboutsummaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authoraclement <aclement>2004-12-09 16:15:38 +0000
committeraclement <aclement>2004-12-09 16:15:38 +0000
commiteb673019179c372c6c17dd403e53d96feae434fd (patch)
tree844711e35a57220f405e2e8a95130519ad7e21be /weaver
parent88fca98be4be9cfd15a25145ec96548f120dd8ab (diff)
downloadaspectj-eb673019179c372c6c17dd403e53d96feae434fd.tar.gz
aspectj-eb673019179c372c6c17dd403e53d96feae434fd.zip
Complete varargs support.
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java2
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/PatternParser.java8
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java7
3 files changed, 15 insertions, 2 deletions
diff --git a/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java
index 6da79c779..945b76ba7 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java
@@ -190,6 +190,8 @@ public class ExactTypePattern extends TypePattern {
}
buff.append(type.toString());
if (includeSubtypes) buff.append('+');
+ // Note, there will be a rogue [] in the pattern here in the case of varargs ...
+ if (isVarArgs) buff.append("...");
if (annotationPattern != AnnotationTypePattern.ANY) {
buff.append(')');
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/PatternParser.java b/weaver/src/org/aspectj/weaver/patterns/PatternParser.java
index 684377120..1eab94f92 100644
--- a/weaver/src/org/aspectj/weaver/patterns/PatternParser.java
+++ b/weaver/src/org/aspectj/weaver/patterns/PatternParser.java
@@ -587,7 +587,13 @@ public class PatternParser {
//??? what about the source location of any's????
if (names.size() == 1 && ((NamePattern)names.get(0)).isAny() && dim == 0) return TypePattern.ANY;
- return new WildTypePattern(names, includeSubtypes, dim, endPos,isVarArgs);
+ // Notice we increase the dimensions if varargs is set. this is to allow type matching to
+ // succeed later: The actual signature at runtime of a method declared varargs is an array type of
+ // the original declared type (so Integer... becomes Integer[] in the bytecode). So, here for the
+ // pattern 'Integer...' we create a WildTypePattern 'Integer[]' with varargs set. If this matches
+ // during shadow matching, we confirm that the varargs flags match up before calling it a successful
+ // match.
+ return new WildTypePattern(names, includeSubtypes, dim+(isVarArgs?1:0), endPos,isVarArgs);
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java b/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java
index 31cf6545a..c34a3ee7f 100644
--- a/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java
@@ -190,10 +190,14 @@ public class SignaturePattern extends PatternNode {
// If we have matched on parameters, let's just check it isn't because the last parameter in the pattern
// is an array type and the method is declared with varargs
+ // XXX - Ideally the shadow would be included in the msg but we don't know it...
if (isNotMatchBecauseOfVarargsIssue(parameterTypes,sig.getModifiers())) {
world.getLint().cantMatchArrayTypeOnVarargs.signal(sig.toString(),getSourceLocation());
return false;
}
+
+ if (parameterTypes.size()>0 && (sig.isVarargsMethod()^parameterTypes.get(parameterTypes.size()-1).isVarArgs))
+ return false;
// Check the throws pattern
if (!throwsPattern.matches(sig.getExceptions(), world)) return false;
@@ -206,6 +210,7 @@ public class SignaturePattern extends PatternNode {
// If we have matched on parameters, let's just check it isn't because the last parameter in the pattern
// is an array type and the method is declared with varargs
+ // XXX - Ideally the shadow would be included in the msg but we don't know it...
if (isNotMatchBecauseOfVarargsIssue(parameterTypes,sig.getModifiers())) {
world.getLint().cantMatchArrayTypeOnVarargs.signal(sig.toString(),getSourceLocation());
return false;
@@ -557,7 +562,7 @@ public class SignaturePattern extends PatternNode {
*/
private boolean isNotMatchBecauseOfVarargsIssue(TypePatternList params,int modifiers) {
if (params.size()>0 && (modifiers & Constants.ACC_VARARGS)!=0 && // XXX Promote this to an isVarargs() on MethodSignature?
- params.get(params.size()-1).getExactType().isArray()) {
+ !params.get(params.size()-1).isVarArgs) {
return true;
}
return false;