Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] * in type patterns

Hi -

> In p3, I use a wildcard in the type pattern, so why
> doesn't it select from
> all available packages?

I answered that already.  Your pointcut specified a type
in the default package, e.g., *Anything.  To specify 
a type in any package, use *..*Anything.

> "type patterns
> in a pointcut that
> do not use wildcards are resolved against the set of
> types visible within
> the source file in which the pointcut is declared," 

You'll have to ask the Eclipse AspectJ authors what they
meant by that.  I suspect they only meant that if there
is no wildcard, you have to import the type or AspectJ
will assume an unqualified name doesn't match.  We have
an XLint warning for that situation in case it was a 
mistake.  I don't recall if the warning was there when
the book was written.

Wes

On Sun, 2 Apr 2006 18:13:45 -0700
 "Jon S. Baekken" <jbaekken@xxxxxxxxxxxx> wrote:
> Yes, you're right that it's embedded. But I'm still
> confused about what the
> eclipse AspectJ book writes on this, that "type patterns
> in a pointcut that
> do not use wildcards are resolved against the set of
> types visible within
> the source file in which the pointcut is declared," and
> that "type patterns
> that don't explicitly refer to types but use wildcards
> will be matched
> against the complete set of types visible to the
> compiler." (p. 159)
> 
> In p3, I use a wildcard in the type pattern, so why
> doesn't it select from
> all available packages? Is the type resolving a different
> ssue?
> 
> Jon
> 
> -----Original Message-----
> From: aspectj-users-bounces@xxxxxxxxxxx
> [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of
> Wes Isberg
> Sent: Friday, March 31, 2006 2:58 PM
> To: aspectj-users@xxxxxxxxxxx
> Subject: Re: [aspectj-users] * in type patterns
> 
> 
> > However, when used like this:
> > 
> > Pointcut p3() : call(public int *SomeClass.*(..));
> > 
> > what is the meaning of * ? It is not embedded within a
> sequence of 
> > characters, and neither is it used "by itself." The
> meaning also seems
> 
> It is embedded, is it not?  Does it not behave that way?
> 
> > 2. Why aren't SomeClass in all packages matched by p3?
> 
> The type is fully-qualified in this case.  To match all
> packages, 
> specify *.. as the package prefix:
> 
>   call(public int *..*SomeClass.*(..));
> 
> The case of * alone is special in picking out any type,
> regardless of
> package.
> 
> Wes
> 
> > ------------Original Message------------
> > From: "Jon S. Baekken" <jbaekken@xxxxxxxxxxxx>
> > To: aspectj-users@xxxxxxxxxxx
> > Date: Fri, Mar-31-2006 2:33 PM
> > Subject: [aspectj-users] * in type patterns
> >
> > Everybody,
> > 
> > I'm a little confused about the meaning of the *
> wildcard used in type 
> > patterns. From what I've read, * stands for zero or
> more occurrences 
> > of any character when used by itself. So,
> > 
> > pointcut p1() : call(public int *.*(..));
> > 
> > would match a call to any public method returning an in
> in any class 
> > in
> > any
> > package (visible to the compiler).
> > 
> > When embedded within a sequence of characters, * stands
> for zero or
> > more
> > occurrences of character except the package separator
> (.), so
> > 
> > pointcut p2() : call(public int
> somepackage.*.SomeClass.*(..));
> > 
> > would match any public method returning an int declared
> in the class 
> > SomeClass in any direct subpackage of somepackage
> (right?)
> > 
> > However, when used like this:
> > 
> > Pointcut p3() : call(public int *SomeClass.*(..));
> > 
> > what is the meaning of * ? It is not embedded within a
> sequence of 
> > characters, and neither is it used "by itself." The
> meaning also seems 
> > to be neither of those mentioned above. It appears that
> it matches 
> > calls to methods declared in any class whose name ends
> in "SomeClass", 
> > but only those
> > classes visible from within p3's source file (which is
> also strange 
> > since I
> > thought all types visible to the compiler were
> considered when using
> > wildcards?).
> > 
> > So to summarize my questions,
> > 
> > 1. What exactly does the * stand for in p3?
> > 2. Why aren't SomeClass in all packages matched by p3?
> > 
> > Thanks,
> > Jon
> > 
> > http://www.eecs.wsu.edu/~jbaekken/
> > 
> > 
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx 
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > 
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> 



Back to the top