You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

messages.xml 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <chapter id="messages" xreflabel="Messages">
  2. <title>Messages</title>
  3. <sect1 id="messages-introduction">
  4. <title>Introduction</title>
  5. <para>
  6. Messages point out potential problems in the input program; some
  7. are clearly problems (errors), but many more may depend on what
  8. the programmer intends. To keep the noise down the latter are treated
  9. as warnings which can be ignored by the programmer or information
  10. which are hidden. However, when investigating
  11. unexpected behavior it's helpful to show them. This section describes how
  12. to configure messages, presents some problem scenarios when
  13. compiling or doing load-time weaving, and summarizes some of the
  14. more relevant messages.
  15. </para>
  16. <sect2 id="messages-introduction-config"
  17. xreflabel="messages-configuration">
  18. <title>Configuring Messages</title>
  19. <para>
  20. The compiler offers <literal>-verbose</literal>,
  21. <literal>-warning</literal>, and <literal>-XLint</literal> options
  22. when invoked using the command-line, Ant, or embedded in an IDE.
  23. All options are listed in the AspectJ Development Environment Guide
  24. sections for
  25. <ulink url="../devguide/ajc-ref.html">Ajc</ulink> and
  26. <ulink url="../devguide/antTasks-iajc.html">Ant Tasks</ulink>.
  27. The <ulink url="../devguide/ltw.html">Load-time Weaving</ulink>
  28. section describes how to use XML configuration files and
  29. system properties to pass options to the weaver. (You can also
  30. pass options to the weaver using system properties in build-
  31. time weaving.)
  32. The <literal>-verbose</literal> option has the effect of including
  33. messages level "info", which are normally ignored.
  34. Both <literal>warning</literal> and <literal>XLint</literal>
  35. enable you to identify specific messages to emit, but warning
  36. messages tend to be the same provided by the underlying Eclipse
  37. JDT (Java) compiler, while XLint messages are emitted by the
  38. AspectJ compiler or weaver. Obviously, during load-time weaving
  39. only weaver messages will be emitted. Similarly, if aspects
  40. are compiled but not woven, then only compiler messages will be
  41. emitted. However, the usual case for the compiler/weaver working
  42. at build time is to emit both compiler and weaver messages.
  43. </para>
  44. <para> The tables below list some options, System Properties (for LTW only) and Java 5 annotations
  45. used to control AspectJ messages. The method
  46. of configuration depends on your environment so please refer to the relevant
  47. documentation for
  48. <ulink url="../devguide/ajc-ref.html">ajc</ulink>,
  49. <ulink url="../devguide/antTasks.html">Ant</ulink> or
  50. <ulink url="../devguide/ltw-configuration.html#weaver-options">LTW</ulink>.
  51. </para>
  52. <para>
  53. <informaltable>
  54. <tgroup cols="2">
  55. <thead>
  56. <row>
  57. <entry>Option</entry>
  58. <entry>Description</entry>
  59. </row>
  60. </thead>
  61. <tbody>
  62. <row>
  63. <entry>
  64. <literal>-verbose</literal>
  65. </entry>
  66. <entry>
  67. Show informational messages including AspectJ version
  68. and build date.
  69. </entry>
  70. </row>
  71. <row>
  72. <entry>
  73. <literal>-debug</literal>
  74. </entry>
  75. <entry>
  76. (Load-time weaving only). Show debugging messages such as
  77. which classes are being woven or those that are excluded.
  78. (This is not related to the compiler -g option to
  79. include debug information in the output .class files.)
  80. </entry>
  81. </row>
  82. <row>
  83. <entry>
  84. <literal>-showWeaveInfo</literal>
  85. </entry>
  86. <entry>
  87. Show weaving messages.
  88. </entry>
  89. </row>
  90. <row>
  91. <entry>
  92. <literal>-Xlint</literal>
  93. </entry>
  94. <entry>
  95. Control level of lint messages.
  96. </entry>
  97. </row>
  98. <row>
  99. <entry>
  100. <literal>messageHolderClass</literal>/
  101. <literal>-XmessageHolderClass:</literal>
  102. </entry>
  103. <entry>
  104. In Ant tasks and LTW respectively specify the class to receive all messages.
  105. See
  106. <ulink url="../devguide/antTasks-iajc.html#antTasks-iajc-options">
  107. iajc task options</ulink> or
  108. <ulink url="../devguide/ltw-configuration.html#weaver-options">
  109. Weaver Options</ulink>.
  110. </entry>
  111. </row>
  112. <!-- We need full javadoc for this API
  113. <row>
  114. <entry>
  115. <literal>org.aspectj.tools.Main.setMessageHolder(..)</literal>
  116. </entry>
  117. <entry>
  118. Programmatic access for setting the message holder
  119. outside of Ant.
  120. </entry>
  121. </row>
  122. -->
  123. </tbody>
  124. </tgroup>
  125. </informaltable>
  126. </para>
  127. <para>
  128. <informaltable>
  129. <tgroup cols="2">
  130. <thead>
  131. <row>
  132. <entry>System Property</entry>
  133. <entry>Description</entry>
  134. </row>
  135. </thead>
  136. <tbody>
  137. <row>
  138. <entry>
  139. <literal>aj.weaving.verbose</literal>
  140. </entry>
  141. <entry>
  142. Show informational messages including AspectJ version and build date
  143. (same as <literal>-verbose</literal> option).
  144. </entry>
  145. </row>
  146. <row>
  147. <entry>
  148. <literal>org.aspectj.weaver.showWeaveInfo</literal>
  149. </entry>
  150. <entry>
  151. Show weaving messages
  152. (same as <literal>-showWeaveInfo</literal> option).
  153. </entry>
  154. </row>
  155. <row>
  156. <entry>
  157. <literal>org.aspectj.weaving.messages</literal>
  158. </entry>
  159. <entry>
  160. Set this system property to enable tracing of all compiler
  161. messages. See <xref linkend="trace-configuration"/>.
  162. </entry>
  163. </row>
  164. </tbody>
  165. </tgroup>
  166. </informaltable>
  167. </para>
  168. <para>
  169. <informaltable>
  170. <tgroup cols="2">
  171. <thead>
  172. <row>
  173. <entry>Annotation</entry>
  174. <entry>Description</entry>
  175. </row>
  176. </thead>
  177. <tbody>
  178. <row>
  179. <entry>
  180. <literal>@SuppressAjWarnings</literal>
  181. </entry>
  182. <entry>
  183. Include this is Java 5 code to suppress AspectJ
  184. warnings associated with the next line of code.
  185. </entry>
  186. </row>
  187. </tbody>
  188. </tgroup>
  189. </informaltable>
  190. </para>
  191. </sect2>
  192. </sect1>
  193. <sect1 id="messages-scenarios">
  194. <title>Message scenarios</title>
  195. <sect2 id="messages-scenarios-ct">
  196. <title>Compile-time weaving scenarios</title>
  197. <sect3 id="messages-scenarios-ct-adviceNotWoven">
  198. <title>Advice not woven</title>
  199. <para>This means that the pointcut for the advice did not match,
  200. and it should be debugged as described in
  201. <xref linkend="pointcuts"/>.</para>
  202. </sect3>
  203. </sect2>
  204. <sect2 id="messages-scenarios-ltw">
  205. <title>Load-time weaving scenarios</title>
  206. <para> You can use <literal>META-INF/aop.xml</literal> to control which
  207. messages are produced during LTW. The following example will produce
  208. basic informational messages about the lifecyle of the weaver in
  209. addition to any warning or error messages. </para>
  210. <programlisting><![CDATA[
  211. <aspectj>
  212. <weaver options="-verbose">
  213. </weaver>
  214. </aspectj>
  215. ]]></programlisting>
  216. <para>The messages indicate which <literal>META-INF/aop.xml</literal>
  217. configurations file(s) are being used. Each message is also preceeded by the
  218. name of the defining class loader associated with weaver. You can use this
  219. information in a large system to distinguish between different applications each
  220. of which will typically have its own class loader. </para>
  221. <programlisting><![CDATA[
  222. [AppClassLoader@92e78c] info AspectJ Weaver Version 1.5.3 built on Thursday Oct 26, 2006 at 17:22:31 GMT
  223. [AppClassLoader@92e78c] info register classloader sun.misc.Launcher$AppClassLoader@92e78c
  224. [AppClassLoader@92e78c] info using configuration /C:/temp/META-INF/aop.xml
  225. [AppClassLoader@92e78c] info using configuration /C:/temp/META-INF/aop-ajc.xml
  226. [AppClassLoader@92e78c] info register aspect ExceptionHandler
  227. [AppClassLoader@92e78c] info processing reweavable type ExceptionHandler: ExceptionHandler.aj
  228. ]]></programlisting>
  229. <sect3 id="messages-scenarios-ltw-adviceNotWoven">
  230. <title>Advice not woven</title>
  231. <para> It is often difficult to determine, especially when using load-time weaving (LTW),
  232. why advice has not been woven. Here is a quick guide to the messages to
  233. look for. Firstly if you use the <literal>-verbose</literal> option you
  234. should see the following message when your aspect is registered: </para>
  235. <programlisting><![CDATA[
  236. info register aspect MyAspect
  237. ]]></programlisting>
  238. <para> Secondly if you use the <literal>-debug</literal> option you should
  239. see a message indicating that you class is being woven: </para>
  240. <programlisting><![CDATA[
  241. debug weaving 'HelloWorld'
  242. ]]></programlisting>
  243. <para> However this does not mean that advice has actually been woven into
  244. your class; it says that the class has been passed to the weaver. To determine
  245. whether your pointcuts match you can use the <literal>-showWeaveInfo</literal>
  246. option which will cause a message to be issued each time a join point is woven: </para>
  247. <programlisting><![CDATA[
  248. weaveinfo Join point 'method-execution(void HelloWorld.main(java.lang.String[]))' ...
  249. ]]></programlisting>
  250. <para>If advice is woven at this join point you should get the
  251. corresponding message.</para>
  252. </sect3>
  253. </sect2>
  254. </sect1>
  255. <sect1 id="messages-xlint">
  256. <title>Lint messages</title>
  257. <para>
  258. The table below lists some useful <literal>-Xlint</literal> messages. </para>
  259. <informaltable>
  260. <tgroup cols="3">
  261. <thead>
  262. <row>
  263. <entry>Message</entry>
  264. <entry>Default</entry>
  265. <entry>Description</entry>
  266. </row>
  267. </thead>
  268. <tbody>
  269. <row>
  270. <entry>
  271. <literal>aspectExcludedByConfiguration</literal>
  272. </entry>
  273. <entry>
  274. <literal>ignore</literal>
  275. </entry>
  276. <entry>
  277. If an aspect is not being woven, despite being
  278. registered, it could be that it has been excluded
  279. by either an <literal>include</literal> or <literal>exclude</literal>
  280. element in the
  281. <literal>aspects</literal> section of <literal>META-INF/aop.xml</literal>.
  282. Enable this message to determine whether an aspect has
  283. been excluded.
  284. </entry>
  285. </row>
  286. <row>
  287. <entry>
  288. <literal>adviceDidNotMatch</literal>
  289. </entry>
  290. <entry>
  291. <literal>warning</literal>
  292. </entry>
  293. <entry>
  294. Issued when advice did not potentially affect any join points.
  295. This means the corresponding pointcut did not match any join
  296. points in the program. This may be valid e.g., in library
  297. aspects or code picking up error conditions, but often the
  298. programmer simply made a mistake in the pointcut. The best
  299. approach is to debug the pointcut.
  300. </entry>
  301. </row>
  302. <row>
  303. <entry>
  304. <literal>invalidAbsoluteTypeName</literal>
  305. </entry>
  306. <entry>
  307. <literal>warning</literal>
  308. </entry>
  309. <entry>
  310. Issued when an exact type in a pointcut does not match any type
  311. in the system. Note that this can interact with the rules for
  312. resolving simple types, which permit unqualified names if they
  313. are imported.
  314. </entry>
  315. </row>
  316. <row>
  317. <entry>
  318. <literal>typeNotExposedToWeaver</literal>
  319. </entry>
  320. <entry>
  321. <literal>warning</literal>
  322. </entry>
  323. <entry>
  324. This means that a type which could be affected by an aspect
  325. is not available for weaving. This happens when a class on
  326. the classpath should be woven.
  327. </entry>
  328. </row>
  329. <row>
  330. <entry>
  331. <literal>runtimeExceptionNotSoftened</literal>
  332. </entry>
  333. <entry>
  334. <literal>warning</literal>
  335. </entry>
  336. <entry>
  337. Before AspectJ 5, declare soft used to soften runtime exceptions
  338. (unnecessarily). Since then, it does not but does issue this
  339. warning in case the programmer did intend for the exception
  340. to be wrapped.
  341. </entry>
  342. </row>
  343. <row>
  344. <entry>
  345. <literal>unmatchedSuperTypeInCall</literal>
  346. </entry>
  347. <entry>
  348. <literal>warning</literal>
  349. </entry>
  350. <entry>
  351. Issued when a call pointcut specifies a defining type which
  352. is not matched at the call site (where the declared type of
  353. the reference is used, not the actual runtime type). Most
  354. people should use
  355. 'target(Foo) &amp;&amp; call(void foo())'
  356. instead.
  357. </entry>
  358. </row>
  359. </tbody>
  360. </tgroup>
  361. </informaltable>
  362. </sect1>
  363. </chapter>