-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Among multiple aspects only last one is being applied. #85
Comments
In AspectJ, a joinpoint can be advised by multiple advice. So if you are experiencing divergent behaviour, I would definitely like to see a reproducer, ideally an MCVE. Just publish it on GitHub and link to it from here, then I can take a look. |
I forgot to mention that for now, I think you probably rather have a configuration issue in your weaving plugin than in AspectJ, but I cannot say for sure without an example project. I also would not be surprised if, while creating the MCVE, you find out what is wrong, because this is a frequent side effect of condensing problems into MCVEs. Therefore, both of us have a chance to learn and understand something here. |
Thank you @kriegaex. I have already created an MCVE but fortunately, or not, I was not able to reproduce the issue. I have also already learned that one of my aspects that is written in Java was not compiled using |
An aspect compiled with javac could work when used in a LTW scenario or in a post-compile binary weaving step, if picked up by ajc. Changing the setup of post-compile weaving - things like inpath, aspect path - can influence the behaviour. But as I almost expected, you learned something when creating the MCVE, because it forced you to isolate the problem and inspect your settings. I am happy that you seem to be able to help yourself. 🙂 |
This is also interesting and mysterious to me because in MCVE I forgot to compile java aspects with
where |
No, I didn't say that. Please let us not talk about your textual description of the MCVE, as we are only wasting our time, you explaining and I speculating. I cannot debug prose, I need to see your project. With Maven, I could help you quickly, because I use it all the time for my AspectJ projects. I never use Gradle. Probably I could help there, too, but I would need to reproduce the problem first. In general, if you do not want to rely on unfinished aspects (compiled with javac only) to be finished during weaving, you should compile your aspect modules with ajc, properly finishing them. This is optional, you can also finish the aspects during weaving, but it makes things easier. I think that an aspect library should contain finished aspects and not rely on the user to take that step on behalf of the library provider. Then, you also need ajc for every application module you wish to weave your aspects into, putting the aspect libraries on the aspect path this time. Having said that, I am not going to answer any more questions without an MCVE. Please understand. Thank you. |
Fair enough @kriegaex. I would appreciate it if you could have a look at https://github.com/ksiczek/org.aspectj_85 and tell me what you think about it, especially why the |
The MCVE helps, thank you. Because you did not follow my advice to compile the aspect modules with ajc, it is not enough to put them on the The minimal change to successfully run your application is to change aspect 'pl.example.aspects:aspect1:1.0.0-SNAPSHOT'
aspect 'pl.example.aspects:aspect2:1.0.0-SNAPSHOT' to inpath 'pl.example.aspects:aspect1:1.0.0-SNAPSHOT'
inpath 'pl.example.aspects:aspect2:1.0.0-SNAPSHOT' Alternatively, use https://docs.freefair.io/gradle-plugins/5.0.1/reference/#_io_freefair_aspectj in your two aspect modules and leave the aspect on the aspect path. That would be the canonical solution. Please also read more about the AspectJ compiler options in the AspectJ manual. @aclement, please close this issue, because it is not really an AspectJ problem but simply a Gradle plugin configuration issue. @ksiczek, in the future, please ask questions like these on StackOverflow, adding an |
Thank you @kriegaex, I learned enough to analyze the issue further on my own. I will keep in mind the point regarding SO. |
Hello guys,
I have a quite large code base with multiple projects being built by Gradle and
io.freefair.aspectj.post-compile-weaving
plugin together with aspectj 1.9.7. We organized our aspects as separate modules or libraries with the intention to include what you need. One use case is to have@MonitoredMethod
marker on methods to add some monitoring, another one@Cachable
to add caching etc. Quite recently I have added another aspect that aimed to collect invocations of public methods and I noticed that even though ajc saysonly the last aspect is being applied. In the above case was the
PerformanceMonitorSupport
connected to@MonitoredMethod
. I decompiled the code and it wasIs AspectJ designed to work that way? Can it be an issue with Gradle, or its plugin? If you feel it is a bug I could try to isolate it but I would like to have a short discussion first :)
The text was updated successfully, but these errors were encountered: