From 517b6c0ec2c76af89a6e78b75f292d67e71e8339 Mon Sep 17 00:00:00 2001 From: jhugunin Date: Mon, 23 Dec 2002 19:39:49 +0000 Subject: updated for new sematics of issingleton aspects advising their own initializers --- tests/new/ConstructorExecInit.java | 4 ++-- tests/new/ConstructorExecInitFails.java | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 tests/new/ConstructorExecInitFails.java diff --git a/tests/new/ConstructorExecInit.java b/tests/new/ConstructorExecInit.java index 337fbbda3..02b9bf293 100644 --- a/tests/new/ConstructorExecInit.java +++ b/tests/new/ConstructorExecInit.java @@ -17,10 +17,10 @@ public class ConstructorExecInit { /** @testcase after returning from initialization and after executing constructor */ aspect A { - after (Object target) : execution(*.new(..)) && target(target) { + after (Object target) : execution(*.new(..)) && target(target) && !within(A) { Tester.event("execution"); } - after () returning (Object target) : initialization(new(..)) { + after () returning (Object target) : initialization(new(..)) && !this(A) { Tester.event("initialization"); } } diff --git a/tests/new/ConstructorExecInitFails.java b/tests/new/ConstructorExecInitFails.java new file mode 100644 index 000000000..4b5e775e4 --- /dev/null +++ b/tests/new/ConstructorExecInitFails.java @@ -0,0 +1,26 @@ +import org.aspectj.testing.*; + +/** + * -usejavac mode: no error + * not -usejavac mode: VerifyError + */ +public class ConstructorExecInitFails { + public static void main(String[] args) { + try { + new ConstructorExecInitFails(); + } catch (ExceptionInInitializerError e) { + return; + } + Tester.checkFailed("shouldn't be able to run"); + } +} + +/** @testcase after returning from initialization and after executing constructor */ +aspect A { + after (Object target) : execution(*.new(..)) && target(target) { + Tester.checkFailed("shouldn't be able to run"); + } + after () returning (Object target) : initialization(new(..)) { + Tester.checkFailed("shouldn't be able to run"); + } +} -- cgit v1.2.3