From 0409bd8da12e4365e857475fda0c8baeb7110e3b Mon Sep 17 00:00:00 2001 From: ehilsdal Date: Wed, 8 Sep 2004 16:28:34 +0000 Subject: [PATCH] Fix for Bug 73073: Inconsistency between starred and nonstarred type patterns in connection with shadowing. Finally documented matching difference between exacttype and patterntype --- docs/progGuideDB/semantics.xml | 61 +++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/docs/progGuideDB/semantics.xml b/docs/progGuideDB/semantics.xml index f405958a4..8beb4b75c 100644 --- a/docs/progGuideDB/semantics.xml +++ b/docs/progGuideDB/semantics.xml @@ -1334,11 +1334,13 @@ aspect A { 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. @@ -1346,32 +1348,40 @@ aspect A { 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, @@ -1379,9 +1389,11 @@ aspect A { 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, @@ -1389,6 +1401,7 @@ aspect A { So the pointcut would pick out the method-execution join point for Sub.m() in this code: + class Super { protected void m() { ... } @@ -1399,6 +1412,7 @@ aspect A { public void m() { ... } } + @@ -1497,7 +1511,7 @@ aspect A { - Type name patterns + Exact type pattern First, all type names are also type patterns. So @@ -1506,6 +1520,44 @@ aspect A { patterns. + + If a type pattern is an exact type—if it doesn't + include a wildcard—then the matching works just + like normal type lookup in Java: + + + Patterns that have the same names as + primitive types (like int) match + those primitive types. + + Patterns that are qualified by package names + (like java.util.HashMap) match types + in other packages. + + + Patterns that are not qualified (like + HashMap) match types that are + resolved by Java's normal scope rules. So, for + example, HashMap might match a + package-level type in the same package or a type that + have been imported with java's + import form. But it would not match + java.util.HashMap unless the aspect + were in java.util or the type had + been imported. + + + + + So exact type patterns match based on usual Java scope + rules. + + + + + + Type name patterns + There is a special type name, *, which is also a type pattern. * picks out all types, including primitive types. So @@ -1562,6 +1614,13 @@ aspect A { declaration of a type whose name begins with "com.xerox.". + + Type patterns with wildcards do not depend on Java's + usual scope rules—they match against all types + available to the weaver, not just those that are + imported into an Aspect's declaring file. + + -- 2.39.5