diff options
author | jhugunin <jhugunin> | 2003-01-07 20:49:38 +0000 |
---|---|---|
committer | jhugunin <jhugunin> | 2003-01-07 20:49:38 +0000 |
commit | 1e721079e0cec90516b4629272c178ff377ec75b (patch) | |
tree | 4461efd429afe8ea0e319a5d028010d789b787c9 /tests/bugs/EnsureOverriding.java | |
parent | 2b680c46c54d8d5c3069b29686282d7fff720b1c (diff) | |
download | aspectj-1e721079e0cec90516b4629272c178ff377ec75b.tar.gz aspectj-1e721079e0cec90516b4629272c178ff377ec75b.zip |
tests from bugzilla
Diffstat (limited to 'tests/bugs/EnsureOverriding.java')
-rw-r--r-- | tests/bugs/EnsureOverriding.java | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/bugs/EnsureOverriding.java b/tests/bugs/EnsureOverriding.java new file mode 100644 index 000000000..6c41e2861 --- /dev/null +++ b/tests/bugs/EnsureOverriding.java @@ -0,0 +1,45 @@ +// from Bug#: 28703 + +class Base { + /** extend when overriding - must call Base.lockResource() */ + public void lockResource(boolean dummy) { /* ... */ } +} + +class Derived extends Base { + boolean isLocked; + + public void lockResource(boolean callSuper) { + if (callSuper) super.lockResource(true); + isLocked = true; + } +} + +public aspect EnsureOverriding pertarget(mustExtend()) { + boolean calledSuper = false; + pointcut mustExtend() : + execution(void Base+.lockResource(..)) && !within(Base); + + after () returning: mustExtend() { + assert(calledSuper); + if (!calledSuper) { throw new RuntimeException("need super call"); } + } + + after(Base a, Base b) returning: + cflow(mustExtend() && target(a)) && execution(void Base.lockResource(..)) && target(b) + { + if (a == b) { + //System.err.println("made call"); + calledSuper = true; + } + } + + public static void main(String args[]) { + (new Derived()).lockResource(true); + try { + (new Derived()).lockResource(false); + throw new Error("shouldn't get here"); + } catch (RuntimeException re) { + if (!re.getMessage().equals("need super call")) throw re; + } + } +} |