summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-03-22 13:14:44 +0000
committeracolyer <acolyer>2005-03-22 13:14:44 +0000
commitb5f4d09e4f4e45943c6c8b3dc8dca0c05b90f27c (patch)
treefd62ccc09921d51f4e59007ddf5205ff5df9f1dc
parent8e275e3b934fd973ca04e358e994e50e9668b415 (diff)
downloadaspectj-b5f4d09e4f4e45943c6c8b3dc8dca0c05b90f27c.tar.gz
aspectj-b5f4d09e4f4e45943c6c8b3dc8dca0c05b90f27c.zip
Fix for Bugzilla Bug 88652: an array type as the last parameter in a signature does not match on the varargs declared method
-rw-r--r--tests/java5/varargs/Pr88652.aj20
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java4
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/ajc150.xml7
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java9
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/TypePattern.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java4
7 files changed, 48 insertions, 4 deletions
diff --git a/tests/java5/varargs/Pr88652.aj b/tests/java5/varargs/Pr88652.aj
new file mode 100644
index 000000000..bd3141cca
--- /dev/null
+++ b/tests/java5/varargs/Pr88652.aj
@@ -0,0 +1,20 @@
+public aspect Pr88652 {
+
+ pointcut p(): call(Touple.new(..));
+
+ declare warning: p() : "should match";
+
+ public static void main(String[] args) {
+ Touple t = new Touple(new Object());
+ Touple t2 = new Touple(new Object(),new Object());
+ }
+}
+
+
+class Touple {
+
+ public Touple(Object formulaHandle, Object... propositions) {
+ ; // empty
+ }
+
+} \ No newline at end of file
diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
index 3d75b53c7..bdcc31a41 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
@@ -141,6 +141,10 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
runTest("invalid cons syntax");
}
+ public void testVarargsInConsBug() {
+ runTest("varargs in constructor sig");
+ }
+
// helper methods.....
public SyntheticRepository createRepos(File cpentry) {
diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
index 84e1de484..67370847d 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
+++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
@@ -126,6 +126,13 @@
<compile files="Rainbow.java" options="-emacssym,-1.5"/>
</ajc-test>
+ <ajc-test dir="java5/varargs" title="varargs in constructor sig" vm="1.5">
+ <compile files="Pr88652.aj" options="-1.5">
+ <message kind="warning" line="8" text="should match"/>
+ <message kind="warning" line="9" text="should match"/>
+ </compile>
+ </ajc-test>
+
<ajc-test dir="java5/annotations" title="invalid cons syntax" vm="1.5">
<compile files="SyntaxError.aj" options="-1.5">
<message kind="error" line="3" text="Syntax error on token &quot;new&quot;, &quot;method name (not constructor)&quot; expected"/>
diff --git a/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java
index b4e4ea7e3..6776579f3 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java
@@ -70,6 +70,10 @@ public class ExactTypePattern extends TypePattern {
this.type = type;
}
+ public boolean isArray() {
+ return type.isArray();
+ }
+
/* (non-Javadoc)
* @see org.aspectj.weaver.patterns.TypePattern#couldEverMatchSameTypesAs(org.aspectj.weaver.patterns.TypePattern)
*/
diff --git a/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java b/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java
index 126d45e95..633e15748 100644
--- a/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java
@@ -573,11 +573,12 @@ public class SignaturePattern extends PatternNode {
* was declared with varargs (Object...). We shouldn't be matching if this is the case.
*/
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).isVarArgs) {
- return true;
+ if (params.size()>0 && (modifiers & Constants.ACC_VARARGS)!=0) {
+ // we have at least one parameter in the pattern list, and the method has a varargs signature
+ TypePattern lastPattern = params.get(params.size()-1);
+ if (lastPattern.isArray() && !lastPattern.isVarArgs) return true;
}
- return false;
+ return false;
}
public AnnotationTypePattern getAnnotationPattern() {
diff --git a/weaver/src/org/aspectj/weaver/patterns/TypePattern.java b/weaver/src/org/aspectj/weaver/patterns/TypePattern.java
index 9763cf9e7..dd33ef30a 100644
--- a/weaver/src/org/aspectj/weaver/patterns/TypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/TypePattern.java
@@ -64,6 +64,10 @@ public abstract class TypePattern extends PatternNode {
return annotationPattern == AnnotationTypePattern.ANY;
}
+ public boolean isArray() {
+ return false;
+ }
+
protected TypePattern(boolean includeSubtypes) {
this(includeSubtypes,false);
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java
index 0dff4aaad..859391bdf 100644
--- a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java
@@ -140,6 +140,10 @@ public class WildTypePattern extends TypePattern {
return dim;
}
+ public boolean isArray() {
+ return dim > 1;
+ }
+
/**
* @param targetTypeName
* @return