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.

ltw.xml 32KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. <chapter id="ltw" xreflabel="Load-Time Weaving">
  2. <title>Load-Time Weaving</title>
  3. <sect1 id="ltw-introduction">
  4. <title>Introduction</title>
  5. <para> The AspectJ weaver takes class files as input and produces class files as output.
  6. The weaving process itself can take place at one of three different times: compile-time,
  7. post-compile time, and load-time. The class files produced by the weaving process (and
  8. hence the run-time behaviour of an application) are the same regardless of the approach
  9. chosen. </para>
  10. <itemizedlist>
  11. <listitem> <para>Compile-time weaving is the simplest approach. When you have the source code
  12. for an application, ajc will compile from source and produce woven class files as
  13. output. The invocation of the weaver is integral to the ajc compilation process. The
  14. aspects themselves may be in source or binary form. </para></listitem>
  15. <listitem> <para>Post-compile weaving (also sometimes called binary weaving) is used to weave
  16. existing class files and JAR files. As with compile-time weaving,
  17. the aspects used for weaving may be in source or binary form,
  18. and may themselves be woven by aspects. </para></listitem>
  19. <listitem> <para>Load-time weaving (LTW) is simply binary weaving defered until the point that
  20. a class loader loads a class file and defines the class to the JVM. To support this,
  21. one or more "weaving class loaders", either provided explicitly by the run-time
  22. environment or enabled through a "weaving agent" are required. </para></listitem>
  23. </itemizedlist>
  24. <para> You may also hear the term "run-time weaving". We define this as the weaving of
  25. classes that have already been defined to the JVM (without reloading those
  26. classes). AspectJ 5 does not provide explicit support for run-time weaving although
  27. simple coding patterns can support dynamically enabling and disabling advice in aspects. </para>
  28. <sect2 id="weaving-class-files-more-than-once" xreflabel="weaving-class-files-more-than-once">
  29. <title>Weaving class files more than once</title>
  30. <para> As of AspectJ 5 aspects (code style or annotation style) and woven classes are
  31. reweavable by default. If you are developing AspectJ applications that are to be used
  32. in a load-time weaving environment with an older version of the compiler you
  33. need to specify the <literal>-Xreweavable</literal> compiler option when building
  34. them. This causes AspectJ to save additional state in the class files that is used
  35. to support subsequent reweaving. </para>
  36. </sect2>
  37. </sect1>
  38. <sect1 id="ltw-rules">
  39. <title>Load-time Weaving Requirements</title>
  40. <para> All load-time weaving is done in the context of a class loader, and hence the set of
  41. aspects used for weaving and the types that can be woven are affected by the class
  42. loader delegation model. This ensures that LTW complies with the Java 2 security model.
  43. The following rules govern the interaction of load-time weaving with class loading: </para>
  44. <orderedlist>
  45. <listitem> <para>All aspects to be used for weaving must be defined to the weaver before any
  46. types to be woven are loaded. This avoids types being "missed" by aspects added
  47. later, with the result that invariants across types fail.</para></listitem>
  48. <listitem> <para>All aspects visible to the weaver are usable.
  49. A visible aspect is one defined by the
  50. weaving class loader or one of its parent class loaders.
  51. All concrete visible aspects are woven and all abstract visible aspects
  52. may be extended.
  53. </para></listitem>
  54. <listitem><para>A class loader may only weave classes that it defines. It may not weave
  55. classes loaded by a delegate or parent class loader.</para></listitem>
  56. </orderedlist>
  57. </sect1>
  58. <sect1 id="ltw-configuration">
  59. <title>Configuration</title>
  60. <para>New in AspectJ 5 are a number of mechanisms to make load-time weaving
  61. easy to use. The load-time weaving mechanism is chosen through JVM startup options.
  62. Configuration files determine the set of aspects to be used for weaving and which
  63. types will be woven. Additional diagnostic options allow the user to debug the configuration and
  64. weaving process. </para>
  65. <sect2 id="enabling-load-time-weaving" xreflabel="enabling-load-time-weaving">
  66. <title>Enabling Load-time Weaving</title>
  67. <para> AspectJ 5 supports several ways of enabling load-time weaving for
  68. an application: agents, a command-line launch script, and a set of interfaces for
  69. integration of AspectJ load-time weaving in custom environments. </para>
  70. <variablelist>
  71. <varlistentry>
  72. <term>Agents</term>
  73. <listitem>
  74. <para>AspectJ 5 ships with a number of load-time weaving agents that
  75. enable load-time weaving. These agents and their configuration
  76. are execution environment dependent. Configuration for the supported environments is discussed
  77. later in this chapter.</para>
  78. <para>
  79. Using Java 5 JVMTI you can specify the <literal>-javaagent:pathto/aspectjweaver.jar</literal> option
  80. to the JVM.</para><para>
  81. Using BEA JRockit and Java 1.3/1.4, the very same behavior can be obtained using BEA JRockit JMAPI features with
  82. the <literal>-Xmanagement:class=org.aspectj.weaver.loadtime.JRockitAgent</literal>
  83. </para>
  84. </listitem>
  85. </varlistentry>
  86. <varlistentry>
  87. <term>Command-line wrapper scripts <literal>aj</literal></term>
  88. <listitem>
  89. <para>The <command>aj</command> command runs Java programs in Java 1.4 or
  90. later by setting up <literal>WeavingURLClassLoader</literal> as the
  91. system class loader.
  92. For more information, see <xref linkend="aj"/>.
  93. </para>
  94. <para>The <command>aj5</command> command runs Java programs in Java 5
  95. by using the <literal>-javaagent:pathto/aspectjweaver.jar</literal> option
  96. described above.
  97. For more information, see <xref linkend="aj"/>.
  98. </para>
  99. </listitem>
  100. </varlistentry>
  101. <varlistentry>
  102. <term>Custom class loader</term>
  103. <listitem>
  104. <para> A public interface is provided to allow a user written class loader
  105. to instantiate a weaver and weave classes after loading and before
  106. defining them in the JVM. This enables load-time weaving to be supported in
  107. environments where no weaving agent is available. It also allows the
  108. user to explicitly restrict by class loader which classes can be woven.
  109. For more information, see <xref linkend="aj"/> and the
  110. API documentation and source for
  111. <literal>WeavingURLClassLoader</literal> and
  112. <literal>WeavingAdapter</literal>.
  113. </para>
  114. </listitem>
  115. </varlistentry>
  116. </variablelist>
  117. </sect2>
  118. <sect2 id="configuring-load-time-weaving-with-aopxml-files" xreflabel="configuring-load-time-weaving-with-aopxml-files">
  119. <title>Configuring Load-time Weaving with aop.xml files</title>
  120. <para>The weaver is configured using one or more <literal>META-INF/aop.xml</literal>
  121. files located on the class loader search path. Each file may define a list of
  122. aspects to be used for weaving, type patterns describing which types
  123. should woven, and a set of options to be passed to the weaver. In addition AspectJ 5
  124. supports the definition of concrete aspects in XML. Aspects defined in this way
  125. must extend an abstract aspect visible to the weaver. The abstract aspect
  126. may define abstract pointcuts (but not abstract
  127. methods). The following example shows a simple aop.xml file: </para>
  128. <programlisting><![CDATA[
  129. <aspectj>
  130. <aspects>
  131. <!-- declare two existing aspects to the weaver -->
  132. <aspect name="com.MyAspect"/>
  133. <aspect name="com.MyAspect.Inner"/>
  134. <!-- define a concrete aspect inline -->
  135. <concrete-aspect name="com.xyz.tracing.MyTracing"
  136. extends="tracing.AbstractTracing"
  137. precedence="com.xyz.first, *">
  138. <pointcut name="tracingScope" expression="within(org.maw.*)"/>
  139. </concrete-aspect>
  140. <!-- Of the set of aspects declared to the weaver
  141. use aspects matching the type pattern "com..*" for weaving. -->
  142. <include within="com..*"/>
  143. <!-- Of the set of aspects declared to the weaver
  144. do not use any aspects with the @CoolAspect annotation for weaving -->
  145. <exclude within="@CoolAspect *"/>
  146. </aspects>
  147. <weaver options="-verbose">
  148. <!-- Weave types that are within the javax.* or org.aspectj.*
  149. packages. Also weave all types in the foo package that do
  150. not have the @NoWeave annotation. -->
  151. <include within="javax.*"/>
  152. <include within="org.aspectj.*"/>
  153. <include within="(!@NoWeave foo.*) AND foo.*"/>
  154. <!-- Do not weave types within the "bar" pakage -->
  155. <exclude within="bar.*"/>
  156. <!-- Dump all types within the "somepack" package,
  157. both before are after they are woven,
  158. to the "./_ajdump" folder on disk (for diagnostic purposes) -->
  159. <dump within="somepack.*" />
  160. </weaver>
  161. </aspectj>
  162. ]]></programlisting>
  163. <para>
  164. An aop.xml file contains two key sections: "aspects" defines one
  165. or more aspects to the weaver and controls which aspects are to be
  166. used in the weaving process; "weaver" defines weaver options and which
  167. types should be woven.
  168. </para>
  169. <para>
  170. The simplest way to define an aspect to the weaver is to
  171. specify the fully-qualified name of the aspect type in an aspect element.
  172. You can also
  173. declare (and define to the weaver) aspects inline in the aop.xml file.
  174. This is done using the "concrete-aspect" element. A concrete-aspect
  175. declaration must provide a pointcut definition for every abstract
  176. pointcut in the abstract aspect it extends. This mechanism is a
  177. useful way of externalizing configuration for infrastructure and
  178. auxiliary aspects where the pointcut definitions themselves can be
  179. considered part of the configuration of the service.
  180. Refer to the next section for more details.
  181. </para>
  182. <para>
  183. The <literal>aspects</literal> element may optionally contain one or more <literal>include</literal> and
  184. <literal>exclude</literal> elements (by default, all defined aspects are used for weaving).
  185. Specifying include or exclude elements restricts the set of defined
  186. aspects to be used for weaving to those that are matched by an include
  187. pattern, but not by an exclude pattern. The <literal>within</literal> attribute accepts
  188. a type pattern of the same form as a within pcd, except that &amp;&amp;
  189. and || are replaced by 'AND' and 'OR'.
  190. </para>
  191. <para>
  192. Note that <literal>include</literal> and <literal>exclude</literal> elements affect all aspects
  193. declared to the weaver including those in other aop.xml files. To help avoid unexpected
  194. behaviour a lint warning is issued
  195. if an aspect is not declared as a result of of applying these filters.
  196. Also note <literal>aspect</literal> and <literal>concrete-aspect</literal> elements
  197. must be used to delare aspects to the weaver i.e. <literal>include</literal> and <literal>exclude</literal>
  198. elements cannot be used find aspects on the class loader search path.
  199. </para>
  200. <para>
  201. The weaver element is used to pass options to the weaver and to specify
  202. the set of types that should be woven. If no include elements are specified
  203. then all types visible to the weaver will be woven.
  204. </para>
  205. <para> When several configuration files are visible from a given weaving class loader
  206. their contents are conceptually merged.
  207. The files are merged in the order they are
  208. found on the search path (regular <literal>getResourceAsStream</literal> lookup)
  209. according to the following rules: </para>
  210. <itemizedlist>
  211. <!-- FIXME AV - looks like we can refine conf in a child CL - not good -->
  212. <listitem> <para>The set of available aspects is the set of all
  213. declared and defined aspects (<literal>aspect</literal> and
  214. <literal>concrete-aspect</literal> elements of the <literal>aspects</literal>
  215. section).</para></listitem>
  216. <listitem> <para>The set of aspects used for weaving is the subset of the available
  217. aspects that are matched by at least one include statement and are not matched
  218. by any exclude statements. If there are no include statements then all non-excluded
  219. aspects are included.</para></listitem>
  220. <listitem> <para> The set of types to be woven are those types matched by at
  221. least one weaver <literal>include</literal> element and not matched by any
  222. weaver <literal>exclude</literal> element. If there are no weaver include
  223. statements then all non-excluded types are included.</para></listitem>
  224. <listitem> <para> The weaver options are derived by taking the union of the
  225. options specified in each of the weaver options attribute specifications. Where an
  226. option takes a value e.g. <literal>-warn:none</literal> the most recently defined value
  227. will be used.</para></listitem>
  228. </itemizedlist>
  229. <para>It is not an error for the same aspect to be defined to the weaver in
  230. more than one visible <literal>META-INF/aop.xml</literal> file.
  231. However, if a concrete aspect
  232. is defined in more than aop.xml file then an error will be issued.
  233. A concrete aspect
  234. defined in this way will be used to weave types loaded by the
  235. class loader that loaded the aop.xml file in which it was defined.
  236. </para>
  237. <para> A <literal>META-INF/aop.xml</literal> can be generated by
  238. using either the <literal>-outxml</literal> or <literal>-outxmlfile</literal> options of the AspectJ compiler.
  239. It will simply contain a (possibly empty) set of aspect elements; one for
  240. each abstract or concrete aspect defined.
  241. When used in conjuction with the <literal>-outjar</literal> option
  242. a JAR is produced that can be used
  243. with the <command>aj5</command> command or a load-time weaving environment.</para>
  244. </sect2>
  245. <sect2 id="concrete-aspect" xreflabel="concrete-aspect">
  246. <title>Using Concrete Aspects</title>
  247. <para>
  248. It is possible to make an abstract aspect concrete by means of the <literal>META-INF/aop.xml</literal>
  249. file. This is useful way to implement abstract pointcuts at deployment time, and also gives control
  250. over precedence through the <literal>precedence</literal> attribute of the
  251. <literal>concrete-aspect</literal> XML element.
  252. Consider the following:
  253. </para>
  254. <programlisting><![CDATA[
  255. package mypack;
  256. @Aspect
  257. public abstract class AbstractAspect {
  258. // abstract pointcut: no expression is defined
  259. @Pointcut
  260. abstract void scope();
  261. @Before("scope() && execution(* *..doSome(..))")
  262. public void before(JoinPoint jp) {
  263. ....
  264. }
  265. }
  266. ]]></programlisting>
  267. <para>
  268. This aspect is equivalent to the following in code style:
  269. </para>
  270. <programlisting><![CDATA[
  271. package mypack;
  272. public abstract aspect AbstractAspect {
  273. // abstract pointcut: no expression is defined
  274. abstract pointcut scope();
  275. before() : scope() && execution(* *..doSome(..)) {
  276. ....
  277. }
  278. }
  279. ]]></programlisting>
  280. <para>
  281. This aspect (in either style) can be made concrete using <literal>META-INF/aop.xml</literal>.
  282. It defines the abstract pointcut <literal>within()</literal>. When using this mechanism the
  283. following rules apply:
  284. <itemizedlist>
  285. <listitem><para>The parent aspect must be abstract. It can be an @AspectJ or a
  286. regular code style aspect.</para></listitem>
  287. <listitem><para>Only a simple abstract pointcut can be implemented i.e. a pointcut that doesn't expose
  288. state (through <literal>args(), this(), target(), if()</literal>). In @AspectJ syntax
  289. as illustrated in this sample, this means the method that hosts the pointcut must be abstract,
  290. have no arguments, and return void.</para></listitem>
  291. <listitem><para>The concrete aspect must implement all inherited abstract pointcuts.</para></listitem>
  292. <listitem><para>The concrete aspect may not implement methods so the abstract aspect it
  293. extends may not contain any abstract methods.</para></listitem>
  294. </itemizedlist>
  295. If more complex aspect inheritance is required use regular aspect
  296. inheritance instead of XML.
  297. The following XML definition shows a valid concrete sub-aspect for the abstract aspects above:
  298. </para>
  299. <programlisting><![CDATA[
  300. <aspectj>
  301. <conrete-aspect name="mypack.__My__AbstractAspect" extends="mypack.AbstractAspect">
  302. <pointcut name="scope" expression="within(yourpackage..*)"/>
  303. </concrete-aspect>
  304. </aspectj>
  305. ]]></programlisting>
  306. <para>
  307. It is important to remember that the <literal>name</literal> attribute in the
  308. <literal>concrete-aspect</literal> directive defines the fully qualified name that will be given to the
  309. concrete aspect. It must a valid class name because the aspect will be generated on the fly by the weaver.
  310. You must
  311. also ensure that there are no name collisions. Note that the concrete aspect will be
  312. defined at the classloader level for which the aop.xml is visible. This implies that if you need
  313. to use the <literal>aspectof</literal> methods to access the aspect instance(s) (depending on the perclause
  314. of the aspect it extends) you have to use the helper API <literal>org.aspectj.lang.Aspects.aspectOf(..)</literal>
  315. as in:
  316. </para>
  317. <programlisting><![CDATA[
  318. // exception handling omitted
  319. Class myConcreteAspectClass = Class.forName("mypack.__My__AbstractAspect");
  320. // here we are using a singleton aspect
  321. AbstractAspect concreteInstance = Aspects.aspectOf(myConcreteAspectClass);
  322. ]]></programlisting>
  323. </sect2>
  324. <sect2 id="concrete-aspect-precedence" xreflabel="concrete-aspect-precedence">
  325. <title>Using Concrete Aspects to define precedence</title>
  326. <para>
  327. As described in the previous section, the <literal>concrete-aspect</literal> element in
  328. <literal>META-INF/aop.xml</literal> gives the option to declare the precedence, just as
  329. <literal>@DeclarePrecedence</literal> or <literal>declare precedence</literal> do in
  330. aspect source code.
  331. </para>
  332. <para>
  333. Sometimes it is necessary to declare precedence without extending any abstract aspect.
  334. It is therefore possible to use the <literal>concrete-aspect</literal>
  335. element without the <literal>extends</literal> attribute and without any
  336. <literal>pointcut</literal> nested elements, just a <literal>precedence</literal>
  337. attribute.
  338. Consider the following:
  339. </para>
  340. <programlisting><![CDATA[
  341. <aspectj>
  342. <concrete-aspect name="mypack.__MyDeclarePrecedence"
  343. precedence="*..*Security*, Logging+, *"/>
  344. </aspectj>
  345. ]]></programlisting>
  346. <para>
  347. This deployment time definitions is only declaring a precedence rule. You have to remember
  348. that the <literal>name</literal> attribute must be a valid fully qualified class name
  349. that will be then reserved for this concrete-aspect and must not conflict with other classes
  350. you deploy.
  351. </para>
  352. </sect2>
  353. <!-- TODO someone implement that -->
  354. <!--
  355. <sect2 id="configuring-load-time-weaving-with-properties-files" xreflabel="configuring-load-time-weaving-with-properties-files">
  356. <title>Configuring Load-time Weaving with Properties Files</title>
  357. <para> For memory constrained environments or those without support for XML a simple
  358. Java Properties file can be used to configure LTW. Just like XML files,
  359. <literal>META-INF/aop.properties</literal> files are loaded from the class loader
  360. search path. Everything that can be configured through XML can be configured using a
  361. Properties file, with the exception of declarative concrete aspects. For example: </para>
  362. <programlisting><![CDATA[
  363. aspects.names=com.MyAspect,com.MyAspect.Inner
  364. aspects.include=com..*
  365. aspects.exclude=@CoolAspect
  366. weaver.options=-verbose
  367. weaver.include=javax.* OR org.aspectj.*
  368. ]]></programlisting>
  369. </sect2>
  370. -->
  371. <sect2 id="weaver-options" xreflabel="weaver-options">
  372. <title>Weaver Options</title>
  373. <para> The table below lists the AspectJ options supported by LTW. All other options
  374. will be ignored and a warning issued. </para>
  375. <informaltable>
  376. <tgroup cols="2">
  377. <thead>
  378. <row>
  379. <entry>Option</entry>
  380. <entry>Purpose</entry>
  381. </row>
  382. </thead>
  383. <tbody>
  384. <row>
  385. <entry>
  386. <literal>-verbose</literal>
  387. </entry>
  388. <entry>Issue informational messages about the weaving process. Messages issued while the weaver is being
  389. bootstrapped are accumulated until all options are parsed. If the messages are required to be output
  390. immediately you can use the option <literal>-Daj.weaving.verbose=true</literal> on the JVM startup command line.
  391. </entry>
  392. </row>
  393. <!-- TODO option parsed but not used -->
  394. <!--
  395. <row>
  396. <entry>
  397. <literal>-1.5</literal>
  398. </entry>
  399. <entry>Run the weaver in 1.5 mode (supports autoboxing in
  400. join point matching)</entry>
  401. </row>
  402. -->
  403. <row>
  404. <entry>
  405. <literal>-Xlintfile:pathToAResource</literal>
  406. </entry>
  407. <entry>Configure lint messages as specified in the given resource (visible from this aop.xml file' classloader)</entry>
  408. </row>
  409. <row>
  410. <entry>
  411. <literal>-Xlint:default, -Xlint:ignore, ...</literal>
  412. </entry>
  413. <entry>Configure lint messages, refer to documentation for meaningfull values</entry>
  414. </row>
  415. <row>
  416. <entry>
  417. <literal>-nowarn, -warn:none</literal>
  418. </entry>
  419. <entry>Suppress warning messages</entry>
  420. </row>
  421. <!-- TODO option parsed but not used -->
  422. <!--
  423. <row>
  424. <entry>
  425. <literal>-proceedOnError</literal>
  426. </entry>
  427. <entry>Continue weaving even if errors occur (for example,
  428. "... already woven" errors)</entry>
  429. </row>
  430. -->
  431. <row>
  432. <entry>
  433. <literal>-Xreweavable</literal>
  434. </entry>
  435. <entry>Produce class files that can subsequently be rewoven</entry>
  436. </row>
  437. <row>
  438. <entry>
  439. <literal>-XnoInline</literal>
  440. </entry>
  441. <entry>Don't inline around advice.</entry>
  442. </row>
  443. <row>
  444. <entry>
  445. <literal>-showWeaveInfo</literal>
  446. </entry>
  447. <entry>Issue informational messages whenever the weaver touches a class file</entry>
  448. </row>
  449. <row>
  450. <entry>
  451. <literal>-XmessageHandlerClass:...</literal>
  452. </entry>
  453. <entry>Provide alternative output destination to stdout/stderr for all weaver messages.
  454. The given value must be the full qualified class name of a class that implements the
  455. <literal>org.aspectj.bridge.IMessageHandler</literal> interface
  456. and is visible to the classloader with which the weaver being configured is associated.
  457. Exercise caution when packaging a custom message handler with an application that is to
  458. be woven. The handler (as well as classes on which it depends) cannot itself be woven
  459. by the aspects that are declared to the same weaver.
  460. </entry>
  461. </row>
  462. </tbody>
  463. </tgroup>
  464. </informaltable>
  465. </sect2>
  466. </sect1>
  467. <sect1 id="ltw-specialcases">
  468. <title>Special cases</title>
  469. <para>
  470. The following classes are not exposed to the LTW infrastructure regardless of
  471. the <literal>aop.xml</literal> file(s) used:
  472. <itemizedlist>
  473. <listitem> <para>All <literal>org.aspectj.*</literal> classes (and subpackages) - as those are needed by the infrastructure itself</para></listitem>
  474. <listitem> <para>All <literal>java.*</literal> and <literal>javax.*</literal> classes (and subpackages)</para></listitem>
  475. <listitem> <para>All <literal>sun.reflect.*</literal> classes - as those are JDK specific classes used when reflective calls occurs</para></listitem>
  476. </itemizedlist>
  477. </para>
  478. <para>
  479. Despite these restrictions, it is perfectly possible to match call join points for calls to these types providing the calling
  480. class is exposed to the weaver. Subtypes of these excluded types that are exposed to the weaver may of course be woven.
  481. </para>
  482. <para>
  483. Note that dynamic proxy representations are exposed to the LTW infrastructure and are not considered
  484. a special case.
  485. </para>
  486. <para>
  487. Some lint options behave differently when used under load-time weaving. The <literal>adviceDidNotMatch</literal>
  488. won't be handled as a warn (as during compile time) but as an info message.
  489. </para>
  490. </sect1>
  491. <sect1 id="ltw-packaging">
  492. <title>Runtime Requirements for Load-time Weaving</title>
  493. <para> To use LTW the <literal>aspectjweaver.jar</literal> library must be added to the
  494. classpath. This contains the AspectJ 5 runtime, weaver, weaving class loader and
  495. weaving agents. It also contains the DTD for parsing XML weaving configuration files. </para>
  496. </sect1>
  497. <sect1 id="ltw-agents">
  498. <title>Supported Agents</title>
  499. <sect2 id="jvmti" xreflabel="jvmti">
  500. <title>JVMTI</title>
  501. <para> When using Java 5 the JVMTI agent can be used by starting the JVM with the
  502. following option (adapt according to the path to aspectjweaver.jar): </para>
  503. <programlisting><![CDATA[
  504. -javaagent:pathto/aspectjweaver.jar
  505. ]]></programlisting>
  506. </sect2>
  507. <sect2 id="jrockit" xreflabel="jrockit">
  508. <title>JRockit with Java 1.3/1.4 (use JVMTI on Java 5)</title>
  509. <para> The JRockit agent is configured with the following JVM option: </para>
  510. <programlisting><![CDATA[
  511. -Xmanagement:class=org.aspectj.weaver.loadtime.JRockitAgent
  512. ]]></programlisting>
  513. </sect2>
  514. </sect1>
  515. </chapter>