AOP: Spring aop vs AspectJ

If you are using Spring framework, it is easy to implement Spring AOP. Ease of implementation comes with some limitations like you can only use aspects with spring managed beans and only methods can be used as pointcuts. Another limitation is that you cannot apply aspects for method calling another in same class. Whereas AspectJ does not have these limitations.

The reason behind this is the way Spring and AspectJ implements AOP. Spring uses runtime weaving whereas AspectJ uses load time weaving. Spring implements proxy based approach. Where it adds a proxy wrapper aound your class, and every call to the class method, has to go through the proxy wrapper.

AspectJ implement load time waving by actually manipulating the bytecode using its compiler while class is loaded to JVM.