Skip to content

Commit f986c3d

Browse files
committed
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 eclipse-aspectj#117. Signed-off-by: Alexander Kriegisch <[email protected]>
1 parent 8b3a50e commit f986c3d

File tree

29 files changed

+395
-223
lines changed

29 files changed

+395
-223
lines changed

ajde.core/pom.xml

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
<groupId>org.ow2.asm</groupId>
4646
<artifactId>asm</artifactId>
4747
</dependency>
48+
<dependency>
49+
<groupId>org.ow2.asm</groupId>
50+
<artifactId>asm-commons</artifactId>
51+
</dependency>
4852
<dependency>
4953
<groupId>org.aspectj</groupId>
5054
<artifactId>testing-util</artifactId>

ajde/pom.xml

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
<groupId>org.ow2.asm</groupId>
3737
<artifactId>asm</artifactId>
3838
</dependency>
39+
<dependency>
40+
<groupId>org.ow2.asm</groupId>
41+
<artifactId>asm-commons</artifactId>
42+
</dependency>
3943
<dependency>
4044
<groupId>org.aspectj</groupId>
4145
<artifactId>org.aspectj.ajdt.core</artifactId>

ajdoc/pom.xml

+4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
<groupId>org.ow2.asm</groupId>
5959
<artifactId>asm</artifactId>
6060
</dependency>
61+
<dependency>
62+
<groupId>org.ow2.asm</groupId>
63+
<artifactId>asm-commons</artifactId>
64+
</dependency>
6165
<dependency>
6266
<groupId>org.aspectj</groupId>
6367
<artifactId>testing-util</artifactId>

aspectjtools/pom.xml

+4
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,10 @@
364364
<groupId>org.ow2.asm</groupId>
365365
<artifactId>asm</artifactId>
366366
</dependency>
367+
<dependency>
368+
<groupId>org.ow2.asm</groupId>
369+
<artifactId>asm-commons</artifactId>
370+
</dependency>
367371
<dependency>
368372
<groupId>org.aspectj</groupId>
369373
<artifactId>runtime</artifactId>

aspectjweaver/aspectjweaver-assembly.xml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<useProjectArtifact>false</useProjectArtifact>
1818
<includes>
1919
<include>org.ow2.asm:asm</include>
20+
<include>org.ow2.asm:asm-commons</include>
2021
</includes>
2122
</dependencySet>
2223
</dependencySets>

aspectjweaver/pom.xml

+9
Original file line numberDiff line numberDiff line change
@@ -389,10 +389,19 @@
389389
<artifactId>weaver</artifactId>
390390
<version>${project.version}</version>
391391
</dependency>
392+
<dependency>
393+
<groupId>org.aspectj</groupId>
394+
<artifactId>loadtime</artifactId>
395+
<version>${project.version}</version>
396+
</dependency>
392397
<dependency>
393398
<groupId>org.ow2.asm</groupId>
394399
<artifactId>asm</artifactId>
395400
</dependency>
401+
<dependency>
402+
<groupId>org.ow2.asm</groupId>
403+
<artifactId>asm-commons</artifactId>
404+
</dependency>
396405
</dependencies>
397406

398407
</project>

loadtime/pom.xml

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
<groupId>org.ow2.asm</groupId>
4242
<artifactId>asm</artifactId>
4343
</dependency>
44+
<dependency>
45+
<groupId>org.ow2.asm</groupId>
46+
<artifactId>asm-commons</artifactId>
47+
</dependency>
4448
<dependency>
4549
<groupId>org.aspectj</groupId>
4650
<artifactId>testing-util</artifactId>

0 commit comments

Comments
 (0)