From bf97cc20ba2315b0e72b239f66c20bc474984789 Mon Sep 17 00:00:00 2001 From: acolyer Date: Tue, 29 Nov 2005 20:45:38 +0000 Subject: tests for parameter name generation in advice annotations --- tests/java5/reflection/AdviceWithArgs.aj | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/java5/reflection/AdviceWithArgs.aj (limited to 'tests/java5/reflection/AdviceWithArgs.aj') diff --git a/tests/java5/reflection/AdviceWithArgs.aj b/tests/java5/reflection/AdviceWithArgs.aj new file mode 100644 index 000000000..533b38012 --- /dev/null +++ b/tests/java5/reflection/AdviceWithArgs.aj @@ -0,0 +1,27 @@ +import org.aspectj.lang.annotation.*; +import java.lang.reflect.*; + +public aspect AdviceWithArgs { + + @SuppressAjWarnings + before(String s) : execution(* *(..)) && args(s) { + System.out.println(s); + } + + public static void main(String[] args) throws Exception { + Method[] meths = AdviceWithArgs.class.getMethods(); + boolean found = false; + for (Method meth : meths) { + if (meth.isAnnotationPresent(Before.class)) { + found = true; + Before bAnn = meth.getAnnotation(Before.class); + String argNames = bAnn.argNames(); + if (!argNames.equals("s")) { + throw new RuntimeException("Expected 's' but got '" + argNames + "'"); + } + break; + } + } + if (!found) throw new RuntimeException("Did not find expected advice annotation"); + } +} \ No newline at end of file -- cgit v1.2.3