Workaround for defining classes during LTW #275
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overhaul
ClassLoaderWeavingAdaptor
to use statically initialisedUnsafe
instances and method handles pointing to theirdefineClass
methods. Those now work universally on JDKs 8-21. In older JDKs, the method used to be insun.misc.Unsafe
, in more recent ones onjdk.internal.misc.Unsafe
. It is challenging to fetch instances, especially as reflection protection and module boundaries have been increased in the JDK progressively. But finally, a solution was adapted from Byte Buddy (BB).Kudos to BB author Rafael Winterhalter. The previous solution to use
ClassLoader::defineClass
and require--add-opens
is no longer necessary for the first time since it became necessary in AspectJ 1.9.7 with Java 16 support.Add
org.ow2.asm:asm-common
as a dependency everywhereorg.ow2.asm:asm
was used before. Maybe that is too many places, but no worse than before.Add missing dependency on
loadtime
toaspectjweaver
. This kept a build likemvn install -am -pl aspectjweaver
from picking up changedloadtime
classes.Fixes #117.