]> source.dussan.org Git - aspectj.git/commit
Workaround for defining classes during LTW
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Sun, 28 Jan 2024 09:13:22 +0000 (16:13 +0700)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Mon, 29 Jan 2024 00:07:26 +0000 (07:07 +0700)
commitf986c3d18386e77c974e4272ab27c3b573773c9b
tree542e0be08b7f34133dc9813cef864e5bfb75e31d
parent8b3a50e5ab8d78e96dd4401081388bc34c17edf4
Workaround for defining classes during LTW

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.

Fixes #117.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
29 files changed:
ajde.core/pom.xml
ajde/pom.xml
ajdoc/pom.xml
aspectjtools/pom.xml
aspectjweaver/aspectjweaver-assembly.xml
aspectjweaver/pom.xml
loadtime/pom.xml
loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
org.aspectj.ajdt.core/pom.xml
org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java
org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java
pom.xml
run-all-junit-tests/pom.xml
taskdefs/pom.xml
testing-drivers/pom.xml
testing/pom.xml
testing/src/test/java/org/aspectj/testing/AntSpec.java
testing/src/test/java/org/aspectj/testing/RunSpec.java
tests/bugs153/pr155033/ant.xml
tests/bugs153/pr157474/ant-server.xml
tests/bugs153/pr158957/ant.xml
tests/java5/ataspectj/ajc-ant.xml
tests/java5/ataspectj/ataspectj/UnweavableTest.java
tests/ltw/ant-server.xml
tests/ltw/ant.xml
tests/pom.xml
tests/profiling/build.xml
tests/tracing/ant.xml
weaver/pom.xml