AspectJ Load time weaver doesn't detect all classes

前端 未结 3 1377
梦谈多话
梦谈多话 2021-02-07 16:07

I am using Spring\'s declarative transactions (the @Transactional annotation) in \"aspectj\" mode. It works in most cases exactly like it should, but for one it doesn\'t. We can

3条回答
  •  星月不相逢
    2021-02-07 16:43

    If your class is not mentioned in the -verbose/-debug output, that suggests to me it is not being loaded by the loader you think it is. Can you be 100% sure that 'Lang' isn't on the classpath of a classloader higher in the hierarchy? Which classloader is loading Lang at the point in time when you trigger your breakpoint?

    Also, you don't mention AspectJ version - if you are on 1.6.7 that had issues with ltw for anything but a trivial aop.xml. You should be on 1.6.8 or 1.6.9.

    How does ltw actually work?

    Put simply, an AspectJ weaver is created for each classloader that may want to weave code. AspectJ is asked if it wants to modify the bytes for a class before it is defined to the VM. AspectJ looks at any aop.xml files it can 'see' (as resources) through the classloader in question and uses them to configure itself. Once configured it weaves the aspects as specified, taking into account all include/exclude clauses.

    Andy Clement
    AspectJ Project Lead

提交回复
热议问题