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 /tests/new | |
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.
Diffstat (limited to 'tests/new')
-rw-r--r-- | tests/new/declare/DeclareWarning.java | 79 |
1 files changed, 79 insertions, 0 deletions
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"); + } + } +} |