<html><head> | |
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> | |
<title>Chapter 5. Load-Time Weaving</title><link rel="stylesheet" href="aspectj-docs.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.44"><link rel="home" href="index.html" title="The AspectJtm Development Environment Guide"><link rel="up" href="index.html" title="The AspectJtm Development Environment Guide"><link rel="previous" href="antTasks-problems.html" title="Isolating problems running the Ant tasks"><link rel="next" href="ltw-rules.html" title="Load-time Weaving Requirements"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 5. Load-Time Weaving</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="antTasks-problems.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ltw-rules.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="ltw"></a>Chapter 5. Load-Time Weaving</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="ltw.html#ltw-introduction">Introduction</a></dt><dd><dl><dt><a href="ltw.html#weaving-class-files-more-than-once">Weaving class files more than once</a></dt></dl></dd><dt><a href="ltw-rules.html">Load-time Weaving Requirements</a></dt><dt><a href="ltw-configuration.html">Configuration</a></dt><dd><dl><dt><a href="ltw-configuration.html#enabling-load-time-weaving">Enabling Load-time Weaving</a></dt><dt><a href="ltw-configuration.html#configuring-load-time-weaving-with-aopxml-files">Configuring Load-time Weaving with aop.xml files</a></dt><dt><a href="ltw-configuration.html#concrete-aspect">Using Concrete Aspects</a></dt><dt><a href="ltw-configuration.html#concrete-aspect-precedence">Using Concrete Aspects to define precedence</a></dt><dt><a href="ltw-configuration.html#weaver-options">Weaver Options</a></dt></dl></dd><dt><a href="ltw-specialcases.html">Special cases</a></dt><dt><a href="ltw-packaging.html">Runtime Requirements for Load-time Weaving</a></dt><dt><a href="ltw-agents.html">Supported Agents</a></dt><dd><dl><dt><a href="ltw-agents.html#jvmti">JVMTI</a></dt><dt><a href="ltw-agents.html#jrockit">JRockit with Java 1.3/1.4 (use JVMTI on Java 5)</a></dt></dl></dd></dl></div><div class="sect1"><a name="ltw-introduction"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="ltw-introduction"></a>Introduction</h2></div></div><p> The AspectJ weaver takes class files as input and produces class files as output. | |
The weaving process itself can take place at one of three different times: compile-time, | |
post-compile time, and load-time. The class files produced by the weaving process (and | |
hence the run-time behaviour of an application) are the same regardless of the approach | |
chosen. </p><div class="itemizedlist"><ul><li><p><a name="d0e2714"></a>Compile-time weaving is the simplest approach. When you have the source code | |
for an application, ajc will compile from source and produce woven class files as | |
output. The invocation of the weaver is integral to the ajc compilation process. The | |
aspects themselves may be in source or binary form. </p></li><li><p><a name="d0e2717"></a>Post-compile weaving (also sometimes called binary weaving) is used to weave | |
existing class files and JAR files. As with compile-time weaving, | |
the aspects used for weaving may be in source or binary form, | |
and may themselves be woven by aspects. </p></li><li><p><a name="d0e2720"></a>Load-time weaving (LTW) is simply binary weaving defered until the point that | |
a class loader loads a class file and defines the class to the JVM. To support this, | |
one or more "weaving class loaders", either provided explicitly by the run-time | |
environment or enabled through a "weaving agent" are required. </p></li></ul></div><p> You may also hear the term "run-time weaving". We define this as the weaving of | |
classes that have already been defined to the JVM (without reloading those | |
classes). AspectJ 5 does not provide explicit support for run-time weaving although | |
simple coding patterns can support dynamically enabling and disabling advice in aspects. </p><div class="sect2"><a name="weaving-class-files-more-than-once"></a><div class="titlepage"><div><h3 class="title"><a name="weaving-class-files-more-than-once"></a>Weaving class files more than once</h3></div></div><p> By default a class file that has been woven by the AspectJ compiler cannot | |
subsequently be rewoven (passed as input to the weaver). If you are developing | |
AspectJ applications that are to be used in a load-time weaving environment, you | |
need to specify the <tt>-Xreweavable</tt> compiler option when building | |
them. This causes AspectJ to save additional state in the class files that is used | |
to support subsequent reweaving. </p><p>As per AspectJ 1.5.0 M3 aspects (code style or annotation style) are | |
reweavable by default, and weaved classes are reweavable by default as well as per AspectJ 1.5.0 M4.</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="antTasks-problems.html">Prev</a> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right"> <a accesskey="n" href="ltw-rules.html">Next</a></td></tr><tr><td width="40%" align="left">Isolating problems running the Ant tasks </td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"> Load-time Weaving Requirements</td></tr></table></div></body></html> |