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.adoc 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. [[messages]]
  2. = Messages
  3. [[messages-introduction]]
  4. == Introduction
  5. Messages point out potential problems in the input program; some are
  6. clearly problems (errors), but many more may depend on what the
  7. programmer intends. To keep the noise down the latter are treated as
  8. warnings which can be ignored by the programmer or information which are
  9. hidden. However, when investigating unexpected behavior it's helpful to
  10. show them. This section describes how to configure messages, presents
  11. some problem scenarios when compiling or doing load-time weaving, and
  12. summarizes some of the more relevant messages.
  13. [[messages-introduction-config]]
  14. === Configuring Messages
  15. The compiler offers `-verbose`, `-warning`, and `-XLint` options when
  16. invoked using the command-line, Ant, or embedded in an IDE. All options
  17. are listed in the AspectJ Development Environment Guide sections for
  18. xref:../devguide/ajc.adoc#ajc[Ajc] and
  19. xref:../devguide/antsupport.adoc#antTasks[Ant Tasks]. The
  20. xref:../devguide/ltw.adoc#ltw[Load-time Weaving] section describes how to
  21. use XML configuration files and system properties to pass options to the
  22. weaver. (You can also pass options to the weaver using system properties
  23. in build- time weaving.) The `-verbose` option has the effect of
  24. including messages level "info", which are normally ignored. Both
  25. `warning` and `XLint` enable you to identify specific messages to emit,
  26. but warning messages tend to be the same provided by the underlying
  27. Eclipse JDT (Java) compiler, while XLint messages are emitted by the
  28. AspectJ compiler or weaver. Obviously, during load-time weaving only
  29. weaver messages will be emitted. Similarly, if aspects are compiled but
  30. not woven, then only compiler messages will be emitted. However, the
  31. usual case for the compiler/weaver working at build time is to emit both
  32. compiler and weaver messages.
  33. The tables below list some options, System Properties (for LTW only) and
  34. Java 5 annotations used to control AspectJ messages. The method of
  35. configuration depends on your environment so please refer to the
  36. relevant documentation for xref:../devguide/ajc.adoc[ajc],
  37. xref:../devguide/antsupport.adoc#antTasks[Ant] or
  38. xref:../devguide/ltw.adoc#weaver-options[LTW].
  39. [cols=",",options="header",]
  40. |===
  41. |Option |Description
  42. |`-verbose` |Show informational messages including AspectJ version and
  43. build date.
  44. |`-debug` |(Load-time weaving only). Show debugging messages such as
  45. which classes are being woven or those that are excluded. (This is not
  46. related to the compiler -g option to include debug information in the
  47. output .class files.)
  48. |`-showWeaveInfo` |Show weaving messages.
  49. |`-Xlint` |Control level of lint messages.
  50. |`messageHolderClass`/ `-XmessageHolderClass:` |In Ant tasks and LTW
  51. respectively specify the class to receive all messages. See
  52. xref:../devguide/antsupport.adoc#antTasks-iajc-options[iajc task
  53. options] or
  54. xref:../devguide/ltw.adoc#weaver-options[Weaver Options].
  55. |===
  56. [cols=",",options="header",]
  57. |===
  58. |System Property |Description
  59. |`aj.weaving.verbose` |Show informational messages including AspectJ
  60. version and build date (same as `-verbose` option).
  61. |`org.aspectj.weaver.showWeaveInfo` |Show weaving messages (same as
  62. `-showWeaveInfo` option).
  63. |`org.aspectj.weaving.messages` |Set this system property to enable
  64. tracing of all compiler messages. See xref:trace.adoc#trace-configuration[Configuring Tracing].
  65. |===
  66. [cols=",",options="header",]
  67. |===
  68. |Annotation |Description
  69. |`@SuppressAjWarnings` |Include this is Java 5 code to suppress AspectJ
  70. warnings associated with the next line of code.
  71. |===
  72. [[messages-scenarios]]
  73. == Message scenarios
  74. [[messages-scenarios-ct]]
  75. === Compile-time weaving scenarios
  76. [[messages-scenarios-ct-adviceNotWoven]]
  77. ==== Advice not woven
  78. This means that the pointcut for the advice did not match, and it should
  79. be debugged as described in xref:pointcuts.adoc#pointcuts[Debugging Pointcuts].
  80. [[messages-scenarios-ltw]]
  81. === Load-time weaving scenarios
  82. You can use `META-INF/aop.xml` to control which messages are produced
  83. during LTW. The following example will produce basic informational
  84. messages about the lifecyle of the weaver in addition to any warning or
  85. error messages.
  86. [source, xml]
  87. ....
  88. <aspectj>
  89. <weaver options="-verbose">
  90. </weaver>
  91. </aspectj>
  92. ....
  93. The messages indicate which `META-INF/aop.xml` configurations file(s)
  94. are being used. Each message is also preceeded by the name of the
  95. defining class loader associated with weaver. You can use this
  96. information in a large system to distinguish between different
  97. applications each of which will typically have its own class loader.
  98. [source, text]
  99. ....
  100. [AppClassLoader@92e78c] info AspectJ Weaver Version 1.5.3 built on Thursday Oct 26, 2006 at 17:22:31 GMT
  101. [AppClassLoader@92e78c] info register classloader sun.misc.Launcher$AppClassLoader@92e78c
  102. [AppClassLoader@92e78c] info using configuration /C:/temp/META-INF/aop.xml
  103. [AppClassLoader@92e78c] info using configuration /C:/temp/META-INF/aop-ajc.xml
  104. [AppClassLoader@92e78c] info register aspect ExceptionHandler
  105. [AppClassLoader@92e78c] info processing reweavable type ExceptionHandler: ExceptionHandler.aj
  106. ....
  107. [[messages-scenarios-ltw-adviceNotWoven]]
  108. ==== Advice not woven
  109. It is often difficult to determine, especially when using load-time
  110. weaving (LTW), why advice has not been woven. Here is a quick guide to
  111. the messages to look for. Firstly if you use the `-verbose` option you
  112. should see the following message when your aspect is registered:
  113. [source, text]
  114. ....
  115. info register aspect MyAspect
  116. ....
  117. Secondly if you use the `-debug` option you should see a message
  118. indicating that you class is being woven:
  119. [source, text]
  120. ....
  121. debug weaving 'HelloWorld'
  122. ....
  123. However this does not mean that advice has actually been woven into your
  124. class; it says that the class has been passed to the weaver. To
  125. determine whether your pointcuts match you can use the `-showWeaveInfo`
  126. option which will cause a message to be issued each time a join point is
  127. woven:
  128. [source, text]
  129. ....
  130. weaveinfo Join point 'method-execution(void HelloWorld.main(java.lang.String[]))' ...
  131. ....
  132. If advice is woven at this join point you should get the corresponding
  133. message.
  134. [[messages-xlint]]
  135. == Lint messages
  136. The table below lists some useful `-Xlint` messages.
  137. [cols=",,",options="header",]
  138. |===
  139. |Message |Default |Description
  140. |`aspectExcludedByConfiguration` |`ignore` |If an aspect is not being
  141. woven, despite being registered, it could be that it has been excluded
  142. by either an `include` or `exclude` element in the `aspects` section of
  143. `META-INF/aop.xml`. Enable this message to determine whether an aspect
  144. has been excluded.
  145. |`adviceDidNotMatch` |`warning` |Issued when advice did not potentially
  146. affect any join points. This means the corresponding pointcut did not
  147. match any join points in the program. This may be valid e.g., in library
  148. aspects or code picking up error conditions, but often the programmer
  149. simply made a mistake in the pointcut. The best approach is to debug the
  150. pointcut.
  151. |`invalidAbsoluteTypeName` |`warning` |Issued when an exact type in a
  152. pointcut does not match any type in the system. Note that this can
  153. interact with the rules for resolving simple types, which permit
  154. unqualified names if they are imported.
  155. |`typeNotExposedToWeaver` |`warning` |This means that a type which could
  156. be affected by an aspect is not available for weaving. This happens when
  157. a class on the classpath should be woven.
  158. |`runtimeExceptionNotSoftened` |`warning` |Before AspectJ 5, declare
  159. soft used to soften runtime exceptions (unnecessarily). Since then, it
  160. does not but does issue this warning in case the programmer did intend
  161. for the exception to be wrapped.
  162. |`unmatchedSuperTypeInCall` |`warning` |Issued when a call pointcut
  163. specifies a defining type which is not matched at the call site (where
  164. the declared type of the reference is used, not the actual runtime
  165. type). Most people should use 'target(Foo) && call(void foo())' instead.
  166. |===