1

I am facing the same issue as:

AspectJ load time weaving not working on Spring beans

The solution of returning 'Object' is working, but I don't know the reason.

I have gone through:

http://docs.spring.io/spring/docs/3.0.0.M3/reference/html/ch08s08.html#aop-aj-ltw

but still no clue.

Community
  • 1
  • 1
Azazle
  • 37
  • 1
  • 9
  • Please post some actual code/configuration to help you. See http://stackoverflow.com/help/how-to-ask on how to ask questions. – M. Deinum May 03 '14 at 13:31
  • thought that adding same content would not add anything. And don't know how people can respond on older (yours) question – Azazle May 03 '14 at 14:39
  • Possible duplicate of [AspectJ load time weaving not working on Spring beans](http://stackoverflow.com/questions/22342526/aspectj-load-time-weaving-not-working-on-spring-beans) –  Dec 03 '15 at 00:58

1 Answers1

2

As I commented on that other thread.

The load-time weaver, as the name suggest, will only operate on the loading of classes. Now when a class is already loaded it cannot be processed anymore.

When the return type is the concrete class it will result in eagerly loading that class, it will be loaded before the load time weaver is registered and can do it stuff.

When the return type is Object the loading of the class is deferred until the class is actually needed and in general this will be after the load time weaver has been registered so it can do its work.

You can simply verify this behavior by adding -verbose:class as parameters when you run the program (like you would add properties). You then get an extensive list of classes when they get loaded.

M. Deinum
  • 115,695
  • 22
  • 220
  • 224