]> source.dussan.org Git - aspectj.git/commitdiff
@xxx(@Foo) -> @xxx(Foo)
authoracolyer <acolyer>
Thu, 17 Feb 2005 21:11:31 +0000 (21:11 +0000)
committeracolyer <acolyer>
Thu, 17 Feb 2005 21:11:31 +0000 (21:11 +0000)
22 files changed:
docs/adk15ProgGuideDB/annotations.xml
docs/adk15ProgGuideDB/grammar.xml
tests/java5/annotations/AnnotationAspect03.aj
tests/java5/annotations/args/AtArgsAspect.java
tests/java5/annotations/args/DeclareEoW.java
tests/java5/annotations/attarget/AtTargetAspect.java
tests/java5/annotations/binding/AtArgs3.aj
tests/java5/annotations/binding/complexExample/X.java
tests/java5/annotations/thisOrtarget/DeclareEoW.java
tests/java5/annotations/thisOrtarget/NotRuntimeRetention.aj
tests/java5/annotations/thisOrtarget/ThisOrTargetTests.aj
tests/java5/annotations/within_code/WithinAndWithinCodeTests.java
weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java
weaver/src/org/aspectj/weaver/patterns/AnnotationPointcut.java
weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java
weaver/src/org/aspectj/weaver/patterns/PatternParser.java
weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java
weaver/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java
weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java
weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java
weaver/testsrc/org/aspectj/weaver/patterns/ParserTestCase.java
weaver/testsrc/org/aspectj/weaver/patterns/PointcutRewriterTest.java

index 8fddf011084e5d7c66dae87b603d9aecdaa0ad7a..2a0d02d549f7edbfdeec14a6c3d985fa6eb09712 100644 (file)
         will be emitted by the compiler if the pointcut expression associated with an 
         advice statement can be statically determined to not match any join points. The
         warning can be suppressed for an individual advice statement by using the 
-        <literal>@SuppressWarnings({"unmatched"})</literal> annotation. (See JLS 9.6.1.5).
+        <literal>@SuppressAjWarnings({"unmatched"})</literal> annotation. This works in
+        the same way as the Java 5 SuppressWarnings annotation (See JLS 9.6.1.5), but has class file
+        retention.
     </para>
   </sect1>
 
   <sect1 id="annotations-pointcuts-and-advice">
     <title>Join Point Matching based on Annotations</title>
 
-    <para><emphasis>Note: compared to the previous version, this version restricts the
-    use of annotations in type patterns (package annotations and outer type annotations
-    cannot be specified inline), and requires parenthesis more often. These changes were
-    made to make pointcut expressions easier to read and interpret.</emphasis></para>  
-  
   <para>
        This section discusses changes to type pattern and signature pattern matching in
        AspectJ 5 that support matching join points based on the presence or absence of
     
            AtTarget := '@target' '(' AnnotationOrIdentifier ')'
        
-           AnnotationOrIdentifier := '@' FullyQualifiedName | Identifier
+           AnnotationOrIdentifier := FullyQualifiedName | Identifier
         
            AtArgs := '@args' '(' AnnotationsOrIdentifiersPattern ')'
         
    <variablelist>
 
         <varlistentry>
-          <term>@this(@Foo)</term>
+          <term>@this(Foo)</term>
           <listitem>
             <para>
                Matches any join point where the object currently bound to 'this'
         </varlistentry>
 
         <varlistentry>
-          <term>call(* *(..)) &amp;&amp; @target(@Classified)</term>
+          <term>call(* *(..)) &amp;&amp; @target(Classified)</term>
           <listitem>
             <para>
                Matches a call to any object where the target of the call has
         * matches any join point with at least one argument, and where the
         * type of the first argument has the @Classified annotation
         */
-       pointcut classifiedArgument() : @args(@Classified,..);
+       pointcut classifiedArgument() : @args(Classified,..);
        
        /**
         * matches any join point with three arguments, where the third
    <variablelist>
 
         <varlistentry>
-          <term>@within(@Foo)</term>
+          <term>@within(Foo)</term>
           <listitem>
             <para>
                Matches any join point where the executing code is defined 
 
        <programlisting><![CDATA[
        declare error : call(* org.xyz.model.*.*(..)) &&
-                       !@within(@Trusted *)
+                       !@within(Trusted)
                        : "Untrusted code should not call the model classes directly";
        ]]></programlisting>
     
     <title>Declare Annotation</title>
   
       <para>AspectJ 5 supports a new kind of declare statement, <literal>declare annotation</literal>.
-      The general form of a <literal>declare annotation</literal> statement is:
+      This takes different forms according to the recipient of the annotation: 
+      <literal>declare @type</literal> for types, <literal>declare @method</literal> for methods,
+      <literal>declare @constructor</literal> for constructors, and <literal>declare @field</literal>
+      for fields. <literal>declare @package</literal> may be supported in a future release.
       </para>
+      
+      <para>The general form is:</para>
 
        <programlisting><![CDATA[
-       declare annotation : ElementPattern : Annotation ;
+       declare @<kind> : ElementPattern : Annotation ;
        ]]></programlisting>
 
     <para>Where annotation is a regular annotation expression as defined in the Java 5 language. If the annotation has 
            <variablelist>
        
                <varlistentry>
-                 <term>declare annotation : org.xyz.model..* : @BusinessDomain ;</term>
+                 <term>declare @type : org.xyz.model..* : @BusinessDomain ;</term>
                  <listitem>
                    <para>
                     All types defined in a package with the prefix <literal>org.xyz.model</literal>
                </varlistentry>
                
                <varlistentry>
-                 <term>declare annotation : public * BankAccount+.*(..) : @Secured(role="supervisor")</term>
+                 <term>declare @method : public * BankAccount+.*(..) : @Secured(role="supervisor")</term>
                  <listitem>
                    <para>
                        All public methods in <literal>BankAccount</literal> and its subtypes have the
                </varlistentry>
                
                <varlistentry>
-                 <term>declare annotation : * DAO+.* : @Persisted;</term>
+                 <term>declare @field : * DAO+.* : @Persisted;</term>
                  <listitem>
                    <para>
                        All fields defined in <literal>DAO</literal> or its subtypes have the
index 740e3fa7a72e90779514cd2c64b88639ec8db736..0f8320208443a3b283d79ed3e57f9b8fae1701e1 100644 (file)
         AtWithin := '@within' '(' AnnotationOrIdentifier ')'
         AtWithinCode := '@withincode' '(' AnnotationOrIdentifier ')'        
         
-        AnnotationOrIdentifier := '@' FullyQualifiedName | Identifier
+        AnnotationOrIdentifier := FullyQualifiedName | Identifier
         
         AtArgs := '@args' '(' AnnotationsOrIdentifiersPattern ')'
         
index 04399e1884920153a5417a008b238406f0a7d3fc..0d67221e9b4ae334180097cfcc9cf3cb8b9b8090 100644 (file)
@@ -1,6 +1,6 @@
 public aspect AnnotationAspect03 {
     
-    declare warning : execution(* *.*(..)) && @annotation(@SimpleAnnotation)
+    declare warning : execution(* *.*(..)) && @annotation(SimpleAnnotation)
                     : "@annotation matched here";
     
     
index 010808ef0be8ebcf2ad193e1c833fc209b030325..2e02000029f8c28ea9194d5b1b2b49b0d0829ad8 100644 (file)
@@ -62,62 +62,62 @@ public aspect AtArgsAspect {
        
        // Non-inherited 
        // test 5
-       before() : myMethod() && @args(@MyAnnotation,..) {
+       before() : myMethod() && @args(MyAnnotation,..) {
                System.out.print("@args(@MyAnnotation,..): ");
                System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL");
        }
-       before() : myMethod() && !@args(@MyAnnotation,..) {
+       before() : myMethod() && !@args(MyAnnotation,..) {
                System.out.print("@args(@MyAnnotation,..): ");
                System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL");
        }
 
        // test 6
-       before() : myMethod() && @args(@MyAnnotation,*,*,@MyAnnotation,*) {
+       before() : myMethod() && @args(MyAnnotation,*,*,MyAnnotation,*) {
                System.out.print("@args(@MyAnnotation,*,*,@MyAnnotation,*): ");
                System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL");
        }
-       before() : myMethod() && !@args(@MyAnnotation,*,*,@MyAnnotation,*) {
+       before() : myMethod() && !@args(MyAnnotation,*,*,MyAnnotation,*) {
                System.out.print("@args(@MyAnnotation,*,*,@MyAnnotation,*): ");
                System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL");
        }
 
        // test 7
-       before() : myMethod() && @args(@MyAnnotation,*,*,@MyAnnotation,@MyAnnotation) {
+       before() : myMethod() && @args(MyAnnotation,*,*,MyAnnotation,MyAnnotation) {
                System.out.print("@args(@MyAnnotation,*,*,@MyAnnotation,@MyAnnotation): ");
                System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL");
        }
-       before() : myMethod() && !@args(@MyAnnotation,*,*,@MyAnnotation,@MyAnnotation) {
+       before() : myMethod() && !@args(MyAnnotation,*,*,MyAnnotation,MyAnnotation) {
                System.out.print("@args(@MyAnnotation,*,*,@MyAnnotation,@MyAnnotation): ");
                System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL");
        }
        
        // Inherited
        // test 8
-       before() : myMethod() && @args(..,@MyInheritableAnnotation,*) {
+       before() : myMethod() && @args(..,MyInheritableAnnotation,*) {
                System.out.print("@args(..,@MyInheritableAnnotation,*): ");
                System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL");
        }
-       @org.aspectj.lang.annotation.SuppressAjWarnings before() : myMethod() && !@args(..,@MyInheritableAnnotation,*) {
+       @org.aspectj.lang.annotation.SuppressAjWarnings before() : myMethod() && !@args(..,MyInheritableAnnotation,*) {
                System.out.print("@args(..,@MyInheritableAnnotation,*): ");
                System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL");
        }
 
        // test 9
-       before() : myMethod() && @args(..,@MyInheritableAnnotation,@MyInheritableAnnotation) {
+       before() : myMethod() && @args(..,MyInheritableAnnotation,MyInheritableAnnotation) {
                System.out.print("@args(..,@MyInheritableAnnotation,@MyInheritableAnnotation): ");
                System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL");
        }
-       @org.aspectj.lang.annotation.SuppressAjWarnings before() : myMethod() && !@args(..,@MyInheritableAnnotation,@MyInheritableAnnotation) {
+       @org.aspectj.lang.annotation.SuppressAjWarnings before() : myMethod() && !@args(..,MyInheritableAnnotation,MyInheritableAnnotation) {
                System.out.print("@args(..,@MyInheritableAnnotation,@MyInheritableAnnotation): ");
                System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL");
        }
 
        // test 10
-       before() : myMethod() && @args(..,@MyInheritableAnnotation,@MyInheritableAnnotation,@MyInheritableAnnotation) {
+       before() : myMethod() && @args(..,MyInheritableAnnotation,MyInheritableAnnotation,MyInheritableAnnotation) {
                System.out.print("@args(..,@MyInheritableAnnotation,@MyInheritableAnnotation,@MyInheritableAnnotation): ");
                System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL");
        }
-       before() : myMethod() && !@args(..,@MyInheritableAnnotation,@MyInheritableAnnotation,@MyInheritableAnnotation) {
+       before() : myMethod() && !@args(..,MyInheritableAnnotation,MyInheritableAnnotation,MyInheritableAnnotation) {
                System.out.print("@args(..,@MyInheritableAnnotation,@MyInheritableAnnotation,@MyInheritableAnnotation): ");
                System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL");
        }
index 2c598e42f5bb906aca3ea4376c5d7216b3afcf9c..b5c58a013b0ccde34701f564770d8c35687b0ea9 100644 (file)
@@ -1,5 +1,5 @@
 public aspect DeclareEoW {
        
-       declare warning : @args(@MyAnnotation) : "@args is not allowed in declares...";
+       declare warning : @args(MyAnnotation) : "@args is not allowed in declares...";
        
 }
\ No newline at end of file
index 8e9238262ec64b5e99a4ba36627965cebd04ca91..d9981b37268b57d72fa552afac6f1da856c5f482 100644 (file)
@@ -1,6 +1,6 @@
 public aspect AtTargetAspect {
 
-  before(): call(* *(..)) && @target(@MyAnnotation) {
+  before(): call(* *(..)) && @target(MyAnnotation) {
     System.err.println("advice running");
   }
     
index ee2fbccc12784dcb4d637b220e91291c6c42762c..dcd102233b1de612b45bc5fda0295f2e192a1140 100644 (file)
@@ -20,7 +20,7 @@ aspect X {
 \r
   static boolean b = false;\r
 \r
-  before(): call(* m(..)) && !within(X) && @args(@Colored) {\r
+  before(): call(* m(..)) && !within(X) && @args(Colored) {\r
     b=true;\r
   }\r
 \r
index b442e3a9974042e23b96db5ca8d84faa657abb6b..141975a16c553ce71868387f7ce545c9806e6dd5 100644 (file)
@@ -3,11 +3,11 @@ import d.e.f.Color;
 
 public aspect X {
 
-  before(): call(* *(..)) && @annotation(@Color) {
+  before(): call(* *(..)) && @annotation(Color) {
     System.err.println("Before call to "+thisJoinPoint);
   }
   
-  before(): execution(* *(..)) && @annotation(@Color) {
+  before(): execution(* *(..)) && @annotation(Color) {
     System.err.println("Before execution of "+thisJoinPoint);
   }
 }
index 491e5400da196e801d8b6f3f85f854a1495f4de6..4b7252fef1a7fd722492f5eaffad60deb98278dd 100644 (file)
@@ -1,7 +1,7 @@
 public aspect DeclareEoW {
        
-       declare warning : @this(@MyAnnotation) : "should give compilation error";
+       declare warning : @this(MyAnnotation) : "should give compilation error";
        
-       declare error : @target(@MyAnnotation) : "should give compilation error";
+       declare error : @target(MyAnnotation) : "should give compilation error";
        
 }
\ No newline at end of file
index ea38a52c4d87e204406c00cddd188283c05b2807..03728c59948ce6bb702142d17155eb8c10970d38 100644 (file)
@@ -4,13 +4,13 @@ public aspect NotRuntimeRetention {
     pointcut doSomethingCall() : call(* doSomething());
     
     // CE L7
-    before() : doSomethingExecution() && @this(@MyClassRetentionAnnotation) {
+    before() : doSomethingExecution() && @this(MyClassRetentionAnnotation) {
        // should be compile-time error!
         System.out.println("How did I get here?");
     }
     
     // CE L13
-    after() returning : doSomethingCall() && @target(@MyClassRetentionAnnotation) {
+    after() returning : doSomethingCall() && @target(MyClassRetentionAnnotation) {
        // should be compile-time error!
         System.out.println("How did I get here?");
     }
index 2936b2ec58985a098ef135272394a26d31e4c0d2..e0fc46d634e098507fdb7af693c8fb8804d31858 100644 (file)
@@ -16,14 +16,14 @@ public aspect ThisOrTargetTests {
   pointcut doSomethingExecution() : execution(* doSomething());\r
   pointcut doSomethingCall() : call(* doSomething());\r
   \r
-  before() : doSomethingExecution() && @this(@MyAnnotation) {\r
+  before() : doSomethingExecution() && @this(MyAnnotation) {\r
        // should match:\r
        // b.doSomething(), reallyB.doSomething() [with test],\r
        // c.doSomething()\r
        add(before1Matches,thisJoinPointStaticPart);\r
   }\r
   \r
-  before() : doSomethingExecution() && @this(@MyInheritableAnnotation) {\r
+  before() : doSomethingExecution() && @this(MyInheritableAnnotation) {\r
        // should match:\r
        // c.doSomething()\r
        // d.doSomething()\r
@@ -31,14 +31,14 @@ public aspect ThisOrTargetTests {
        add(before2Matches,thisJoinPointStaticPart);\r
   }\r
   \r
-  after() returning : doSomethingCall() && @target(@MyAnnotation) {\r
+  after() returning : doSomethingCall() && @target(MyAnnotation) {\r
        // should match:\r
        // b.doSomething(), reallyB.doSomething() [with test],\r
        // c.doSomething()\r
        add(after1Matches,thisJoinPointStaticPart);\r
   }\r
   \r
-  after() returning : doSomethingCall() && @target(@MyInheritableAnnotation) {\r
+  after() returning : doSomethingCall() && @target(MyInheritableAnnotation) {\r
        // should match:\r
        // c.doSomething()\r
        // d.doSomething()\r
index 96ed0188d1a50e50b10ed140452c7fb50c916b07..139b72d5d3abf8c72e0756a80b3243cfb2297f6c 100644 (file)
@@ -1,14 +1,14 @@
 public aspect WithinAndWithinCodeTests {
        
        // should be two matches, L32 and L39
-       declare warning : execution(* doSomething(..)) && @within(@MyAnnotation)
+       declare warning : execution(* doSomething(..)) && @within(MyAnnotation)
                        : "@within match on non-inherited annotation";
        
        // one match on L39
-       declare warning : execution(* doSomething(..)) && @within(@MyInheritableAnnotation)
+       declare warning : execution(* doSomething(..)) && @within(MyInheritableAnnotation)
                        : "@within match on inheritable annotation";
        
        // one match on L32
-       declare warning : call(* doSomething(..)) && @withincode(@MyClassRetentionAnnotation)
+       declare warning : call(* doSomething(..)) && @withincode(MyClassRetentionAnnotation)
                        : "@withincode match";  
 }
\ No newline at end of file
index 71be36a23f4adc36cd65bc9883eb4a5d3c4ab018..cca0c32c3822d57a431743fb160f38bb6839dd08 100644 (file)
@@ -129,7 +129,8 @@ public class AnnotationPatternList extends PatternNode {
                if (type == AnnotationTypePattern.ELLIPSIS) {
                        buf.append("..");
                } else {
-                       buf.append(type.toString());
+                       String annPatt = type.toString();
+                       buf.append(annPatt.startsWith("@") ? annPatt.substring(1) : annPatt);
                }
        }
        buf.append(")");
index f62cefeb24e51f13b84ba9c55ad8471f53436240..e396576de1987732a65f9d6402ca2a6346eab977 100644 (file)
@@ -244,7 +244,8 @@ public class AnnotationPointcut extends NameBindingPointcut {
        public String toString() {
                StringBuffer buf = new StringBuffer();
                buf.append("@annotation(");
-               buf.append(annotationTypePattern.toString());
+               String annPatt = annotationTypePattern.toString();
+               buf.append(annPatt.startsWith("@") ? annPatt.substring(1) : annPatt);
                buf.append(")");
                return buf.toString();
        }
index 811874fe49aaccbf83ee8b2b709bb2881c287e33..8e1b17d17ce80aa1fd2f2ecfe3de1cc0ad722c5c 100644 (file)
@@ -42,7 +42,7 @@ public class ExactAnnotationTypePattern extends AnnotationTypePattern {
                this.resolved = (annotationType instanceof ResolvedTypeX);
        }
 
-       public ExactAnnotationTypePattern(String formalName) {
+       protected ExactAnnotationTypePattern(String formalName) {
                this.formalName = formalName;
                this.resolved = false;
                this.bindingPattern = true;
@@ -104,8 +104,9 @@ public class ExactAnnotationTypePattern extends AnnotationTypePattern {
                        Bindings bindings, boolean allowBinding) {
                if (resolved) return this;
                resolved = true;
-               if (formalName != null) {
-                       FormalBinding formalBinding = scope.lookupFormal(formalName);
+               String simpleName = maybeGetSimpleName();
+               if (simpleName != null) {
+                       FormalBinding formalBinding = scope.lookupFormal(simpleName);
                        if (formalBinding != null) {
                                if (bindings == null) {
                                        scope.message(IMessage.ERROR, this, "negation doesn't allow binding");
@@ -116,6 +117,8 @@ public class ExactAnnotationTypePattern extends AnnotationTypePattern {
                                                "name binding only allowed in @pcds, args, this, and target");
                                        return this;
                                }
+                               formalName = simpleName;
+                               bindingPattern = true;
                                verifyIsAnnotationType(formalBinding.getType(),scope);
                                BindingAnnotationTypePattern binding = new BindingAnnotationTypePattern(formalBinding);
                                binding.copyLocationFrom(this);
@@ -123,30 +126,32 @@ public class ExactAnnotationTypePattern extends AnnotationTypePattern {
                                binding.resolveBinding(scope.getWorld());
                                
                                return binding;
-                       } else {
-                               scope.message(IMessage.ERROR,this,"unbound formal " + formalName);
-                               return this;
-                       }
-               } else {
-                       // Non binding case
+                       } 
+               }
 
-                       String cleanname = annotationType.getName();
-                       annotationType = scope.getWorld().resolve(annotationType,true);
-                       
-                       // We may not have found it if it is in a package, lets look it up...
-                       if (annotationType == ResolvedTypeX.MISSING) {
-                               TypeX type = null;
-                               while ((type = scope.lookupType(cleanname,this)) == ResolvedTypeX.MISSING) {
-                                       int lastDot = cleanname.lastIndexOf('.');
-                                       if (lastDot == -1) break;
-                                       cleanname = cleanname.substring(0,lastDot)+"$"+cleanname.substring(lastDot+1);
-                               }
-                               annotationType = scope.getWorld().resolve(type,true);
+               // Non binding case
+               String cleanname = annotationType.getName();
+               annotationType = scope.getWorld().resolve(annotationType,true);
+               
+               // We may not have found it if it is in a package, lets look it up...
+               if (annotationType == ResolvedTypeX.MISSING) {
+                       TypeX type = null;
+                       while ((type = scope.lookupType(cleanname,this)) == ResolvedTypeX.MISSING) {
+                               int lastDot = cleanname.lastIndexOf('.');
+                               if (lastDot == -1) break;
+                               cleanname = cleanname.substring(0,lastDot)+"$"+cleanname.substring(lastDot+1);
                        }
-                       
-                       verifyIsAnnotationType(annotationType,scope);
-                       return this;
+                       annotationType = scope.getWorld().resolve(type,true);
                }
+               
+               verifyIsAnnotationType(annotationType,scope);
+               return this;
+       }
+       
+       private String maybeGetSimpleName() {
+               if (formalName != null) return formalName;
+               String ret = annotationType.getName();
+               return (ret.indexOf('.') == -1) ? ret : null;
        }
        
        /**
index 80322fabeb8a44406ca29c7f1672383603cd44ef..d33588f0c993c6c0463ac8c01188c8f3639b0959 100644 (file)
@@ -689,11 +689,9 @@ public class PatternParser {
                ExactAnnotationTypePattern p = null;
                int startPos = tokenSource.peek().getStart();
                if (maybeEat("@")) {
-                       p = parseSimpleAnnotationName();
-               } else {
-                       String formal = parseIdentifier();
-                       p = new ExactAnnotationTypePattern(formal); // will get replaced when bindings resolved
+                       throw new ParserException("@Foo form was deprecated in AspectJ 5 M2: annotation name or var ",tokenSource.peek(-1));
                }
+               p = parseSimpleAnnotationName();
                int endPos = tokenSource.peek(-1).getEnd();
                p.setLocation(sourceContext,startPos,endPos);
                return p;
index 6aff2dbd973031c230dd95dfbe2cffd4ca30c36a..590c022d385fd0d76ce3b076ad97429a84183fd5 100644 (file)
@@ -261,7 +261,8 @@ public class ThisOrTargetAnnotationPointcut extends NameBindingPointcut {
     public String toString() {
                StringBuffer buf = new StringBuffer();
                buf.append(isThis ? "@this(" : "@target(");
-               buf.append(annotationTypePattern.toString());
+               String annPatt = annotationTypePattern.toString();
+               buf.append(annPatt.startsWith("@") ? annPatt.substring(1) : annPatt);
                buf.append(")");
                return buf.toString();   
        }
index 1ae0e1db9fe7b0451cec5666490963ad3e8e356a..cbcf0e55bc17c7ac51c6bf1f69360e53c30f36fd 100644 (file)
@@ -199,7 +199,8 @@ public class WithinAnnotationPointcut extends NameBindingPointcut {
     public String toString() {
                StringBuffer buf = new StringBuffer();
                buf.append("@within(");
-               buf.append(annotationTypePattern.toString());
+               String annPatt = annotationTypePattern.toString();
+               buf.append(annPatt.startsWith("@") ? annPatt.substring(1) : annPatt);
                buf.append(")");
                return buf.toString();
     }
index 163a83fb05c5384e198623574d420374211bceaf..edcc5b39870fb4f338a8c27be246e86d5d1f2ed7 100644 (file)
@@ -206,7 +206,8 @@ public class WithinCodeAnnotationPointcut extends NameBindingPointcut {
        public String toString() {
            StringBuffer buf = new StringBuffer();
                buf.append("@withincode(");
-               buf.append(annotationTypePattern.toString());
+               String annPatt = annotationTypePattern.toString();
+               buf.append(annPatt.startsWith("@") ? annPatt.substring(1) : annPatt);
                buf.append(")");
                return buf.toString();
        }
index 464d2e9ec3861073f70d1bc6d318a16f8ba57aba..136ab98fa36342b20974e74c5e7800923a0e2f7c 100644 (file)
@@ -110,7 +110,7 @@ public class AnnotationPatternTestCase extends TestCase {
        }
 
        public void testParseNameOrVarAnnotationPattern() {
-               PatternParser p = new PatternParser("@Foo");
+               PatternParser p = new PatternParser("Foo");
                AnnotationTypePattern foo = p.parseAnnotationNameOrVarTypePattern();
                assertTrue("ExactAnnotationTypePattern",foo instanceof ExactAnnotationTypePattern);
                assertEquals("Foo",TypeX.forName("Foo"),((ExactAnnotationTypePattern)foo).annotationType);              
@@ -127,7 +127,7 @@ public class AnnotationPatternTestCase extends TestCase {
        }
 
        public void testParseNameOrVarAnnotationPatternWithOr() {
-               PatternParser p = new PatternParser("@Foo || @Boo");
+               PatternParser p = new PatternParser("Foo || Boo");
                AnnotationTypePattern foo = p.parseAnnotationNameOrVarTypePattern();
                // rest of pattern not consumed...
                assertTrue("ExactAnnotationTypePattern",foo instanceof ExactAnnotationTypePattern);
@@ -138,12 +138,11 @@ public class AnnotationPatternTestCase extends TestCase {
                PatternParser p = new PatternParser("foo");
                AnnotationTypePattern foo = p.parseAnnotationNameOrVarTypePattern();
                assertTrue("ExactAnnotationTypePattern",foo instanceof ExactAnnotationTypePattern);
-               assertNull("no type pattern yet",((ExactAnnotationTypePattern)foo).annotationType);
-               assertEquals("foo",((ExactAnnotationTypePattern)foo).formalName);
+               assertEquals("@foo",((ExactAnnotationTypePattern)foo).toString());
        }
 
        public void testParseNameOrVarAnnotationPatternWithAnd() {
-               PatternParser p = new PatternParser("@Foo @Boo");
+               PatternParser p = new PatternParser("Foo Boo");
                AnnotationTypePattern foo = p.parseAnnotationNameOrVarTypePattern();
                // rest of pattern not consumed...
                assertEquals("@Foo",foo.toString());
index 8854f3e1166a3710290e81381a68d34adc0d1aad..c800427d00599118dff10e79dd1dc8ac3936dd17 100644 (file)
@@ -152,13 +152,13 @@ public class ParserTestCase extends TestCase {
        }
        
        public void testAtAnnotation() {
-           PatternParser parser = new PatternParser("@annotation(@Foo)");
+           PatternParser parser = new PatternParser("@annotation(Foo)");
            AnnotationPointcut p = (AnnotationPointcut) parser.parsePointcut();
-           assertEquals("@annotation(@Foo)",p.toString());                                                 
+           assertEquals("@annotation(Foo)",p.toString());                                                  
        }
        
        public void testBadAtAnnotation() {
-           PatternParser parser = new PatternParser("@annotation(!@Foo)");
+           PatternParser parser = new PatternParser("@annotation(!Foo)");
            try {
                Pointcut p = parser.parsePointcut();
                fail("Expected parser exception");
@@ -174,7 +174,7 @@ public class ParserTestCase extends TestCase {
        }
        
        public void testDoubleAtAnnotation() {
-           PatternParser parser = new PatternParser("@annotation(@Foo @Goo)");
+           PatternParser parser = new PatternParser("@annotation(Foo Goo)");
            try {
                Pointcut p = parser.parsePointcut();
                fail("Expected parser exception");
@@ -187,18 +187,18 @@ public class ParserTestCase extends TestCase {
            PatternParser parser = new PatternParser("@within(foo)");
            WithinAnnotationPointcut p = (WithinAnnotationPointcut) parser.parsePointcut();
            assertEquals("@within(foo)",p.toString());   
-           parser = new PatternParser("@within(@Foo))");
+           parser = new PatternParser("@within(Foo))");
            p = (WithinAnnotationPointcut) parser.parsePointcut();
-           assertEquals("@within(@Foo)",p.toString());
+           assertEquals("@within(Foo)",p.toString());
        }
        
        public void testAtWithinCode() {
            PatternParser parser = new PatternParser("@withincode(foo)");
            WithinCodeAnnotationPointcut p = (WithinCodeAnnotationPointcut) parser.parsePointcut();
            assertEquals("@withincode(foo)",p.toString());       
-           parser = new PatternParser("@withincode(@Foo))");
+           parser = new PatternParser("@withincode(Foo))");
            p = (WithinCodeAnnotationPointcut) parser.parsePointcut();
-           assertEquals("@withincode(@Foo)",p.toString());
+           assertEquals("@withincode(Foo)",p.toString());
        }
        
        public void testAtThis() {
@@ -206,10 +206,10 @@ public class ParserTestCase extends TestCase {
            ThisOrTargetAnnotationPointcut p = (ThisOrTargetAnnotationPointcut) parser.parsePointcut();
            assertEquals("@this(foo)",p.toString());
            assertTrue("isThis",p.isThis());
-           parser = new PatternParser("@this(@Foo))");
+           parser = new PatternParser("@this(Foo))");
            p = (ThisOrTargetAnnotationPointcut) parser.parsePointcut();
            assertTrue("isThis",p.isThis());
-           assertEquals("@this(@Foo)",p.toString());
+           assertEquals("@this(Foo)",p.toString());
        }
 
        public void testAtTarget() {
@@ -217,16 +217,16 @@ public class ParserTestCase extends TestCase {
            ThisOrTargetAnnotationPointcut p = (ThisOrTargetAnnotationPointcut) parser.parsePointcut();
            assertEquals("@target(foo)",p.toString());
            assertTrue("isTarget",!p.isThis());
-           parser = new PatternParser("@target(@Foo))");
+           parser = new PatternParser("@target(Foo))");
            p = (ThisOrTargetAnnotationPointcut) parser.parsePointcut();
            assertTrue("isTarget",!p.isThis());
-           assertEquals("@target(@Foo)",p.toString());
+           assertEquals("@target(Foo)",p.toString());
        }
        
        public void testAtArgs() {
-           PatternParser parser = new PatternParser("@args(@Foo,@Goo,*,..,@Moo)");
+           PatternParser parser = new PatternParser("@args(Foo,Goo,*,..,Moo)");
            Pointcut p = parser.parsePointcut();
-           assertEquals("@args(@Foo, @Goo, @ANY, .., @Moo)",p.toString());
+           assertEquals("@args(Foo, Goo, ANY, .., Moo)",p.toString());
        }
        
        public TestScope makeSimpleScope() {
index 14a19e0de97aabdadd8f7143e34cfc532cccfbb1..f28a5a7ac564f5c555315660ce47837336909648 100644 (file)
@@ -289,7 +289,7 @@ public class PointcutRewriterTest extends TestCase {
                        }
                }
                // + @
-               p = getPointcut("@this(@Foo)");
+               p = getPointcut("@this(Foo)");
                matches = p.couldMatchKinds();
                for (Iterator iter = matches.iterator(); iter.hasNext();) {
                        Shadow.Kind kind = (Shadow.Kind) iter.next();
@@ -315,7 +315,7 @@ public class PointcutRewriterTest extends TestCase {
                        }
                }
                // + @
-               p = getPointcut("@target(@Foo)");
+               p = getPointcut("@target(Foo)");
                matches = p.couldMatchKinds();
                for (Iterator iter = matches.iterator(); iter.hasNext();) {
                        Shadow.Kind kind = (Shadow.Kind) iter.next();
@@ -337,7 +337,7 @@ public class PointcutRewriterTest extends TestCase {
        }
        
        public void testKindSetOfAnnotation() {
-               Pointcut p = getPointcut("@annotation(@Foo)");
+               Pointcut p = getPointcut("@annotation(Foo)");
                assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));               
        }
        
@@ -345,7 +345,7 @@ public class PointcutRewriterTest extends TestCase {
                Pointcut p = getPointcut("within(*)");
                assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));
                // + @
-               p = getPointcut("@within(@Foo)");
+               p = getPointcut("@within(Foo)");
                assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));
        }
        
@@ -365,7 +365,7 @@ public class PointcutRewriterTest extends TestCase {
                assertTrue("Need cons-exe for inlined field inits",matches.contains(Shadow.ConstructorExecution));
                assertTrue("Need init for inlined field inits",matches.contains(Shadow.Initialization));
                // + @
-               p = getPointcut("@withincode(@Foo)");
+               p = getPointcut("@withincode(Foo)");
                matches = p.couldMatchKinds();
                for (Iterator iter = matches.iterator(); iter.hasNext();) {
                        Shadow.Kind kind = (Shadow.Kind) iter.next();
@@ -409,9 +409,9 @@ public class PointcutRewriterTest extends TestCase {
        }
        
        public void testOrderingInAnd() {
-               Pointcut bigLongPC = getPointcut("cflow(this(Foo)) && @args(@X) && args(X) && @this(@Foo) && @target(@Boo) && this(Moo) && target(Boo) && @annotation(@Moo) && @withincode(@Boo) && withincode(new(..)) && set(* *)&& @within(@Foo) && within(Foo)");
+               Pointcut bigLongPC = getPointcut("cflow(this(Foo)) && @args(X) && args(X) && @this(Foo) && @target(Boo) && this(Moo) && target(Boo) && @annotation(Moo) && @withincode(Boo) && withincode(new(..)) && set(* *)&& @within(Foo) && within(Foo)");
                Pointcut rewritten = prw.rewrite(bigLongPC);
-               assertEquals("((((((((((((within(Foo) && @within(@Foo)) && set(* *)) && withincode(new(..))) && @withincode(@Boo)) && @annotation(@Moo)) && target(Boo)) && this(Moo)) && @target(@Boo)) && @this(@Foo)) && args(X)) && @args(@X)) && cflow(this(Foo)))",rewritten.toString());
+               assertEquals("((((((((((((within(Foo) && @within(Foo)) && set(* *)) && withincode(new(..))) && @withincode(Boo)) && @annotation(Moo)) && target(Boo)) && this(Moo)) && @target(Boo)) && @this(Foo)) && args(X)) && @args(X)) && cflow(this(Foo)))",rewritten.toString());
        }
        
        public void testOrderingInSimpleOr() {