Skip to content
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

Throw exception for minimal AJC runtime version violation #294

Merged
merged 1 commit into from
Mar 15, 2024

Conversation

kriegaex
Copy link
Contributor

@kriegaex kriegaex commented Mar 15, 2024

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.
Supersedes PR #293.

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]>
@kriegaex kriegaex added the bug Something isn't working label Mar 15, 2024
@kriegaex kriegaex added this to the 1.9.22 milestone Mar 15, 2024
@kriegaex kriegaex self-assigned this Mar 15, 2024
@kriegaex kriegaex merged commit b8447ab into master Mar 15, 2024
3 checks passed
@kriegaex kriegaex deleted the github-292 branch March 15, 2024 08:46
@SamD
Copy link

SamD commented Apr 1, 2024

This prevents the plugin from working with Java 11, is that intended ?

@kriegaex
Copy link
Contributor Author

kriegaex commented Apr 2, 2024

No, it does not. It protects users from strange error messages in favour of a clearer one, because as documented here, AJC requires Java 17+ during build time since 1.9.21. This is due to the Eclipse Java Compiler ECJ, which AJC is a fork of. I cannot change the fact that an upstream dependency contains Java 17 class files, just like a while ago I could not change the JDT Core team's decision to switch to Java 11. AspectJ's own code still is Java 8 compliant, which you will notice when running aspect-enhanced programs on Java 8 or using the load-time weaver on Java 8. But ECJ (JDT Core) is Java 17, and we need that for compile-time weaving.

For more technical details, please read #260 (comment).

@SamD
Copy link

SamD commented Apr 3, 2024

Thanks for the clarification the project I'm working with is using compile-time weaving and not yet able to jump to 17. So until that time we will just need to pin aspectjtools to the previous version

@kriegaex
Copy link
Contributor Author

kriegaex commented Apr 4, 2024

Like I said, the Java 17 requirement only applies to the build environment. You can still run your aspects on older JREs. If you think you cannot run your build on JDK 17+ and do not need the latest AspectJ features and bugfixes, then pinning aspectjtools is a possible solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In-process compilation with less than minimal JRE version does not fail after printing warning
2 participants