Skip to content

Commit

Permalink
Fix eclipse-aspectj#292 - Add error message in message holder if mini…
Browse files Browse the repository at this point in the history
…mal JRE version is incorrect
  • Loading branch information
philippe-granet committed Mar 14, 2024
1 parent d279437 commit e946a69
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,27 @@ public void setCommand(ICommand command) {
public void runMain(String[] args, boolean useSystemExit) {
final boolean doExit = useSystemExit && !flagInArgs("-noExit", args);

IMessageHolder holder = clientHolder;
if (null == this.clientHolder) {
this.clientHolder = checkForCustomMessageHolder(args);
}
if (null == holder) {
holder = ourHandler;
if (verbose) {
ourHandler.setInterceptor(MessagePrinter.VERBOSE);
} else {
ourHandler.ignore(IMessage.INFO);
ourHandler.setInterceptor(MessagePrinter.TERSE);
}
}
// This needs to be checked, before any classes using JDT Core classes are used for the first time. Otherwise, users
// will see ugly UnsupportedClassVersionError stack traces, which they might or might not interpret correctly.
// Therefore, interrupt AJC usage right here, even if it means that not even a usage page can be printed. It is
// better to save users from subsequent problems later.
if (SourceVersion.latest().ordinal() < MINIMAL_JRE_VERSION) {
System.err.println(MINIMAL_JRE_VERSION_ERROR);
IMessage minimalJreVersionErrorMessage = new Message(MINIMAL_JRE_VERSION_ERROR, null, true);
holder.handleMessage(minimalJreVersionErrorMessage);
if (doExit)
System.exit(-1);
return;
Expand All @@ -255,19 +270,6 @@ public void runMain(String[] args, boolean useSystemExit) {
AjBuildManager.enableRuntimeVersionCheck(this);
final boolean verbose = flagInArgs("-verbose", args);
final boolean timers = flagInArgs("-timers", args);
if (null == this.clientHolder) {
this.clientHolder = checkForCustomMessageHolder(args);
}
IMessageHolder holder = clientHolder;
if (null == holder) {
holder = ourHandler;
if (verbose) {
ourHandler.setInterceptor(MessagePrinter.VERBOSE);
} else {
ourHandler.ignore(IMessage.INFO);
ourHandler.setInterceptor(MessagePrinter.TERSE);
}
}

// make sure we handle out of memory gracefully...
try {
Expand Down

0 comments on commit e946a69

Please sign in to comment.