From: aclement Date: Mon, 14 Nov 2005 09:50:22 +0000 (+0000) Subject: fix for parser crash on erroneous perthis() - see pr115788 X-Git-Tag: V1_5_0RC1~195 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=563ab1bc7659edf2d42bed64f131b2a6df1ac56a;p=aspectj.git fix for parser crash on erroneous perthis() - see pr115788 --- diff --git a/tests/bugs150/pr115788/AAA.java b/tests/bugs150/pr115788/AAA.java new file mode 100644 index 000000000..9a2e4c7c6 --- /dev/null +++ b/tests/bugs150/pr115788/AAA.java @@ -0,0 +1,4 @@ +package a; + +public aspect AAA perthis(this(Screen)) { } + diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index a7993fb86..1bb8a5aa2 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -49,6 +49,7 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testGenericITDsAndAbstractMethodError_pr102357() { runTest("generic itds and abstract method error");} */ + public void testParserException_pr115788() { runTest("parser exception");} public void testPossibleStaticImports_pr113066_1() { runTest("possible static imports bug - 1");} public void testPossibleStaticImports_pr113066_2() { runTest("possible static imports bug - 2");} public void testPossibleStaticImports_pr113066_3() { runTest("possible static imports bug - 3");} diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index e5122ff09..b2d871101 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -57,6 +57,12 @@ + + + + + + diff --git a/weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java b/weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java index 42f1b2d4e..da8271721 100644 --- a/weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java +++ b/weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java @@ -134,10 +134,16 @@ public class PerThisOrTargetPointcutVisitor extends IdentityPointcutVisitor { public Object visit(ThisOrTargetPointcut node, Object data) { if ((m_isTarget && !node.isThis()) || (!m_isTarget && node.isThis())) { + String pointcutString = node.getType().toString(); + // see pr115788 "" means there was a problem resolving types - that will be reported so dont blow up + // the parser here.. + if (pointcutString.equals("")) { + return new NoTypePattern(); + } //pertarget(target(Foo)) => Foo+ for type pattern matching //perthis(this(Foo)) => Foo+ for type pattern matching // TODO AV - we do like a deep copy by parsing it again.. quite dirty, would need a clean deep copy - TypePattern copy = new PatternParser(node.getType().toString().replace('$', '.')).parseTypePattern(); + TypePattern copy = new PatternParser(pointcutString.replace('$', '.')).parseTypePattern(); // TODO AV - see dirty replace from $ to . here as inner classes are with $ instead (#108488) copy.includeSubtypes = true; return copy;