From 3dcc2dd68179b687ba785ad3352ba7eabde387c5 Mon Sep 17 00:00:00 2001 From: wisberg Date: Sat, 28 Aug 2004 23:52:44 +0000 Subject: [PATCH] Fix bug 72623; also changed "definition" to "declaration" for Java elements --- docs/progGuideDB/semantics.xml | 93 +++++++++++++++++++++++++++++++--- 1 file changed, 85 insertions(+), 8 deletions(-) diff --git a/docs/progGuideDB/semantics.xml b/docs/progGuideDB/semantics.xml index 19f8cdf9f..f405958a4 100644 --- a/docs/progGuideDB/semantics.xml +++ b/docs/progGuideDB/semantics.xml @@ -1116,7 +1116,7 @@ aspect A { - At a method execution join point, the signature a method signature + At a method execution join point, the signature is a method signature whose qualifying type is the declaring type of the method. @@ -1188,16 +1188,16 @@ aspect A { patterns to determine the join points they describe. A signature pattern is an abstract description of one or more join-point signatures. Signature patterns are intended to match very closely the - same kind of things one would write when defining individual methods + same kind of things one would write when declaring individual members and constructors. - Method definitions in Java include method names, method parameters, + Method declarations in Java include method names, method parameters, return types, modifiers like static or private, and throws clauses, - while constructor definitions omit the return type and replace the + while constructor declarations omit the return type and replace the method name with the class name. The start of a particular method - definition, in class Test, for example, might be + declaration, in class Test, for example, might be @@ -1326,6 +1326,81 @@ aspect A { execution(private C.new() throws ArithmeticException) + + Matching based on the declaring type + + + The signature-matching pointcuts all specify a declaring type, + but the meaning varies slightly for each join point signature, + in line with Java semantics. + + + When matching for pointcuts withincode, + get, and set, the declaring + type is the class that contains the declaration. + + + When matching method-call join points, the + declaring type is the static type used to access the method. + A common mistake is to specify a declaring type for the + call pointcut that is a subtype of the + originally-declaring type. For example, given the class + + + class Service implements Runnable { + public void run() { ... } + } + + + the following pointcut + + + call(void Service.run()) + + + would fail to pick out the join point for the code + + + ((Runnable) new Service()).run(); + + + Specifying the originally-declaring type is correct, but would + pick out any such call (here, calls to the run() + method of any Runnable). + In this situation, consider instead picking out the target type: + + + call(void run()) && target(Service) + + + When matching method-execution join points, + if the execution pointcut method signature specifies a declaring type, + the pointcut will only match methods declared in that type, or methods + that override methods declared in or inherited by that type. + So the pointcut + + + execution(public void Middle.*()) + + + picks out all method executions for public methods returning void + and having no arguments that are either declared in, or inherited by, + Middle, even if those methods are overridden in a subclass of Middle. + So the pointcut would pick out the method-execution join point + for Sub.m() in this code: + + + class Super { + protected void m() { ... } + } + class Middle extends Super { + } + class Sub extends Middle { + public void m() { ... } + } + + + Matching based on the throws clause @@ -1483,8 +1558,8 @@ aspect A { - picks out all join points where the code is in any type - definition of a type whose name begins with "com.xerox.". + picks out all join points where the code is in any + declaration of a type whose name begins with "com.xerox.". @@ -2231,7 +2306,7 @@ ModifiersPattern = - The initializer, if any, of an inter-type field definition runs + The initializer, if any, of an inter-type field declaration runs before the class-local initializers defined in its target class. @@ -3045,3 +3120,5 @@ ModifiersPattern = + + -- 2.39.5