]> source.dussan.org Git - aspectj.git/commitdiff
tests and fix for bug pr106461:
authoracolyer <acolyer>
Wed, 10 Aug 2005 11:49:34 +0000 (11:49 +0000)
committeracolyer <acolyer>
Wed, 10 Aug 2005 11:49:34 +0000 (11:49 +0000)
 "org.aspectj.weaver.patterns.WildTypePattern.maybeGetCleanName(WildTypePattern.java:500)"

tests/bugs150/PR106461.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
weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java

diff --git a/tests/bugs150/PR106461.aj b/tests/bugs150/PR106461.aj
new file mode 100644 (file)
index 0000000..5edc140
--- /dev/null
@@ -0,0 +1,18 @@
+public aspect PR106461 {
+       
+       pointcut missingNamePattern() : call(* Foo+(..));
+       
+       pointcut missingNamePatternInField() : get(* Foo+);
+       
+       pointcut missingNamePatternInConstructor() : call(Foo+(..));
+       
+       pointcut butThisIsAllowedOfCourse() : call(* *(..));
+       
+       pointcut asIsThis() : call(* foo(..));
+}
+
+class Foo {
+       
+       void foo() {}
+       
+}
\ No newline at end of file
index 40803152b49904c9c1bc17d516c28b723af833c8..8ecef9a1d8f0bb0169d7eec3db29bab7d5c4e95b 100644 (file)
@@ -192,6 +192,8 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
   
   public void testSyntaxErrorNPE_pr103266() {runTest("NPE on syntax error");}
   
+  public void testMissingNamePattern_pr106461() { runTest("missing name pattern"); }
+  
   // helper methods.....
   
   public SyntheticRepository createRepos(File cpentry) {
index c2faab4f621d7f9cef08c83fd6fe571681dd8d40..ef77a0528b7332f5bdaca09e26c4f091a6c1c6f7 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="bugs150" title="missing name pattern">
+        <compile files="PR106461.aj">
+            <message kind="error" line="3" text="Syntax error on token &quot;(&quot;, &quot;name pattern&quot; expected"/>
+            <message kind="error" line="5" text="Syntax error on token &quot;)&quot;, &quot;name pattern&quot; expected"/>
+            <message kind="error" line="7" text="Syntax error on token &quot;.&quot;, &quot;name pattern&quot; expected"/>
+        </compile>
+    </ajc-test>
         
     <ajc-test dir="../docs/dist/doc/examples/introduction" title="introduction sample" vm="1.5">
         <compile files="CloneablePoint.java,ComparablePoint.java,HashablePoint.java,Point.java" options="-1.5"/>
index 69d59cdae74840cc5f9d7254d7cfe855c976def2..76060b1b64d8aff0b0124bdfd9d522db35a45142 100644 (file)
@@ -1111,6 +1111,7 @@ public class PatternParser {
                    name = parseNamePattern();
            } else {
                name = tryToExtractName(declaringType);
+               if (name == null) throw new ParserException("name pattern",tokenSource.peek());
                if (declaringType.toString().equals("")) {
                        declaringType = TypePattern.ANY;
                }
index e2f99c0fa398dca4d11916ae8ebf331c4c3fec1e..493d82fccd989af00b05b8be67fc8b5258b10c01 100644 (file)
@@ -455,6 +455,11 @@ public class WildTypePattern extends TypePattern {
        }
 
        public NamePattern extractName() {
+               if (isIncludeSubtypes() || isVarArgs() || isArray()) {
+                       // we can't extract a name, the pattern is something like Foo+ and therefore
+                       // it is not ok to treat Foo as a method name!
+                       return null;
+               }
                //System.err.println("extract from : " + Arrays.asList(namePatterns));
                int len = namePatterns.length;
                NamePattern ret = namePatterns[len-1];