The releases 1.9.22 and 1.9.22.1 are described together in this document.

AspectJ 1.9.22.1

© Copyright 2024 Contributors. All rights reserved.

Release info: 1.9.22.1 available 11-May-2024

Please note that Bugzilla for issue management is deprecated and new issues should be filed as GitHub issues. The list of issues addressed for 1.9.22.1 can be found here:

New features

AspectJ 1.9.22.1 has no new features, only bugfixes and improvements.

Improvements

AspectJ 1.9.22

© Copyright 2024 Contributors. All rights reserved.

Release info: 1.9.22 available 23-Mar-2024

Please note that Bugzilla for issue management is deprecated and new issues should be filed as GitHub issues. The list of issues addressed for 1.9.22 can be found here:

New features

AspectJ 1.9.22 supports Java 22, its final and preview features, such as:

  • JEP 456: Unnamed Variables & Patterns

  • JEP 459: String Templates (Second Preview)

  • JEP 463: Implicitly Declared Classes and Instance Main Methods (Second Preview)

  • JEP 447: Statements before super(…​) (Preview)

The following Java 22 features are API or JVM only, therefore irrelevant for the compiler and should just work out of the box:

  • JEP 423: Region Pinning for G1

  • JEP 454: Foreign Function & Memory API

  • JEP 458: Launch Multi-File Source-Code Programs

  • JEP 462: Structured Concurrency (Second Preview)

  • JEP 464: Scoped Values (Second Preview)

  • JEP 457: Class-File API (Preview)

  • JEP 461: Stream Gatherers (Preview)

  • JEP 460: Vector API (Seventh Incubator)

Improvements

  • No major improvements

Other changes and bug fixes

  • No major bug fixes

AspectJ usage hints

AspectJ compiler build system requirements

Since 1.9.21, the AspectJ compiler ajc (contained in the aspectjtools library) no longer works on JDKs 11 to 16. The minimum compile-time requirement is now JDK 17 due to upstream changes in the Eclipse Java Compiler (subset of JDT Core), which AspectJ is a fork of. You can still compile to legacy target versions as low as Java 1.3 when compiling plain Java code or using plain Java ITD constructs which do not require the AspectJ runtime aspectjrt, but the compiler itself needs JDK 17+. Just like in previous AspectJ versions, both the runtime aspectjrt and the load-time weaver aspectjweaver still only require JRE 8+.

History: Since 1.9.8, the AspectJ compiler ajc needed JDK 11+, before then JDK 8+.

Use LTW on Java 16+

Since AspectJ 1.9.21.1, using --add-opens is no longer necessary! The additional JVM command-line option was necessary for LTW on JRE 16+ in all AspectJ versions up to 1.9.21. Since AspectJ 1.9.21.1, the LTW agent uses an alternative approach for defining new classes during weaving, which works without --add-opens - at least for now, i.e. JDKs 8 to 22. There still is no canonical solution, because JDK-8200559 is still unresolved since 2018.

Compile with Java preview features

For features marked as preview on a given JDK, you need to compile with ajc --enable-preview and run with java --enable-preview on that JDK.

Please note, that you cannot run code compiled with preview features on any other JDK than the one used for compilation. For example, records compiled with preview on JDK 15 cannot be used on JDK 16 without recompilation. This is a JVM limitation unrelated to AspectJ. Also, e.g. sealed classes are preview-1 on JDK 15 and preview-2 on JDK 16. You still need to recompile, no matter what.