]> source.dussan.org Git - aspectj.git/commitdiff
fix for missing syntax error on execution((@XXX *) Foo.new(..))
authoracolyer <acolyer>
Mon, 14 Mar 2005 21:39:32 +0000 (21:39 +0000)
committeracolyer <acolyer>
Mon, 14 Mar 2005 21:39:32 +0000 (21:39 +0000)
                                                                          ^^^

tests/java5/annotations/SyntaxError.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/PatternParser.java

diff --git a/tests/java5/annotations/SyntaxError.aj b/tests/java5/annotations/SyntaxError.aj
new file mode 100644 (file)
index 0000000..ed0085c
--- /dev/null
@@ -0,0 +1,21 @@
+public aspect SyntaxError {
+
+  after(Object x) : execution((@Alien *) Passenger+.new(..)) && this(x) {
+         System.out.println("after alien...");
+  }
+
+}
+
+@interface Alien{}
+
+class Passenger {
+       
+       @Alien Passenger() {}
+       
+}
+
+class SubPassenger extends Passenger {
+       
+       @Alien SubPassenger() { super(); }
+       
+}
\ No newline at end of file
index a1aeb6d77fdb59f8a438c3af5ca8a28f45f213c8..3d75b53c7c26c76e4c193d550accfb1720837d26 100644 (file)
@@ -137,6 +137,10 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
          runTest("declare soft w. catch block");
   }
   
+  public void testSyntaxError() {
+         runTest("invalid cons syntax");
+  }
+  
   // helper methods.....
   
   public SyntheticRepository createRepos(File cpentry) {
index 2e165f3a8f84c5fc3c2551b1a9594645e6ff58c0..84e1de484280ade4b91a7b054c4a4679f6584956 100644 (file)
     <ajc-test dir="bugs150" title="bad asm for enums" vm="1.5">
         <compile files="Rainbow.java" options="-emacssym,-1.5"/>
     </ajc-test>
-    
+
+    <ajc-test dir="java5/annotations" title="invalid cons syntax" vm="1.5">
+        <compile files="SyntaxError.aj" options="-1.5">
+            <message kind="error" line="3" text="Syntax error on token &quot;new&quot;, &quot;method name (not constructor)&quot; expected"/>
+        </compile>
+    </ajc-test>
+        
     <!-- Annotation binding tests -->
     
     <ajc-test dir="java5/annotations/binding" vm="1.5" title="call annotation binding 1">
index c9ca1ccf6c2d6a787821debd5bc6bfa8128e6c6d..91f32babad7e331f4e72e6818d1834c6b24840c0 100644 (file)
@@ -985,24 +985,26 @@ public class PatternParser {
                        name = NamePattern.ANY;
                } else {
                        kind = Member.METHOD;
+                       IToken nameToken = tokenSource.peek();
                        declaringType = parseTypePattern();
                        if (maybeEat(".")) {
+                               nameToken = tokenSource.peek();
                            name = parseNamePattern();
                    } else {
                        name = tryToExtractName(declaringType);
-                       if (name == null) {
-                               throw new ParserException("name pattern", tokenSource.peek());
-                       }
-                       String simpleName = name.maybeGetSimpleName();
-                       //XXX should add check for any Java keywords
-                       if (simpleName != null && simpleName.equals("new")) {
-                               throw new ParserException("constructor patterns have no return type", 
-                                                                       tokenSource.peek());
-                       }
                        if (declaringType.toString().equals("")) {
                                declaringType = TypePattern.ANY;
                        }
-                       }
+                   }
+               if (name == null) {
+                       throw new ParserException("name pattern", tokenSource.peek());
+               }
+               String simpleName = name.maybeGetSimpleName();
+               //XXX should add check for any Java keywords
+               if (simpleName != null && simpleName.equals("new")) {
+                       throw new ParserException("method name (not constructor)", 
+                                                               nameToken);
+               }
                }
                
                TypePatternList parameterTypes = parseArgumentsPattern();