Overhaul ClassLoaderWeavingAdaptor to use statically initialised Unsafe instances and method handles pointing to their defineClass methods. Those now work universally on JDKs 8-21. In older JDKs, the method used to be in sun.misc.Unsafe, in more recent ones on jdk.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 everywhere org.ow2.asm:asm was used before. Maybe that is too many places, but no worse than before.
Add missing dependency on loadtime to aspectjweaver. This kept a build like mvn install -am -pl aspectjweaver from picking up changed loadtime classes.
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 useClassLoader::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.