diff options
-rw-r--r-- | tests/bugs150/pr115235.aj | 22 | ||||
-rw-r--r-- | tests/bugs150/pr115235b.aj | 28 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java | 7 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc150/ajc150.xml | 13 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/patterns/Pointcut.java | 2 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java | 5 |
6 files changed, 76 insertions, 1 deletions
diff --git a/tests/bugs150/pr115235.aj b/tests/bugs150/pr115235.aj new file mode 100644 index 000000000..1d855e3cb --- /dev/null +++ b/tests/bugs150/pr115235.aj @@ -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 index 000000000..5427debe8 --- /dev/null +++ b/tests/bugs150/pr115235b.aj @@ -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) { + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index 1bb8a5aa2..f2d435ee0 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -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..... diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index b2d871101..174172e84 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -976,6 +976,19 @@ <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> + <!-- ============================================================================ --> <!-- ============================================================================ --> diff --git a/weaver/src/org/aspectj/weaver/patterns/Pointcut.java b/weaver/src/org/aspectj/weaver/patterns/Pointcut.java index 64029dd29..1cf99da28 100644 --- a/weaver/src/org/aspectj/weaver/patterns/Pointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/Pointcut.java @@ -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. */ diff --git a/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java b/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java index 886e5f818..6d99ae261 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java @@ -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(); |