Skip to content

Commit

Permalink
Provide guidelines in AspectJ documentation to avoid dumps
Browse files Browse the repository at this point in the history
Closes gh-27650
  • Loading branch information
sdeleuze committed Jan 10, 2024
1 parent 9ccc72a commit 1631be5
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion framework-docs/modules/ROOT/pages/core/aop/using-aspectj.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,11 @@ standard AspectJ. The following example shows the `aop.xml` file:
</aspectj>
----

NOTE: It is recommended to only weave specific classes (typically those in the
application packages, as shown in the `aop.xml` example above) in order
to avoid side effects such as AspectJ dump files and warnings.
This is also a best practice from an efficiency perspective.

Now we can move on to the Spring-specific portion of the configuration. We need
to configure a `LoadTimeWeaver` (explained later). This load-time weaver is the
essential component responsible for weaving the aspect configuration in one or
Expand Down Expand Up @@ -714,10 +719,29 @@ Furthermore, the compiled aspect classes need to be available on the classpath.


[[aop-aj-ltw-aop_dot_xml]]
=== 'META-INF/aop.xml'
=== `META-INF/aop.xml`

The AspectJ LTW infrastructure is configured by using one or more `META-INF/aop.xml`
files that are on the Java classpath (either directly or, more typically, in jar files).
For example:

[source,xml,indent=0,subs="verbatim"]
----
<!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "https://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>
<weaver>
<!-- only weave classes in our application-specific packages -->
<include within="com.xyz.*"/>

This comment has been minimized.

Copy link
@kriegaex

kriegaex Feb 14, 2024

Contributor

@sdeleuze: Revisiting this issue for another reason, I just noticed this line. It should be com.xyz..* (double dot) to also include sub-packages. This is such a common error, and newbies usually copy & paste, propagating the same errors, asking the same questions over and over on Stack Overflow...

This comment has been minimized.

Copy link
@sdeleuze

sdeleuze Feb 14, 2024

Author Contributor

Good catch, will improve that via #32264.

</weaver>
</aspectj>
----

NOTE: It is recommended to only weave specific classes (typically those in the
application packages, as shown in the `aop.xml` example above) in order
to avoid side effects such as AspectJ dump files and warnings.
This is also a best practice from an efficiency perspective.

The structure and contents of this file is detailed in the LTW part of the
{aspectj-docs-devguide}/ltw-configuration.html[AspectJ reference
Expand Down

0 comments on commit 1631be5

Please sign in to comment.