diff options
author | wisberg <wisberg> | 2003-02-12 22:43:39 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2003-02-12 22:43:39 +0000 |
commit | ab8f8e5f7c93538ffc113009ad9f811366f1acc5 (patch) | |
tree | e12f06d38e681c8cc3442ea5703e508b8bd82748 | |
parent | 049f5d29418e7920dde19d7cd521d236da1f8ff3 (diff) | |
download | aspectj-ab8f8e5f7c93538ffc113009ad9f811366f1acc5.tar.gz aspectj-ab8f8e5f7c93538ffc113009ad9f811366f1acc5.zip |
testcase for bug 31724
http://dev.eclipse.org/bugs/show_bug.cgi?id=31724
declare warning context.
Note context itself untested -- need to check/upgrade message checking.
-rw-r--r-- | tests/ajcTestsFailing.xml | 22 | ||||
-rw-r--r-- | tests/new/declare/DeclareWarning.java | 79 |
2 files changed, 101 insertions, 0 deletions
diff --git a/tests/ajcTestsFailing.xml b/tests/ajcTestsFailing.xml index 3b1ec8e41..dd0d78673 100644 --- a/tests/ajcTestsFailing.xml +++ b/tests/ajcTestsFailing.xml @@ -2,6 +2,7 @@ <!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"> <suite> + <ajc-test dir="new" title="incompatible advice throws clause are a compile-time error" keywords="from-resolved_10x"> @@ -29,4 +30,25 @@ </compile> </ajc-test> + <ajc-test dir="new/declare" pr="31724" + title="omnibus declare warning context" + comment="XXX untested: no source context shown"> + <compile files="DeclareWarning.java"> + <message kind="warning" line="5"/> + <message kind="warning" line="12"/> + <message kind="warning" line="13"/> + <message kind="warning" line="14"/> + <message kind="warning" line="15"/> + <message kind="warning" line="16"/> + <message kind="warning" line="17"/> + <message kind="warning" line="18"/> + <message kind="warning" line="21"/> + <message kind="warning" line="22"/> + <message kind="warning" line="23"/> + <message kind="warning" line="33"/> + <message kind="warning" line="36"/> + <message kind="warning" line="39"/> + <message kind="warning" line="73"/> + </compile> + </ajc-test> </suite> diff --git a/tests/new/declare/DeclareWarning.java b/tests/new/declare/DeclareWarning.java new file mode 100644 index 000000000..1c1fadc63 --- /dev/null +++ b/tests/new/declare/DeclareWarning.java @@ -0,0 +1,79 @@ + +/** @testcase PR#31724 omnibus declare-warning test */ +public class DeclareWarning { + static { + if (null == System.getProperty("ignore")) { // CW 5 + throw new Error("never thrown"); + } + } + static int staticInt; + int instanceInt; + public static void main (String[] args) { + DeclareWarning dw = new DeclareWarning(); // CW 12..18 + int i = staticInt; + i = dw.instanceInt; + staticInt = 2; + dw.instanceInt = 2; + run(); + dw.irun(); + throw new Error("compile-only test"); + } + public static void run() {} // CW 21..23 + public void irun() {} + public DeclareWarning() { + try { + long l = System.currentTimeMillis(); + if (0l == l) { + throw new Error("never thrown"); + } else if (1l == l) { + throw new RuntimeException("never thrown"); + } else if (2l == l) { + throw new OutOfMemoryError("never thrown"); + } + } catch (OutOfMemoryError e) { + // CW 34 + System.err.println("never run"); + } catch (Error e) { + // CW 37 + System.err.println("never run"); + } catch (RuntimeException x) { + // CW 40 + System.err.println("never run"); + } + } +} + +aspect A { + declare warning: staticinitialization(DeclareWarning) + : "staticinitialization(DeclareWarning)"; + declare warning: initialization(DeclareWarning.new(..)) + : "initialization(DeclareWarning)"; + declare warning: get(int staticInt) : "get staticInt"; + declare warning: get(int instanceInt) : "get instanceInt"; + declare warning: set(int staticInt) : "set staticInt"; + declare warning: set(int instanceInt) : "set instanceInt"; + declare warning: call(void run()) : "call(void run())"; + declare warning: call(void irun()) : "call(void irun())"; + declare warning: call(DeclareWarning.new()) + : "call(DeclareWarning.new())"; + declare warning: execution(void run()) : "execution(void run())"; + declare warning: execution(void irun()) : "execution(void irun())"; + declare warning: execution(DeclareWarning.new()) + : "execution(DeclareWarning.new())"; + declare warning: handler(Error) : "handler(Error)"; + declare warning: handler(OutOfMemoryError) && within(DeclareWarning) + : "handler(OutOfMemoryError) && within(DeclareWarning)"; + declare warning: handler(RuntimeException) + && withincode(DeclareWarning.new()) + : "handler(RuntimeException) && withincode(DeclareWarning.new())"; + declare warning: adviceexecution() && within(A) + : "adviceExecution() && within(A)"; + + before() : initialization(DeclareWarning.new(..)) { + // CW 73 + long l = System.currentTimeMillis(); + if (0l == l) { + throw new Error("never thrown"); + } + } +} |