[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] within{static}initialization - was Re: [aspectj-users] withincode(clinit)
|
On Wed, 22 Dec 2004, Wes Isberg wrote:
> <snip>
> > I am trying to figure out if there is a special syntax for using a
> > withincode(<clinit>) other than:
> >
> > within(TypeX) && !withincode(* TypeX.*(..)) &&
> > !withincode(TypeX.new(..))
>
> This says, "anything in TypeX except stuff in methods and
> constructors," but would also pick out instance field
> initializers, adviceexecution, pre-initialization, etc.
pre-initialization is withincode(TypeX.new(..)), isn't it? Likewise
instance field initialization, according to ajc 1.2.1, although perhaps in
theory it shouldn't be if the initializer is outside the constructor in
source. [Since bytecode doesn't distinguish, this isn't actually possible]
> You could continue along this vein by excluding all these
> other join points. (minor point: code not upwards-compatible
> with enhanced join point model.)
Is it possible to exclude adviceexecution? Of course, that's only relevant
for aspects, so if TypeX is a normal class this isn't a problem.
> I'd agree w/Ramnivas that there is a bucket here that might
> be useful to scope the code that's involved in class or object
> initialization. Ironically, the code is scattered in source but a
> Java compiler gathers all the initializers, etc. into one class or
> instance initialization chunk of code that can be staticly scoped.
>
> So perhaps two new "lexical" pointcuts:
>
> - withinstaticinitialization(TypePattern)
> Restricts the scope of the join points picked out to those join
> points associated with static (class) initialization
> within types matched by {TypePattern}.
That makes a lot of sense and would be easy to implement. I'd also propose
withinadvice(TypePattern), for consistency as much as anything.
> - withininitialization(TypePattern)
> Restricts the scope of the join points picked out to those join
> points associated with object (instance) initialization
> within types matched by {TypePattern}, including object
> initialization, preinitialization, and constructors.
I don't understand this one. How does it differ from
withincode(TypePattern.new(..)) ?
> Neither form will exclude methods that might be called
> during initialization or superclass initialization code.
> [need to comment on aspect-defined initialization code]
I don't understand what you mean here.
> /** instance field-set in initialization but outside constructors */
> set(!static * T.*) && withininitialization(T) && !within(T.new(..))
I'm not sure where this would ever match.
Cheers,
Ganesh