[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [aspectj-users] execution(method) and execution(constructor)
- From: "Eric Bodden" <eric.bodden@xxxxxxxxxxxxxx>
- Date: Sun, 18 Jun 2006 23:40:31 -0400
- Delivered-to: firstname.lastname@example.org
- Thread-index: AcaTOB4yHEjQKhtrRW+yeOTZ2OxbKgAGXefA
- Thread-topic: [aspectj-users] execution(method) and execution(constructor)
> I understand that when "super.bar();" is not present, the pointcut
> matches because SubFoo is also a Foo, so the execution of the
> method SubFoo.bar() should be also considered the execution of
This is correct.
> But why after adding a super call, the pointcut matches twice?
Well, because you enter the execution of a method "bar" of a type Foo
twice: Once after the outermost call and once when calling the
super-implementation. In fact, the code in the advice body is inserted
into both methods, the one in Foo and the one in SubFoo.
> And why this is different for constructors?
Because of their inlining semantics. A constructor is not invoked via
invokevirtual but via invokespecial (such as private methods). This
means, that it is only looked up in the class you specify. When you call
super(), this causes the body of the super constructor to be copied into
the call site, this and nothing else.
Sable Research Group, McGill University