Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] call and execution pointcut problem

Hi Alexander,

The problem is the usage of 'call'. I decided to use 'execution' instead and then use StackTraceElement for from a stacktrace to find the calling class and method.

Then I had missed to use:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<useIncrementalCompilation>false</useIncrementalCompilation>
<source>11</source>
<target>11</target>
</configuration>
</plugin>

in my pom.xml for the module using my my aspect as a library.


So no need for  MCVE.


By the way if you need a tester of new versions of the maven aspectj plugin let me know if I can assist.


br,


//mike

 


Från: aspectj-users <aspectj-users-bounces@xxxxxxxxxxx> för Mikael Petterson <mikaelpetterson@xxxxxxxxxxx>
Skickat: den 10 juni 2022 19:49
Till: aspectj-users@xxxxxxxxxxx <aspectj-users@xxxxxxxxxxx>
Ämne: Re: [aspectj-users] call and execution pointcut problem
 
Hi Alexander,

Thanks for taking the time to reply. 

I did not know 'call' was weaving into caller. Does this mean that my test module also need to be dependent on aspect module directly? 

The basic idea I wanted to do with aspect was  to add it to our test framework. Then track all calls to  deprecated methods in our test framework from different test projects.

The maven module project is to test this idea.

I think I am using defauIt since I  don't specify the phase at all, in pom.xml. Correct?

I am working on a MCVE. Some more work is needed.

Br,

Mike



Från: aspectj-users <aspectj-users-bounces@xxxxxxxxxxx> på uppdrag av Alexander Kriegisch <alexander@xxxxxxxxxxxxxx>
Skickat: fredag 10 juni 2022 20:53
Till: aspectj-users@xxxxxxxxxxx <aspectj-users@xxxxxxxxxxx>
Ämne: Re: [aspectj-users] call and execution pointcut problem

Hi Mikael.

This is not a bug but to be expected. Please note that while
'execution()' is woven into the target method (callee), 'call()' is
woven into the calling method (caller). However, the caller is your
test, and probably you configured AspectJ Maven to use the 'compile'
goal, but not the 'test-compile' goal. Or maybe your plugin
configuration conflicts with Maven Compiler, which can happen if you are
not using the default phase but a custom one, leading to Maven Compiler
to recompile and overwrite code which previously was compiled by AspectJ
Maven already. Without an MCVE [1] this is difficult to say.

[1] https://stackoverflow.com/help/mcve

--
Alexander Kriegisch
https://scrum-master.de


Mikael Petterson:

> I have the following maven modules:
>
> 1.Aspects
>
> 2.Sim
>
> 3.Test
>
> Aspect looks like:
>
> (...)
> @annotation(Deprecated) && (call(public * *(..)) || call(*.new(..)));
> (...)
>
> I have built Aspect and weaved it into Sim module using the
>
> <aspectLibraries>
> <aspectLibrary>
>
> tags.
>
> I add a @Deprecated method in Sim module on a class method.
>
> Then I let one of my tests in Test module call the method annotated
> @Deprecated in Sim module.
>
> When using 'call' in the aspect I don't see the info, println in
> aspect, of my deprecated method in Sim module being called.
>
> However if I change to 'execution' in my aspect then I can see that
> the info of my method in Sim module being called. All other things the
> same.
>
> Problem with this is I cannot see the calling class. There is no info
> for that when using 'execution'.
>
> Is this is a bug? Or am I using it in the wrong way?
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/aspectj-users


Back to the top