From 4b8bed7cff98b2aca5586e604a138c3674453c90 Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 14 Nov 2005 10:38:47 +0000 Subject: [PATCH] tests and fixes for 115235: stackoverflow on concretizing pointcuts (patch from Helen) --- tests/bugs150/pr115235.aj | 22 +++++++++++++++ tests/bugs150/pr115235b.aj | 28 +++++++++++++++++++ .../systemtest/ajc150/Ajc150Tests.java | 7 +++++ .../org/aspectj/systemtest/ajc150/ajc150.xml | 13 +++++++++ .../org/aspectj/weaver/patterns/Pointcut.java | 2 ++ .../weaver/patterns/ReferencePointcut.java | 5 +++- 6 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 tests/bugs150/pr115235.aj create mode 100644 tests/bugs150/pr115235b.aj 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{ + abstract protected pointcut pc(); + before() : pc() {} +} + +aspect Concrete extends GenericAbstractAspect { + // should get circular dependency error message from this + protected pointcut pc() : pc(); +} + +aspect Concrete2 extends GenericAbstractAspect { + // this should compile as expected + protected pointcut pc() : p1(); + pointcut p1() : call(void Concrete2.foo(..)); +} + +aspect Concrete3 extends GenericAbstractAspect { + // 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 { + abstract protected pointcut pc(); + before() : pc() {} +} + +abstract aspect SubGenericAspect extends GenericAbstractAspect { + 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 { + 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 @@ + + + + + + + + + + + + + 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(); -- 2.39.5