From 6cded1d30cf1e59ee133ac08f44dabb7859b4fed Mon Sep 17 00:00:00 2001 From: wisberg Date: Tue, 23 Dec 2003 01:28:08 +0000 Subject: [PATCH] @testcase PR#49295 extra warning (join point?) for interface-typepattern execution --- tests/ajcTestsFailing.xml | 10 +++++ tests/bugs/SubtypeConstructorCW.java | 67 ++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 tests/bugs/SubtypeConstructorCW.java diff --git a/tests/ajcTestsFailing.xml b/tests/ajcTestsFailing.xml index fe3fdc664..db19ce857 100644 --- a/tests/ajcTestsFailing.xml +++ b/tests/ajcTestsFailing.xml @@ -141,5 +141,15 @@ + + + + + + + + diff --git a/tests/bugs/SubtypeConstructorCW.java b/tests/bugs/SubtypeConstructorCW.java new file mode 100644 index 000000000..d3b6a8765 --- /dev/null +++ b/tests/bugs/SubtypeConstructorCW.java @@ -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); + } +} -- 2.39.5