]> source.dussan.org Git - aspectj.git/commitdiff
test and fix for pr111915
authoraclement <aclement>
Fri, 21 Oct 2005 06:56:11 +0000 (06:56 +0000)
committeraclement <aclement>
Fri, 21 Oct 2005 06:56:11 +0000 (06:56 +0000)
tests/bugs150/pr111915.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java

diff --git a/tests/bugs150/pr111915.java b/tests/bugs150/pr111915.java
new file mode 100644 (file)
index 0000000..f0ca3ab
--- /dev/null
@@ -0,0 +1,17 @@
+import java.io.*;
+
+class SomeClass {
+    public void doSomething() { }
+}
+
+aspect DoesntCompile {
+
+    declare parents : SomeClass implements Serializable;
+
+    pointcut doSomething(SomeClass someClass) :
+            execution(void SomeClass.doSomething()) &&
+            this(someClass);
+
+    void around(Serializable myWorld) : doSomething(myWorld) { }
+    
+}
\ No newline at end of file
index a6f8acb46141bb0a9f556a7ffdaf81335394cc4f..1aabffea647fbdb6bb6758094f615e19b959135d 100644 (file)
@@ -485,6 +485,10 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
          runTest("parameterized generic methods");
   }
   
+  public void testIllegalChangeToPointcutDeclaration_pr111915() {
+       runTest("test illegal change to pointcut declaration");
+  }
+  
   public void testCantProvideDefaultImplViaITD_pr110307_1() {runTest("Cant provide default implementation via ITD - 1");}
   public void testCantProvideDefaultImplViaITD_pr110307_2() {runTest("Cant provide default implementation via ITD - 2");}
   public void testCantProvideDefaultImplViaITD_pr110307_3() {runTest("Cant provide default implementation via ITD - 3");}
index d0aaa64ca71d370c8d01f70b1f40e38583812144..b4546aac740a16546ba5b480f77e07f53edf737a 100644 (file)
@@ -6,6 +6,13 @@
     <ajc-test dir="java5/staticImports" title="import static java.lang.System.out">
         <compile files="StaticImport.aj" options="-1.5"/>
     </ajc-test>
+    
+    <ajc-test dir="bugs150" title="test illegal change to pointcut declaration">
+        <compile files="pr111915.java" options="-1.5 -showWeaveInfo">
+          <message kind="weave" text="Join point 'method-execution(void SomeClass.doSomething())' in Type 'SomeClass' (pr111915.java:4) advised by around advice from 'DoesntCompile' (pr111915.java:15)"/>
+          <message kind="weave" text="Extending interface set for type 'SomeClass' (pr111915.java) to include 'java.io.Serializable' (pr111915.java)"/>
+        </compile>
+    </ajc-test> 
 
     <ajc-test dir="java5/bridgeMethods" pr="72766" title="Ignore bridge methods">
         <compile files="AspectX.aj" inpath="testcode.jar" options="-showWeaveInfo">
index 67407a4089f9c4cd2e2630b42653e08edf8d899c..886e5f818e05657744dffba5b51d13612e2522f3 100644 (file)
@@ -23,7 +23,6 @@ import java.util.Set;
 import org.aspectj.bridge.IMessage;
 import org.aspectj.bridge.MessageUtil;
 import org.aspectj.util.FuzzyBoolean;
-import org.aspectj.weaver.BCException;
 import org.aspectj.weaver.ISourceContext;
 import org.aspectj.weaver.IntMap;
 import org.aspectj.weaver.ResolvedPointcutDefinition;
@@ -209,7 +208,7 @@ public class ReferencePointcut extends Pointcut {
                                !p.getExactType().equals(UnresolvedType.OBJECT))
                        {
                                scope.message(IMessage.ERROR, p, "incompatible type, expected " +
-                                               parameterTypes[i].getName() + " found " + p);
+                                               parameterTypes[i].getName() + " found " + p +".  Check the type specified in your pointcut");
                                return;
                        }
                }
@@ -299,18 +298,14 @@ public class ReferencePointcut extends Pointcut {
                        for (int i=0,len=arguments.size(); i < len; i++) {
                                TypePattern p = arguments.get(i);
                                if (p == TypePattern.NO) continue;
-                               //we are allowed to bind to pointcuts which use subtypes as this is type safe
-                               if (!p.matchesSubtypes(parameterTypes[i])  && 
-                                       !p.getExactType().equals(UnresolvedType.OBJECT))
-                               {
-                                       throw new BCException("illegal change to pointcut declaration: " + this);
-                               }
-                               
+                               // we are allowed to bind to pointcuts which use subtypes as this is type safe
+                               // this will be checked in ReferencePointcut.resolveBindings().  Can't check it here
+                               // as we don't know about any new parents added via decp.
                            if (p instanceof BindingTypePattern) {
                                newBindings.put(i, ((BindingTypePattern)p).getFormalIndex());
                            }
                        }
-                       
+
                        if (searchStart.isParameterizedType()) {
                                // build a type map mapping type variable names in the generic type to
                                // the type parameters presented