-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AJC 1.9.21 on JDK < 17 dumps ajcore file with 'NoSuchFieldError: RELEASE_17' #269
Comments
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. |
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
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 import javax.lang.model.SourceVersion;
// (...)
public static final SourceVersion MINIMAL_REQUIRED_RUNTIME_VERSION = SourceVersion.RELEASE_17;
There are two ways to handle that:
An |
Signed-off-by: Alexander Kriegisch <[email protected]>
This should avoid the strange "NoSuchFieldError: RELEASE_17" error message in AJC. Relates to eclipse-aspectj/aspectj#269. Signed-off-by: Alexander Kriegisch <[email protected]>
Use new constant Main.MINIMAL_JRE_VERSION (currently = 17) and SourceVersion.latest().ordinal() to check, if the minimal JRE version requirement for AJC is met. If not, then exit with code -1 and error message "The AspectJ compiler needs at least Java runtime 17". Relates to #269. Signed-off-by: Alexander Kriegisch <[email protected]>
When running AJC, throw an AbortException(MINIMAL_JRE_VERSION) instead of just logging an error, if the minimal JRE version requirement is violated. Otherwise, in-process compilation would not fail due to the skipped System.exit(-1) that was used before. In-process compilation is, for example, relevant for AspectJ Maven Plugin, but also for non-forked executions of Plexus AspectJ via Maven Compiler. I am not 100% sure that AbortException is the appropriate exception type, because it was designed for an aborted compilation process and here compilation has not even started yet, but it seems to work fine. Relates to #269. Fixes #292. Signed-off-by: Alexander Kriegisch <[email protected]>
When running AJC, throw an AbortException(MINIMAL_JRE_VERSION) instead of just logging an error, if the minimal JRE version requirement is violated. Otherwise, in-process compilation would not fail due to the skipped System.exit(-1) that was used before. In-process compilation is, for example, relevant for AspectJ Maven Plugin, but also for non-forked executions of Plexus AspectJ via Maven Compiler. I am not 100% sure that AbortException is the appropriate exception type, because it was designed for an aborted compilation process and here compilation has not even started yet, but it seems to work fine. Relates to #269. Fixes #292. Signed-off-by: Alexander Kriegisch <[email protected]>
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.
The text was updated successfully, but these errors were encountered: