]> source.dussan.org Git - aspectj.git/commit
Use previous weaving result if classes were generated during weaving
authorUri Simchoni <urisimchoni@gmail.com>
Sun, 4 Feb 2024 10:51:15 +0000 (12:51 +0200)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Thu, 8 Feb 2024 05:03:50 +0000 (12:03 +0700)
commit499eee18ed51ee29abf715929f6cdcd6ff68d7b1
treeba6209138685e28ff5a07d56ac4d7c90bfae2543
parent0f7b2e70f921192d8d36a943224f0e397c6d07a7
Use previous weaving result if classes were generated during weaving

A parallel-capable class loader might load the same class multiple times
in multiple threads, see
https://docs.oracle.com/javase/7/docs/technotes/guides/lang/cl-mt.html.

In this scenario, the JVM instrumentation mechanism invokes the AspectJ
weaver twice on the same class. In simple weaving scenarios, this would
just cause weaving logic to run multiple times and produce the same
result for each thread, but if the weaver is generating new classes,
it is undesirable to generate those classes multiple times.

To avoid this, the generatedClasses map in WeavingAdaptor keeps track of
classes for which inner classes were generated and avoids re-weaving
them. However, before this change, if a class was found in the generated
map, the weaver would return the un-woven bytes, which would cause
AspectJ not to work for some of the threads.

This change returns the woven bytes instead of re-running weaving.

Fixes #279.
weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java