]> source.dussan.org Git - aspectj.git/commitdiff
testcode for 135865 and 142165
authoraclement <aclement>
Wed, 17 May 2006 09:43:15 +0000 (09:43 +0000)
committeraclement <aclement>
Wed, 17 May 2006 09:43:15 +0000 (09:43 +0000)
tests/bugs152/pr135865/A.java [new file with mode: 0644]
tests/bugs152/pr135865/B.java [new file with mode: 0644]
tests/bugs152/pr135865/One.java [new file with mode: 0644]
tests/bugs152/pr142165/A.java [new file with mode: 0644]
tests/bugs152/pr142165/C.java [new file with mode: 0644]
tests/bugs152/pr142165/aop.xml [new file with mode: 0644]
tests/bugs152/pr142165/aop2.xml [new file with mode: 0644]
tests/bugs152/pr142165/aop3.xml [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc152/ajc152.xml

diff --git a/tests/bugs152/pr135865/A.java b/tests/bugs152/pr135865/A.java
new file mode 100644 (file)
index 0000000..940540c
--- /dev/null
@@ -0,0 +1,30 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @interface Ann {}
+
+
+aspect Aspect {
+
+  // Call to an annotated method
+  pointcut annotated(Ann b) : call(@Ann * *(..)) && @annotation(b);
+
+  // Top level call to an annotated method
+  pointcut annotatedTop(Ann b) : annotated(b) && !cflowbelow(annotated(Ann));
+
+  // Non top level call
+  pointcut annotatedNotTop(Ann b, Ann bTopo) : 
+    annotated(b) && cflowbelow(annotatedTop(bTopo));
+
+  before(Ann b, Ann bTopo) : annotatedNotTop(b, bTopo) {
+    System.out.println("\tJoin point: " + thisJoinPointStaticPart);
+  }
+
+  // Methods with out the Ann annotation but in an Ann annotated type get Ann
+  declare @method: !@Ann * (@Ann *).*(..) : @Ann;
+}
+
+public class A {
+  @Ann void foo() { new B().foo(); new B().goo();}
+  public static void main(String[] args) { new A().foo(); }
+}
+
diff --git a/tests/bugs152/pr135865/B.java b/tests/bugs152/pr135865/B.java
new file mode 100644 (file)
index 0000000..c12542d
--- /dev/null
@@ -0,0 +1,6 @@
+
+@Ann class B {
+  //@Ann
+  void foo() { }
+  void goo() { }
+}
\ No newline at end of file
diff --git a/tests/bugs152/pr135865/One.java b/tests/bugs152/pr135865/One.java
new file mode 100644 (file)
index 0000000..f4110aa
--- /dev/null
@@ -0,0 +1,51 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @interface Ann {String value();}
+
+aspect Aspect {
+
+  // Methods with out the Ann annotation but in an Ann annotated type get Ann
+//  declare @method: !@Ann * (@Ann *).*(..) : @Ann("introduced");
+
+  // Call to an annotated method
+  pointcut annotated(Ann b) : call(@Ann * *(..)) && @annotation(b);
+
+  // Top level call to an annotated method
+  pointcut annotatedTop(Ann b) : annotated(b) && !cflowbelow(annotated(Ann));
+
+  // Non top level call
+  pointcut annotatedNotTop(Ann b, Ann bTopo) : 
+    annotated(b) && cflowbelow(annotatedTop(bTopo));
+
+  before(Ann b, Ann bTopo) :
+    annotatedNotTop(b, bTopo) {
+    System.out.println("Non-top:");
+    System.out.println("\tJoin point: " + thisJoinPointStaticPart);
+    System.out.println("\tEnclosing join point: " + thisEnclosingJoinPointStaticPart);
+    System.out.println("\tAnn: " + b);
+    System.out.println("\tTop annotation: " + bTopo);
+  }
+
+//  before(Ann b) :
+//    annotatedTop(b) {
+//    System.out.println("Top:");
+//    System.out.println("\tJoin point: " + thisJoinPointStaticPart);
+//    System.out.println("\tEnclosing join point: " +
+//thisEnclosingJoinPointStaticPart);
+//    System.out.println("\tAnn: " + b);
+//  }
+//  declare @method: !@Ann * (@Ann *).*(..) : @Ann("introduced");
+  declare @method: * B.goo() : @Ann("introduced");
+}
+
+public class A {
+  @Ann("A.foo") void foo() { new B().foo(); new B().goo();}
+  public static void main(String[] args) { new A().foo(); }
+}
+
+@Ann("B") class B {
+  // The Ann is injected here!
+  @Ann("B.foo") 
+  void foo() { }
+  void goo() { }
+}
diff --git a/tests/bugs152/pr142165/A.java b/tests/bugs152/pr142165/A.java
new file mode 100644 (file)
index 0000000..a37879a
--- /dev/null
@@ -0,0 +1,6 @@
+abstract aspect A {
+  abstract pointcut p();
+  before(): p() {
+    System.err.println("advice");
+  }
+}
diff --git a/tests/bugs152/pr142165/C.java b/tests/bugs152/pr142165/C.java
new file mode 100644 (file)
index 0000000..e03fbc8
--- /dev/null
@@ -0,0 +1,8 @@
+public class C {
+  public static void main(String []argv) {
+    new C().foo();
+  }
+  public void foo() {System.err.println("foo running");}
+}
+
diff --git a/tests/bugs152/pr142165/aop.xml b/tests/bugs152/pr142165/aop.xml
new file mode 100644 (file)
index 0000000..5e89ba9
--- /dev/null
@@ -0,0 +1,11 @@
+<aspectj>
+ <weaver options="-Xnoinline"/>
+    <aspects>
+      <concrete-aspect name="AA"
+                       extends="A">
+                         
+   <pointcut name="p" expression="within(SomeType) AND execution(* foo(..))" />                         
+                         
+ </concrete-aspect>
+    </aspects>
+</aspectj>
diff --git a/tests/bugs152/pr142165/aop2.xml b/tests/bugs152/pr142165/aop2.xml
new file mode 100644 (file)
index 0000000..3fca4ec
--- /dev/null
@@ -0,0 +1,11 @@
+<aspectj>
+ <weaver options="-Xnoinline"/>
+    <aspects>
+      <concrete-aspect name="AA"
+                       extends="A">
+                         
+   <pointcut name="p" expression="(within(*) AND (call(java.lang.String*.new(..)) || call(java.lang.Object.new(..))) )"/>
+                         
+ </concrete-aspect>
+    </aspects>
+</aspectj>
diff --git a/tests/bugs152/pr142165/aop3.xml b/tests/bugs152/pr142165/aop3.xml
new file mode 100644 (file)
index 0000000..d7ebd07
--- /dev/null
@@ -0,0 +1,11 @@
+<aspectj>
+ <weaver options="-Xnoinline"/>
+    <aspects>
+      <concrete-aspect name="AA"
+                       extends="A">
+                         
+   <pointcut name="p" expression="within(C) AND call(* foo(..))" />                         
+                         
+ </concrete-aspect>
+    </aspects>
+</aspectj>
index 6378b42ca6dd75c48d6f150b8a0aca9d88592194..eafefc2f033f32b3a9eb1de089734ee371a55ee5 100644 (file)
       </run>
     </ajc-test>
     
+    <ajc-test dir="bugs152/pr135865" title="misbehaving declare annotation">
+      <compile files="B.java,A.java" options="-1.5">
+       <!--message kind="weave" text="Join point 'method-call(void B.foo())' in Type 'A' (A.java:32) advised by before advice from 'Aspect' (A.java:22) [with runtime test]"/>
+       <message kind="weave" text="Join point 'method-call(void A.foo())' in Type 'A' (A.java:33) advised by before advice from 'Aspect' (A.java:22) [with runtime test]"/>
+       <message kind="weave" text="' void B.goo()' (A.java:7) is annotated with @Ann method annotation from 'Aspect' (A.java:27)"/-->
+      </compile>
+      <run class="A">
+        <stdout>
+          <line text="Join point: call(void B.foo())"/>
+          <line text="Join point: call(void B.goo())"/>
+        </stdout>
+      </run>
+    </ajc-test>
+    
     <ajc-test dir="bugs152/pr129704" title="annotations and generics leading to BCException">
       <compile files="A.java" options="-1.5"/>
       <run class="A">
         </compile>
     </ajc-test>
     
+    <ajc-test dir="bugs152/pr142165" title="broken concretization">
+      <compile files="C.java" options="-1.5"/>
+      <compile files="A.java" options="-1.5"/>
+      <run class="C" ltw="aop.xml">
+        <stderr>
+          <line text="warning at Type 'AA' (no debug info available)::0 no match for this type name: SomeType [Xlint:invalidAbsoluteTypeName]"/>        
+          <line text="foo running"/>
+           </stderr>
+      </run>
+    </ajc-test>
+    
+    <ajc-test dir="bugs152/pr142165" title="broken concretization - 2">
+      <compile files="C.java" options="-1.5"/>
+      <compile files="A.java" options="-1.5"/>
+      <run class="C" ltw="aop2.xml">
+        <stderr>
+           <line text="foo running"/>
+        </stderr>
+      </run>
+    </ajc-test>
+    
+    <ajc-test dir="bugs152/pr142165" title="broken concretization - 3">
+      <compile files="C.java" options="-1.5"/>
+      <compile files="A.java" options="-1.5"/>
+      <run class="C" ltw="aop3.xml">
+        <stderr>
+           <line text="advice"/>
+           <line text="foo running"/>
+        </stderr>
+      </run>
+    </ajc-test>
+    
 </suite>
\ No newline at end of file