]> source.dussan.org Git - aspectj.git/commitdiff
fix for parser crash on erroneous perthis() - see pr115788
authoraclement <aclement>
Mon, 14 Nov 2005 09:50:22 +0000 (09:50 +0000)
committeraclement <aclement>
Mon, 14 Nov 2005 09:50:22 +0000 (09:50 +0000)
tests/bugs150/pr115788/AAA.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/PerThisOrTargetPointcutVisitor.java

diff --git a/tests/bugs150/pr115788/AAA.java b/tests/bugs150/pr115788/AAA.java
new file mode 100644 (file)
index 0000000..9a2e4c7
--- /dev/null
@@ -0,0 +1,4 @@
+package a;
+
+public aspect AAA perthis(this(Screen)) { }
+
index a7993fb8676331f1ffa5a8333719f6c920d6b6e6..1bb8a5aa2c7457f8b10495524968813bddf7fcde 100644 (file)
@@ -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");}
index e5122ff09c856a8ca9c0e42ae9912a578a80df10..b2d87110145df1a23abe481e1b63faaa26f042c3 100644 (file)
         <compile files="Consts.java,TestNPE.java" options="-1.5"/>
     </ajc-test>
     
+    <ajc-test dir="bugs150/pr115788" title="parser exception">
+        <compile files="AAA.java">
+          <message kind="warning" line="3" text="no match for this type name: Screen"/>
+        </compile>
+    </ajc-test>
+    
     <ajc-test dir="bugs150/pr113066" title="possible static imports bug - 2">
         <compile files="Consts2.java,TestNPE2.java" options="-1.5">
           <message kind="error" line="2" text="The import a.Consts2.A_CONST cannot be resolved"/>
index 42f1b2d4e68d86f72bd4033b25e3e451cfc64e22..da8271721214fe57dec8b40bb27feb7665e071cc 100644 (file)
@@ -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 "<nothing>" means there was a problem resolving types - that will be reported so dont blow up
+               // the parser here..
+               if (pointcutString.equals("<nothing>")) {
+                       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;