diff options
author | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
commit | 144143c2970a1e874d74cdbd0f8c622d4282a3c3 (patch) | |
tree | b12383d3d9e76c7e1f25f7fbec83051ef17f81fb /tests/new/IfPCDExprVisibility.java | |
parent | fafae443719b26159ab2d7dac1c9b46b5e00b671 (diff) | |
download | aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip |
initial version
Diffstat (limited to 'tests/new/IfPCDExprVisibility.java')
-rw-r--r-- | tests/new/IfPCDExprVisibility.java | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/tests/new/IfPCDExprVisibility.java b/tests/new/IfPCDExprVisibility.java new file mode 100644 index 000000000..c94dcd432 --- /dev/null +++ b/tests/new/IfPCDExprVisibility.java @@ -0,0 +1,109 @@ + +aspect AspectForIfPCDExprVisibility { + // See IfPCDExprJoinPoint* for join-point error cases + + pointcut stringLArgs(String[] args) + : args (args); + pointcut targetTarget(IfPCDExprVisibility target) + : target(target); + pointcut thisItem(IfPCDExprVisibility thisItem) + : this(thisItem); + + pointcut callDo() + : call(void IfPCDExprVisibility()); + + pointcut callMain(String[] args) + : args(args) && call(static void *..main(String[])) ; + + // ok: anonymous pointcut + /** + *@testTarget ifpcd.compile.visibility.tjp + *@testTarget ifpcd.compile.visibility.tjpsp + */ + before () + : if (thisJoinPoint != null) + && if (thisJoinPointStaticPart != null) + && call(void IfPCDExprJoinPointVisibleCE.main(..)) { + System.err.println("before main + " + thisJoinPoint); + } + // ok: anonymous pointcut, name composition, arg state + /** + */ + before (String[] args) + : if (thisJoinPointStaticPart != null) + && if (null != args) + && callMain (args){ + String m = "before main" + + " join point: " + thisJoinPoint + + " args: " + args ; + System.err.println(m); + if (null == thisJoinPointStaticPart) + throw new Error("impossible null thisJoinPointStaticPart"); + // actually, it is possible to directly invoke main with null args... + if (null == args) throw new Error("null args"); + } + /** + *@testTarget ifpcd.compile.visibility.args.named + *@testTarget ifpcd.compile.visibility.this.named + *@testTarget ifpcd.compile.visibility.target.named + */ + Object around (String[] _args + , IfPCDExprVisibility _target + , IfPCDExprVisibility _thisItem) + : targetTarget(_target) + && thisItem(_thisItem) + && call(* IfPCDExprVisibility.exec(..)) + && args(_args) + && if(null != _args) + && if(null != _target) + && if(null != _thisItem) + { + String m = "around main - start " + + " join point: " + thisJoinPoint + + " static join point: " + thisJoinPointStaticPart + + " this: " + _thisItem + + " target: " + _target + + " args: " + _args + ; + System.err.println(m); + // note: no compile error unless around is actually woven in + proceed(_args, _target, _thisItem); + m = "around main - end " + + " join point: " + thisJoinPoint + + " static join point: " + thisJoinPointStaticPart + + " this: " + _thisItem + + " target: " + _target + + " args: " + _args + ; + System.err.println(m); + return null; + } +} + +/** + * @author wes + */ +public class IfPCDExprVisibility { + void exec(String[] args) { + if (null == args) { + System.err.println("exec running with null args"); + } else { + System.err.println("exec running with args: " + args); + System.err.println("exec calling itself with null args: " + args); + // only this call is captured by around - from/to this object + exec(null); + } + } + public static void main(String[] args) { + if (null != args) { + System.err.println("main calling itself with null args"); + new IfPCDExprVisibility().main(null); // self-call + System.err.println("main done calling itself with null args"); + + new IfPCDExprVisibility().exec(args); + } else { + System.err.println("ok - main running with null args"); + } + } +} + |