-
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
In-process compilation with less than minimal JRE version does not fail after printing warning #292
Comments
…mal JRE version is incorrect
MR proposed: #293 |
Thanks for the PR, @philippe-granet. I will review and possibly merge it, with or without modification. Note to myself: The actual problem is that AJ Maven does not fork but runs AJC in-process, i.e. the exit code -1 which would signal an error is not there in that situation. Before introducing the warning, AJC would just try to start compilation and run into an exception thrown by the JVM due to unknown class file versions or by JDT Core due to missing constants there, whichever would occur first depending on the AspectJ version. By trying to print a more comprehensive error message instead of throwing an exception, AspectJ lost the ability to signal the fatal error in the in-process situation, which I think is what really needs to be fixed. Logging a compiler error instead as proposed here feels wrong, because there was no compilation attempt in the first place. A good old exception like before, just with a clear error message, might be not just the simplest but also the best course of action. |
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]>
@philippe-granet, while writing the note to myself - a technique I sometimes use when there is no other "rubber duck" to talk to - I realised that I actually prefer to throw an exception, if the minimum JRE requirement is unmet, which is why I created another PR superseding yours. Having said that, I am still impressed that you created your own PR and managed to get it done with the complex message handling approach. By all means, feel encouraged to contribute more to AspectJ. Your PRs are always welcome, even though this particular one ended up unmerged. But I hope that my alternative fix also works for you. |
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]>
Yes your alternative is OK for me, thanks! |
When using https://github.com/mojohaus/aspectj-maven-plugin with an invalid JRE version, aspectj silently return without any error in
MessageHolder
:aspectj/org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java
Lines 247 to 251 in d279437
In maven logs:
-> build continue and not failing
The text was updated successfully, but these errors were encountered: