Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] Multiple AspectJ agents

I'd need to remind myself about the ins and outs of overweaving. You might have hit a bug - this would be easy to check by just attempting overweaving just with regular AspectJ and around advice that requires a closure to be generated. If weaving something twice (overweaving the second time) doesn't work it would be an overweaving bug because it isn't recognizing it needs to use a different number for the closure class suffix. I *suspect* the code that should be using a different suffix just isn't there (for example it exists for the tjp fields here: https://github.com/eclipse/org.aspectj/blob/c2de53913d15eed07e8eb8c56a0d065ad7fb2ebd/weaver/src/main/java/org/aspectj/weaver/bcel/LazyClassGen.java#L1107 ) - I couldn't see an equivalent for closure classes.

However, if overweaving is operating by looking for specifically named attributes in the classfile identifying what previously happened to the class then and you have shaded all the names, it maybe cannot work out that a variant of AspectJ is also affecting the same class because your attributes would have a different name.

You *probably* want overweaving ON otherwise all the code generated to support advice invocation by the first weave will result in joinpoints for the secondary AspectJ to discover. 

My write up of overweaving is here: http://andrewclement.blogspot.com/2010/05/aspectj-overweaving.html (as an alternative to reweaving)

cheers,
Andy



On Wed, 6 Jul 2022 at 07:08, Uri Simchoni <urisimchoni@xxxxxxxxx> wrote:
Hi,

We make a Java agent that uses a shaded version of AspectJ, and doing LTW. We'd like our agent to be able to coexist with other agents which might be using AspectJ as well in LTW mode.

Is that supposed to work in principle? Our testing shows that it works to some extent, but clearly fails when an Around advice is applied by both agents to the same method - in that case there seems to be a naming clash with the generated AjcClosure inner class, which can be resolved if we change the name of that inner class (by modifying the AspectJ source code).

So the thing I'm trying to understand is whether AspectJ is designed for that use case, and I just found a bug (which I might be able to fix), or, am I just opening a can of worms here...

In that respect, what's the role of "overweaving" which seems to be related (it doesn't fix the issue I just reported).

Thanks,
Uri
_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/aspectj-dev

Back to the top