Matthew, Wes,
Thank you for the most detailed response. The
issue is clear for me now.
I am curious, should the AspectJ users
expect some changes in this regard in the AspectJ 1.5.1 release?
Also, I’d be happy to see if AspectJ
project adds some very basic design/architecture docs that would explain the weaving
process and the aspects deployment process at some high level. It would then
help the AspectJ users like myself to understand many things
that aren’t documented in the language/tools guides.
Thanks,
Seva
From:
aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Matthew Webster
Sent: Thursday, March 23, 2006
1:56 PM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] LTW
and build-time weaving used together resultin an unexpected
org.aspectj.bridge.AbortException
Importance: High
Seva,
You
have encountered a restriction in the current implementation of AspectJ that is
described in https://bugs.eclipse.org/bugs/show_bug.cgi?id=104218. Basically
AspectJ cannot weave code that has already been woven. This causes a problem
for LTW when an application has already used aspects. The solution is to use
the reweavable mode of the compiler which stores an unwoven version of the
class when it is woven. When a reweavable class it woven again, either
statically or at load-time, the compiler retrieves the unwoven
"vanilla" version of the class then weaves it again with the original
aspects plus any new ones.
Therefore
if your application uses aspects that are woven at build-time they must all be
declared in an aop.xml, perhaps generated using the -outxml compiler option,
that is available at runtime. If you don't then the vanilla class will be used
and you application will not behave correctly. This is why the compiler issues
an error.
Matthew
Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley
Park, Winchester, SO21 2JN,
England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/
Please respond to
aspectj-users@xxxxxxxxxxx
Sent by: aspectj-users-bounces@xxxxxxxxxxx
To:
<aspectj-users@xxxxxxxxxxx>
cc:
Subject: [aspectj-users]
LTW and build-time weaving used together result in an
unexpected org.aspectj.bridge.AbortException
Hi,
In our company we are considering the possibility
to use LTW and build-time weaving together with AspectJ 1.5. What I
mean is that we would like to allow LTW only for the "global" aspects
(i.e. those that crosscut all our codebase) only in our system level jars (that
are audited more carefully and owned by a more senior developers). At the same
time we do not want to let the rest of our projects to have aspects that are
weaved at load-time. However, we still want them to be able to use AspectJ at
compile/build time should they have a need. The reason is that we just do not
want some negligent, too broad pointcut definitions coming from some regular
jar file with the LTW approach to "accidentally" harm/break other
code in the system. This sounds like a safer approach for us.
Anyway, closer to my question.
>From what I know so far with the LTW one
has to declare all the aspects in the aop.xml files even if the aspect was
already weaved into the desired classes. The AspectJ will issue an ERROR
logging with the stack trace if some aspect is not declared. In spite of
that ERROR reporting, everything seems to work okay for us.
So, I'd like to understand why the described
situation considered an error by AspectJ. I would expect just a warning message
from AspectJ just saying that an aspect is found that is not declared (i.e.
there is no LTW for this aspect).
Below is the relevent output from AspectJ with an
error message and a stack trace:
info processing reweavable type
com.metatv.user.hibernate.HibernateUserFactory:
com\metatv\user\hibernate\HibernateUserFactory.java
error aspect
'com.metatv.user.hibernate.TransactionManager' woven into
'com.metatv.user.hibernate.HibernateUserFactory' must be declared in an aop.xml
file.
Message: error aspect
'com.metatv.user.hibernate.TransactionManager' woven into
'com.metatv.user.hibernate.HibernateUserFactory' must be declared in an aop.xml
file.
org.aspectj.bridge.AbortException: aspect
'com.metatv.user.hibernate.TransactionManager' woven into
'com.metatv.user.hibernate.HibernateUserFactory' must be declared in an aop.xml
file.
at
org.aspectj.weaver.tools.WeavingAdaptor$WeavingAdaptorMessageHandler.handleMessage(WeavingAdaptor.java:413)
at
org.aspectj.weaver.World.showMessage(World.java:550)
at
org.aspectj.weaver.bcel.BcelWeaver.processReweavableStateIfPresent(BcelWeaver.java:1244)
at
org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1024)
at
org.aspectj.weaver.tools.WeavingAdaptor.getWovenBytes(WeavingAdaptor.java:277)
at
org.aspectj.weaver.tools.WeavingAdaptor.weaveClass(WeavingAdaptor.java:210)
at
org.aspectj.weaver.loadtime.Aj.preProcess(Aj.java:65)
at
org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:52)
at
sun.instrument.TransformerManager.transform(TransformerManager.java:122)
Thanks,
Seva
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users