[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [aspectj-users] LTW and AspectOf() NoSuchMethodError
- From: Alexandre Vasseur <avasseur@xxxxxxxxx>
- Date: Mon, 24 Oct 2005 11:30:16 +0200
- Delivered-to: firstname.lastname@example.org
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=gQzRYw8JZ2iDYCzgFYICYLAh76AffOdyyt37bSCOT3mJ1jEm6++/ue+2jPSX90ZtMFETI4OCRuLTN1c/kDwqapkhkjaD650ZszreoqGo+PXajbUSIUOWs6kdiCHrsJus+w2C38HJFyYJdf6YtXNSlJRbF05xmENZyWbHcTf5kR0=
Perhaps you could post your aspect and the program (client code) snip
that calls aspectOf.
For @AspectJ aspect, assuming you have the source code for it, there
is no aspectOf() method. Hence you need to use the Aspects.aspectOf
helper methods in your client code.
This no matter if you are or not using LTW.
If you have an AJC compiled @AspectJ aspect (thus in binary form) in
your project path, you'll see that the aspectOf method does exist on
the aspect class. AJC added it when compiling the aspect. Hence the
client code can call it directly - but you can also use the helper
If the @AspectJ aspect was compiled with javac, then this method won't
be there, so your only choice is to use the Aspects.aspectof helper.
And from there again with or without LTW does not changes the situation.
For regular code style aspect, the aspectOf method is implicit on the
aspect itself, so you can call it. Then off course both aspect and
client code will have to be compiled with AJC - and then you can use
LTW without change.
One situation can happen: if you have an @Aspect compiled with javac,
and some client code using the Aspects.aspectOf helper. Then use that
with LTW. If the @Aspect class is not exposed to the weaver for some
reason (f.e. you are using a limited form of LTW), the actual aspectOf
method cannot be added to the aspect class, and the helper method that
reflectively invokes this method will thus fail.
I think this is a rare case. The message you refer to unfortunately
did not end up in a bug report. Feel free to open one if you have a
On 10/23/05, Yoav Landman <yoavl@xxxxxxxxxxxx> wrote:
> I am getting a similar behavior to what is described in
> Using M4 and load time weaving, I am receiving a NoSuchMethodError from a
> weaved class calling aspectOf() on my aspect class.
> I am trying to weave an external jar file. Compile time weaving using ajc on
> the same jar works just fine.
> According to the docs, I thought that using LTW weaved classes are supposed
> to call aspectOf() on the Aspects helper class and not on the aspect itself.
> Is this correct?
> aspectj-users mailing list