]> source.dussan.org Git - aspectj.git/commitdiff
tests and fixes for 115235: stackoverflow on concretizing pointcuts (patch from Helen)
authoraclement <aclement>
Mon, 14 Nov 2005 10:38:47 +0000 (10:38 +0000)
committeraclement <aclement>
Mon, 14 Nov 2005 10:38:47 +0000 (10:38 +0000)
tests/bugs150/pr115235.aj [new file with mode: 0644]
tests/bugs150/pr115235b.aj [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/Pointcut.java
weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java

diff --git a/tests/bugs150/pr115235.aj b/tests/bugs150/pr115235.aj
new file mode 100644 (file)
index 0000000..1d855e3
--- /dev/null
@@ -0,0 +1,22 @@
+abstract aspect GenericAbstractAspect<T>{
+       abstract protected pointcut pc();
+       before() : pc() {}
+}
+
+aspect Concrete extends GenericAbstractAspect<Concrete> {
+       // should get circular dependency error message from this
+       protected pointcut pc() : pc();
+}
+
+aspect Concrete2 extends GenericAbstractAspect<Concrete2> {
+       // this  should compile as expected
+       protected pointcut pc() : p1(); 
+       pointcut p1() : call(void Concrete2.foo(..));
+}
+
+aspect Concrete3 extends GenericAbstractAspect<Concrete3> {
+       // should get circular dependency error message from this
+       protected pointcut pc() : pc1();
+       pointcut pc1() : pc2();
+       pointcut pc2() : pc();
+}
diff --git a/tests/bugs150/pr115235b.aj b/tests/bugs150/pr115235b.aj
new file mode 100644 (file)
index 0000000..5427deb
--- /dev/null
@@ -0,0 +1,28 @@
+abstract aspect GenericAbstractAspect<T> {
+       abstract protected pointcut pc();
+       before() : pc() {}
+}
+
+abstract aspect SubGenericAspect<T> extends GenericAbstractAspect<T> {
+       abstract protected pointcut pc1();
+       abstract protected pointcut pc3();
+
+       protected pointcut pc() : pc1();
+       protected pointcut pc2() : pc3();
+}
+
+// this should compile with no errors
+aspect Concrete2 extends SubGenericAspect<String> {    
+       protected pointcut pc() : pc1();
+       protected pointcut pc1() :pc3();
+       protected pointcut pc3() : execution(* *(String));
+}
+
+class C {
+       
+       public void method(String s) {  
+       }
+       
+       public void method2(int i) {    
+       }
+}
index 1bb8a5aa2c7457f8b10495524968813bddf7fcde..f2d435ee03f79441a8c50c5435d85404264703b3 100644 (file)
@@ -703,6 +703,13 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
          runTest("no verify error with two args pcds");
   }
   
+  public void testNoStackOverflowWithCircularPCDInGenericAspect() {
+         runTest("no StackOverflowError with circular pcd in generic aspect");
+  }
+  
+  public void testNoStackOverflowWithCircularPCDInGenericAspect2() {
+         runTest("no StackOverflowError with circular pcd in generic aspect - 2");
+  }
   
   // helper methods.....
   
index b2d87110145df1a23abe481e1b63faaa26f042c3..174172e8416b8cc6bfe4a4efce345f714a061f95 100644 (file)
         <run class="PR113447e"/>
     </ajc-test>
 
+    <ajc-test dir="bugs150" title="no StackOverflowError with circular pcd in generic aspect">
+        <compile files="pr115235.aj" options="-1.5">
+               <message kind="warning" line="3" text="advice defined in GenericAbstractAspect has not been applied [Xlint:adviceDidNotMatch]"/>
+               <message kind="error" text="circular pointcut declaration involving: pc()"/>
+               <message kind="error" line="20" text="circular pointcut declaration involving: pc2()"/>
+           </compile>
+    </ajc-test> 
+
+    <ajc-test dir="bugs150" title="no StackOverflowError with circular pcd in generic aspect - 2">
+        <compile files="pr115235b.aj" options="-1.5">
+        </compile>
+    </ajc-test>
+
     <!-- ============================================================================ -->
     <!-- ============================================================================ -->
     
index 64029dd29c1654020f5f05cee4144602dd54e1f7..1cf99da28cdac55cd282bdd37d3c901677cb1ac3 100644 (file)
@@ -104,6 +104,8 @@ public abstract class Pointcut extends PatternNode {
        private FuzzyBoolean lastMatchedShadowResult;
        private String[] typeVariablesInScope = new String[0];
        
+       protected boolean hasBeenParameterized = false;
+       
        /**
         * Constructor for Pattern.
         */
index 886e5f818e05657744dffba5b51d13612e2522f3..6d99ae26179d18a89aec8ba3e760cbbc5729a567 100644 (file)
@@ -322,7 +322,10 @@ public class ReferencePointcut extends Pointcut {
                        newBindings.pushEnclosingDefinition(pointcutDec);
                        try {
                                Pointcut ret = pointcutDec.getPointcut();
-                               if (typeVariableMap != null) ret = ret.parameterizeWith(typeVariableMap);
+                               if (typeVariableMap != null && !hasBeenParameterized) {                                 
+                                       ret = ret.parameterizeWith(typeVariableMap);
+                                       ret.hasBeenParameterized=true;
+                               }
                                return ret.concretize(searchStart, declaringType, newBindings);
                        } finally {
                                newBindings.popEnclosingDefinitition();