diff options
Diffstat (limited to 'tests/java5/reflection/AdviceWithArgs.aj')
-rw-r--r-- | tests/java5/reflection/AdviceWithArgs.aj | 27 |
1 files changed, 27 insertions, 0 deletions
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 |