]> source.dussan.org Git - aspectj.git/commitdiff
@testcase PR#49295 extra warning (join point?) for interface-typepattern execution
authorwisberg <wisberg>
Tue, 23 Dec 2003 01:28:08 +0000 (01:28 +0000)
committerwisberg <wisberg>
Tue, 23 Dec 2003 01:28:08 +0000 (01:28 +0000)
tests/ajcTestsFailing.xml
tests/bugs/SubtypeConstructorCW.java [new file with mode: 0644]

index fe3fdc6649f61dc32ad6f113273ea0a5d540cd32..db19ce8574ad5883e139f4399aad941f4cda855d 100644 (file)
         <run class="AfterReturningParamMatching"/>
     </ajc-test>
 
+    <ajc-test dir="bugs" 
+               pr="49295"
+               title="declare warning on subtype constructor">
+        <compile files="SubtypeConstructorCW.java" >
+                       <message kind="warning" line="5" text="String as first"/>
+                       <message kind="warning" line="10" text="String as first"/>
+        </compile>
+        <run class="SubtypeConstructorCW"/>
+    </ajc-test>
+
 
 </suite>
diff --git a/tests/bugs/SubtypeConstructorCW.java b/tests/bugs/SubtypeConstructorCW.java
new file mode 100644 (file)
index 0000000..d3b6a87
--- /dev/null
@@ -0,0 +1,67 @@
+
+import org.aspectj.testing.Tester;
+
+
+class C implements Runnable { // CW 5
+       public void run() {
+       }
+}
+class F implements Runnable {
+       F(int i) {// CW 10
+       } 
+       public void run() {
+       }
+}
+
+/** @testcase PR#49295 extra warning (join point?) for typepattern-type execution */
+public class SubtypeConstructorCW {
+       public static void main(String[] args) {
+               new C().run();
+               new D("").run();
+               new E("", 0).run();
+               new F(0).run();
+       }
+}
+
+class D implements Runnable {
+       D(String s) {
+       }
+       public void run() {
+       }
+}
+
+class E implements Runnable {
+       E(String s, int i) {
+       }
+       public void run() {
+       }
+}
+
+// XXX warning: harness might ignore duplicates, so this can give false positives
+aspect A {
+       static {
+               Tester.expectEvents(
+                       new String[] {
+                               "before execution(C())",
+                               "before execution(F(int))",
+                               });
+       }
+       static void event(String s) {
+               System.out.println("    \"" + s + "\",");
+       }
+       // getting two warning rather than one, and on wrong places
+       declare warning : execution((Runnable +).new (..))
+               && !execution(new (String,
+                       .
+                       .)) : "Runnable constructors should take String as first parameter";
+
+       //  this works as expected
+       //    declare warning: execution((!Runnable && Runnable+).new(..))
+       //        && !execution(new(String, ..)) 
+       //        : "Runnable constructors should take String as first parm";
+
+       before() : execution((Runnable +).new (..))
+               && !execution(new (String,..)) {
+               event("before " + thisJoinPointStaticPart);
+       }
+}