diff options
author | acolyer <acolyer> | 2005-11-23 12:52:27 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-11-23 12:52:27 +0000 |
commit | 8b294d9e4f02625c4c3391612242969fb4b6be57 (patch) | |
tree | 15b4adfb80b1d162c1a48191b694acfda70eae19 /tests/bugs150 | |
parent | 504e4300204475cef1254de5d1308863c43b26e7 (diff) | |
download | aspectj-8b294d9e4f02625c4c3391612242969fb4b6be57.tar.gz aspectj-8b294d9e4f02625c4c3391612242969fb4b6be57.zip |
tests and fix for pr103157
Diffstat (limited to 'tests/bugs150')
-rw-r--r-- | tests/bugs150/Pr103157.aj | 66 | ||||
-rw-r--r-- | tests/bugs150/Pr113368.aj | 56 |
2 files changed, 102 insertions, 20 deletions
diff --git a/tests/bugs150/Pr103157.aj b/tests/bugs150/Pr103157.aj new file mode 100644 index 000000000..f9d41cf4b --- /dev/null +++ b/tests/bugs150/Pr103157.aj @@ -0,0 +1,66 @@ +public aspect Pr103157 { + + // verify after returning behaviour with join points that have no "return" value + + // these are: + // ConstructorExecution + // FieldSet + // StaticInitialization + // Initialization + // PreInitialization + // ExceptionHandler -- but handler can't have after returning advice anyway + // arguably all adviceexecution join points except for around, but allow this for now + + after() returning(Object obj) : execution(C.new(..)) { + System.out.println("returning obj on cons exe " + obj); + } + + after() returning : execution(C.new(..)) { + System.out.println("returning from cons exe"); + } + + after() returning(Object obj) : set(* C.*) { + System.out.println("returning obj on set " + obj); + } + + after() returning : set(* C.*) { + System.out.println("returning from set"); + } + + after() returning(Object obj) : staticinitialization(C) { + System.out.println("returning obj on staticinit " + obj); + } + + after() returning : staticinitialization(C) { + System.out.println("returning from staticinit"); + } + + after() returning(Object obj) : initialization(C.new(..)) { + System.out.println("returning obj on init " + obj); + } + + after() returning : initialization(C.new(..)) { + System.out.println("returning from init"); + } + + after() returning(Object obj) : preinitialization(C.new(..)) { + System.out.println("returning obj on preinit " + obj); + } + + after() returning : preinitialization(C.new(..)) { + System.out.println("returning from preinit"); + } + + public static void main(String[] args) { + new C(); + } + +} + +class C { + + String s; + + public C() { this.s = "xxx"; } + +}
\ No newline at end of file diff --git a/tests/bugs150/Pr113368.aj b/tests/bugs150/Pr113368.aj index b9d067df6..7f70c7a6d 100644 --- a/tests/bugs150/Pr113368.aj +++ b/tests/bugs150/Pr113368.aj @@ -1,36 +1,52 @@ + public aspect Pr113368 { - - private pointcut managedBeanConstruction(ManagedBean bean) : - execution(ManagedBean+.new(..)) && this(bean); + + public static void main(String[] args) { + try { + aspectOf().hook(); + } catch (ExceptionInInitializerError ex) { + Throwable cause = ex.getCause(); + if (! (cause instanceof org.aspectj.lang.NoAspectBoundException)) { + throw new RuntimeException("Unexpected exception: " + cause); + } + } + } + + void hook() {} + private pointcut managedBeanConstruction(ManagedBean bean) : + execution(ManagedBean+.new(..)) && this(bean); + //NPE's on the if pointcut below private pointcut topLevelManagedBeanConstruction(ManagedBean bean) : managedBeanConstruction(bean) && if(thisJoinPointStaticPart.getSignature().getDeclaringType() == bean.getClass()); after(ManagedBean bean) returning: topLevelManagedBeanConstruction(bean) { - System.out.println("I just constructed " + bean); + System.out.println("I just constructed " + bean); } - public static void main(String[] args) { - new ManagedBean("super-bean"); - new ManagedSubBean(); +} + +abstract aspect ManagedBean { +} + + +aspect ManagedSubBean extends ManagedBean { + + before() : execution(* hook()) { } } -class ManagedBean { - - public ManagedBean(String s) { - System.out.println(s); - } +aspect AutoStart { + before() : staticinitialization(ManagedBean) { + ManagedSubBean.aspectOf(); + } } - -class ManagedSubBean extends ManagedBean { - - public ManagedSubBean() { - super("sub-bean"); - } - -}
\ No newline at end of file +aspect Tracer { + before() : !within(Tracer) { + System.out.println(thisJoinPoint); +} +} |