Closed simonpahl closed 11 months ago
Ok, apparently the issue comes from https://github.com/eclipse-aspectj/eclipse.jdt.core/blob/V1_9_21_RC1/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseProcessingEnvImpl.java#L49C36-L49C68 . And it seems like this version of eclipse.jdt.core is built to run only on Java 17 and higher.
Yes, sure. Maybe next time, you want to read the release notes before upgrading AspectJ.
It also explains the root cause. It is not an AspectJ decision, but we depend on Eclipse JDT Core. It only affects the AspectJ compiler, not the runtime.
# mvn --version Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae) Maven home: /home/xxx/.sdkman/candidates/maven/current Java version: 11.0.21, vendor: Eclipse Adoptium, runtime: /home/xxx/.sdkman/candidates/java/11.0.21-tem
Here, I could have seen the problem, but standing in the middle of a crowd in the bus, scrolling on the mobile phone with one hand is not an ideal situation.
I looked into this a bit more. When running ECJ 3.36.0 or 3.37.0-SNAPSHOT stand-alone, the JVM throws a LinkageError
, caused by UnsupportedClassVersionError
, which is kind of clear to the user:
$ java -jar ~/.m2/repository/org/eclipse/jdt/ecj/3.37.0-SNAPSHOT/ecj-3.37.0-SNAPSHOT.jar -11 src/main/java/org/example/Main.java
Error: LinkageError occurred while loading main class org.eclipse.jdt.internal.compiler.batch.Main
java.lang.UnsupportedClassVersionError: org/eclipse/jdt/internal/compiler/batch/Main has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
With ACJ 1.9.21 stand-alone, compilation can even pass for simple cases, but in many cases we will see the error you posted here. The difference is due to the fact that the Eclipse JDT Core is compiled to with source and target level 17, while the forked AspectJ JDT Core is compiled with source 17 and target 11, which today still works (maybe no longer in the future). But in some execution paths, the class org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl
(just a relocated version of the upstream class without the org.aspectj
package prefix) is loaded, and that one defines
import javax.lang.model.SourceVersion;
// (...)
public static final SourceVersion MINIMAL_REQUIRED_RUNTIME_VERSION = SourceVersion.RELEASE_17;
SourceVersion
is a JDK class, more exactly an enum
, and that enum constant does not exist in JDKs < 17. I.e., on JDK 11 many classes of the AspectJ compiler load normally, until at some point BaseProcessingEnvImpl
is loaded and tries to use a constant not present in the current JDK, which leads to the exception you have seen.
There are two ways to handle that:
ajcore.*.txt
core dump file.LinkageError
, caused by UnsupportedClassVersionError
, as ECJ.An UnsupportedClassVersionError
already occurs, if you run AJC 1.9.21 e.g. on JDK 8, i.e. it would be kind of consistent to yield the same effect on JDKs 11 to 16. It is already documented in the release notes and Java version compatibility matrix that AJC 1.9.21 needs JDK 17 to run, so strictly speaking neither change is necessary. But avoiding AJ core dumps one way or another would still be appropriate.
Steps to reproduce
Java Code (org/example/Main.java):
Maven version
mvn clean install
causes the following Error:Changing back to AspectJ 1.9.20.1 or changing to JDK 17 resolves this issue.