Messages
Introduction
By default only warning and error messages are issued by the compiler whether it is
being used for source code compilation, weaving, binary weaving or load-time weaving. Informational,
debug and weaving messages can also be obtained using compiler options
or System properties. Also as well as being able to soften or ignore
certain error messages the various -Xlint
options can be used to
notify you of conditions that would otherwise be ignored.
It is often difficult to determine, especially when using load-time weaving (LTW),
why advice has not been woven. Here is a quick guide to the messages to
look for. Firstly if you use the -verbose option you
should see the following message when your aspect is registered:
Secondly if you use the -debug option you should
see a message indicating that you class is being woven:
However this does not mean that advice has actually been woven into
your class merely that the class has been passed to the weaver. So thirdly to determine
whether your pointcuts match you can use the -showWeaveInfo
option which will cause a message to be issued each time a piece of advice is woven:
Configuration
The table below lists the options used to control AspectJ messages. The method
of configuration depends on your environment so refer to the relevant
documentation for
ajc,
Ant or
LTW.
Option
Description
-verbose
Show informational messages including AspectJ version
and build date.
-debug
(Load-time weaving only). Show debugging messages such as
which classes are being woven or those that are excluded.
-showWeaveInfo
Show weaving messages.
-Xlint
Control level of lint messages.
The table below lists some useful -Xlint messages.
Message
Default
Description
aspectExcludedByConfiguration
ignore
If an aspect is not being woven, despite being
registered, it could be that it has been excluded
by either an include or exclude
element in the
aspects section of META-INF/aop.xml.
Enable this message to determine whether an aspect has
been excluded.
Examples
You can use META-INF/aop.xml to control which
messages are produced during LTW. The following example will produce
basic informational messages about the lifecyle of the weaver in
addition to any warning or error messages.
]]>
Notice that you are told exactly which META-INF/aop.xml
configurations file(s) are being used. Each message is also preceeded by the
name of the defining class loader associated with weaver. You can use this
information in a large system to distinguish between different applications each
of which will typically have its own class loader.