Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] LTW and AspectOf() NoSuchMethodError

Hi

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
methods.
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
reproductible scenario.

Alex


On 10/23/05, Yoav Landman <yoavl@xxxxxxxxxxxx> wrote:
>
> I am getting a similar behavior to what is described in
> http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg04775.html.
>
> 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?
>
> Thanks,
>
> Yoav
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
>


Back to the top