From 72172aa072aae0896e9cb8e6d8d21231c56625a7 Mon Sep 17 00:00:00 2001 From: acolyer Date: Thu, 18 Nov 2004 09:29:21 +0000 Subject: [PATCH] some small updates in annotations, plus beginnings of varargs section --- docs/adk15ProgGuideDB/adk15notebook.xml | 2 + docs/adk15ProgGuideDB/annotations.xml | 2 +- docs/adk15ProgGuideDB/grammar.xml | 6 + docs/adk15ProgGuideDB/varargs.xml | 184 ++++++++++++++++++++++++ 4 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 docs/adk15ProgGuideDB/grammar.xml diff --git a/docs/adk15ProgGuideDB/adk15notebook.xml b/docs/adk15ProgGuideDB/adk15notebook.xml index 232002dc0..d31f0e974 100644 --- a/docs/adk15ProgGuideDB/adk15notebook.xml +++ b/docs/adk15ProgGuideDB/adk15notebook.xml @@ -14,6 +14,7 @@ ]> +]> @@ -65,5 +66,6 @@ &getthistargetobj; &declaresoft; &reflection; + &grammar; diff --git a/docs/adk15ProgGuideDB/annotations.xml b/docs/adk15ProgGuideDB/annotations.xml index 456094cdc..3737c9f2b 100644 --- a/docs/adk15ProgGuideDB/annotations.xml +++ b/docs/adk15ProgGuideDB/annotations.xml @@ -419,7 +419,7 @@ - + Signature Patterns A FieldPattern is described by the following diff --git a/docs/adk15ProgGuideDB/grammar.xml b/docs/adk15ProgGuideDB/grammar.xml new file mode 100644 index 000000000..0a77b9f8f --- /dev/null +++ b/docs/adk15ProgGuideDB/grammar.xml @@ -0,0 +1,6 @@ + + + A Grammar for the AspectJ 1.5 Language + +> + diff --git a/docs/adk15ProgGuideDB/varargs.xml b/docs/adk15ProgGuideDB/varargs.xml index 81f1f6e49..91a389b52 100644 --- a/docs/adk15ProgGuideDB/varargs.xml +++ b/docs/adk15ProgGuideDB/varargs.xml @@ -2,5 +2,189 @@ Varargs + + Variable-length Argument Lists in Java 5 + + + Java 5 (and hence AspectJ 1.5) allows you to specify methods that take a + variable number of arguments of a specified type. This is achieved using + an ellipsis (...) in the method signature as shown: + + + + + + A method or constructor may take at most one variable length argument, and + this must always be the last declared argument in the signature. + + + + Calling Methods and Constructors with variable-length arguments + + + A varargs method may be called with zero or more arguments + in the variable argument position. For example, given the definition of + foo above, the following calls are all legal: + + + + + A varargs parameter is treated as an array within the + defining member. So in the body of foo we could write for example: + + + + + One consequence of this treatment of a varargs parameter as an array + is that you can also call a varargs method with an array: + + + + + + + + + Using Variable-length arguments in advice and pointcut expressions + + AspectJ 1.5 allows variable-length arguments to be used for methods declared within + aspects, and for inter-type declared methods and constructors, in accordance with the rules + outlined in the previous section. + + + AspectJ 1.5 also allows variable length arguments to be specified in pointcut expressions and + bound as formals in advice. + + + + Matching signatures based on variable length arguments + + + Building on the definition of signature patterns given in the chapter on + annotations (), MethodPattern + and ConstructorPattern are extended to allow a varargs + pattern in the last argument position of a method or constructor signature. + + + + + + Method and constructor patterns are used in the call, + execution, initialization, + preinitialization, and withincode + pointcut designators. Some examples of usage follow: + + + + + + call(* org.xyz.*.*(int, String...)) + + + Matches a call join point for a call to a method defined in the + org.xyz package, taking an int + and a String vararg. + + + + + + execution(* org.xyz.*.*(Integer...)) + + + Matches an execution join point for the execution of a method defined in the + org.xyz package, taking an Integer vararg. + + + + + + initialization(org.xyz.*.new((Foo || Goo)...)) + + + Matches the initialization join point for the construction of an + object in the org.xyz package via a constructor + taking either a variable number of Foo parameters or + a variable number of Goo parameters. (This example + illustrating the use of a type pattern with ...). + + + + + + + A variable argument parameter and an array parameter are treated as distinct + signature elements, so given the method definitions: + + + + + + The pointcut execution(* *.*(String...)) matches the execution join point + for foo, but not bar. The pointcut + execution(* *.*(String[])) matches the execution join point + for bar but not foo. + + + + The args pointcut designator can also now take a varargs + pattern as the last argument in the list. For example, you can write: + + + + + + + + Exposing variable-length arguments as context in pointcuts and advice + + + -- 2.39.5