Skip to content

Commit 02d3b78

Browse files
committed
[GR-55047] Only mention image-layer in error message when option is enabled.
PullRequest: graal/18300
2 parents 0c14a6e + 454b6ad commit 02d3b78

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGeneratorRunner.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import com.oracle.svm.core.JavaMainWrapper.JavaMainSupport;
6363
import com.oracle.svm.core.OS;
6464
import com.oracle.svm.core.SubstrateOptions;
65+
import com.oracle.svm.core.option.HostedOptionKey;
6566
import com.oracle.svm.core.option.SubstrateOptionsParser;
6667
import com.oracle.svm.core.util.ExitStatus;
6768
import com.oracle.svm.core.util.InterruptImageBuilding;
@@ -393,13 +394,16 @@ private int buildImage(ImageClassLoader classLoader) {
393394
Pair<Method, CEntryPointData> mainEntryPointData = Pair.empty();
394395
JavaMainSupport javaMainSupport = null;
395396

396-
NativeImageKind imageKind;
397+
NativeImageKind imageKind = null;
397398
boolean isStaticExecutable = SubstrateOptions.StaticExecutable.getValue(parsedHostedOptions);
398399
boolean isSharedLibrary = SubstrateOptions.SharedLibrary.getValue(parsedHostedOptions);
399400
boolean isImageLayer = SubstrateOptions.ImageLayer.getValue(parsedHostedOptions);
400-
if ((isStaticExecutable && isSharedLibrary) || (isStaticExecutable && isImageLayer) || (isSharedLibrary && isImageLayer)) {
401-
throw UserError.abort("Cannot pass multiple options: %s, %s, %s", SubstrateOptionsParser.commandArgument(SubstrateOptions.SharedLibrary, "+"),
402-
SubstrateOptionsParser.commandArgument(SubstrateOptions.StaticExecutable, "+"), SubstrateOptionsParser.commandArgument(SubstrateOptions.ImageLayer, "+"));
401+
if (isStaticExecutable && isSharedLibrary) {
402+
reportConflictingOptions(SubstrateOptions.SharedLibrary, SubstrateOptions.StaticExecutable);
403+
} else if (isStaticExecutable && isImageLayer) {
404+
reportConflictingOptions(SubstrateOptions.StaticExecutable, SubstrateOptions.ImageLayer);
405+
} else if (isSharedLibrary && isImageLayer) {
406+
reportConflictingOptions(SubstrateOptions.SharedLibrary, SubstrateOptions.ImageLayer);
403407
} else if (isSharedLibrary) {
404408
imageKind = NativeImageKind.SHARED_LIBRARY;
405409
} else if (isImageLayer) {
@@ -583,6 +587,10 @@ private int buildImage(ImageClassLoader classLoader) {
583587
return ExitStatus.OK.getValue();
584588
}
585589

590+
private static void reportConflictingOptions(HostedOptionKey<Boolean> o1, HostedOptionKey<Boolean> o2) {
591+
throw UserError.abort("Cannot pass both options: %s and %s", SubstrateOptionsParser.commandArgument(o1, "+"), SubstrateOptionsParser.commandArgument(o2, "+"));
592+
}
593+
586594
protected void reportEpilog(String imageName, ProgressReporter reporter, ImageClassLoader classLoader, boolean wasSuccessfulBuild, Throwable unhandledThrowable, OptionValues parsedHostedOptions) {
587595
reporter.printEpilog(Optional.ofNullable(imageName), Optional.ofNullable(generator), classLoader, wasSuccessfulBuild, Optional.ofNullable(unhandledThrowable), parsedHostedOptions);
588596
}

0 commit comments

Comments
 (0)