From 522911ec81aeb3ec5b600939d3a2ee6e6297fd0c Mon Sep 17 00:00:00 2001 From: acolyer Date: Sat, 19 Nov 2005 17:08:48 +0000 Subject: tests and fix for pr116229 and pr116755. Also adds support and tests for parseTypePattern in PointcutParser. --- .../ataspectj/annotationGen/RuntimePointcuts.java | 1 + tests/java5/reflection/PointcutLibrary.aj | 14 ++++++++++++++ .../reflection/ReflectOnAjcCompiledPointcuts.java | 22 ++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 tests/java5/reflection/PointcutLibrary.aj create mode 100644 tests/java5/reflection/ReflectOnAjcCompiledPointcuts.java (limited to 'tests/java5') diff --git a/tests/java5/ataspectj/annotationGen/RuntimePointcuts.java b/tests/java5/ataspectj/annotationGen/RuntimePointcuts.java index 8f9e530d5..171239cd5 100644 --- a/tests/java5/ataspectj/annotationGen/RuntimePointcuts.java +++ b/tests/java5/ataspectj/annotationGen/RuntimePointcuts.java @@ -6,6 +6,7 @@ public class RuntimePointcuts { public static void main(String[] args) throws Exception { PointcutParser parser = new PointcutParser(); + parser.setClassLoader(RuntimePointcuts.class.getClassLoader()); PointcutExpression pc1 = parser.parsePointcutExpression("PCLib.anyMethodExecution()"); PointcutParameter param = parser.createPointcutParameter("s",String.class); PointcutExpression pc2 = parser.parsePointcutExpression("PCLib.joinPointWithStringArg(s)",RuntimePointcuts.class,new PointcutParameter[] {param}); diff --git a/tests/java5/reflection/PointcutLibrary.aj b/tests/java5/reflection/PointcutLibrary.aj new file mode 100644 index 000000000..f3e59e21c --- /dev/null +++ b/tests/java5/reflection/PointcutLibrary.aj @@ -0,0 +1,14 @@ +// random collection of pointcuts to check that +// reflective world and PointcutParser can interpret +// them correctly. + +public aspect PointcutLibrary { + + public pointcut propertyAccess() : get(* *); + public pointcut propertyUpdate() : set(* *); + public pointcut methodExecution() : execution(* *(..)); + public pointcut propertyGet() : execution(!void get*(..)); + public pointcut propertySet(Object newValue) + : execution(void set*(..)) && args(newValue); + +} \ No newline at end of file diff --git a/tests/java5/reflection/ReflectOnAjcCompiledPointcuts.java b/tests/java5/reflection/ReflectOnAjcCompiledPointcuts.java new file mode 100644 index 000000000..9dc9927be --- /dev/null +++ b/tests/java5/reflection/ReflectOnAjcCompiledPointcuts.java @@ -0,0 +1,22 @@ +import org.aspectj.weaver.tools.*; + +public class ReflectOnAjcCompiledPointcuts { + + public static void main(String[] args) { + PointcutParser p = new PointcutParser(); + PointcutExpression pe = null; + pe = p.parsePointcutExpression("PointcutLibrary.propertyAccess()"); + pe = p.parsePointcutExpression("PointcutLibrary.propertyUpdate()"); + pe = p.parsePointcutExpression("PointcutLibrary.methodExecution()"); + pe = p.parsePointcutExpression("PointcutLibrary.propertyGet()"); + pe = p.parsePointcutExpression("PointcutLibrary.propertySet(Object)"); + + PointcutParameter pp = p.createPointcutParameter("foo",String.class); + p.parsePointcutExpression("execution(* *(..)) && PointcutLibrary.propertySet(foo)", + Object.class, + new PointcutParameter[] {pp}); + + } + + +} \ No newline at end of file -- cgit v1.2.3