|
36 | 36 | import java.nio.file.Path;
|
37 | 37 | import java.nio.file.Paths;
|
38 | 38 | import java.util.List;
|
| 39 | +import java.util.Set; |
39 | 40 | import java.util.UUID;
|
40 | 41 | import java.util.function.Predicate;
|
41 | 42 |
|
42 | 43 | import org.graalvm.collections.EconomicMap;
|
| 44 | +import org.graalvm.collections.EconomicSet; |
43 | 45 | import org.graalvm.collections.UnmodifiableEconomicMap;
|
44 | 46 | import org.graalvm.nativeimage.ImageInfo;
|
45 | 47 | import org.graalvm.nativeimage.ImageSingletons;
|
@@ -166,9 +168,7 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean o
|
166 | 168 | @Override
|
167 | 169 | public String getValueOrDefault(UnmodifiableEconomicMap<OptionKey<?>, Object> values) {
|
168 | 170 | if (!values.containsKey(this)) {
|
169 |
| - return Platform.includedIn(Platform.ANDROID.class) |
170 |
| - ? "bionic" |
171 |
| - : System.getProperty("substratevm.HostLibC", "glibc"); |
| 171 | + return Platform.includedIn(Platform.ANDROID.class) ? "bionic" : System.getProperty("substratevm.HostLibC", "glibc"); |
172 | 172 | }
|
173 | 173 | return (String) values.get(this);
|
174 | 174 | }
|
@@ -884,9 +884,8 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, String ol
|
884 | 884 | isLLVMBackendMissing = ReflectionUtil.lookupClass(true, "com.oracle.svm.core.graal.llvm.LLVMFeature") == null;
|
885 | 885 | }
|
886 | 886 | if (isLLVMBackendMissing) {
|
887 |
| - throw UserError.invalidOptionValue(CompilerBackend, newValue, |
888 |
| - "The LLVM backend for GraalVM Native Image is missing and needs to be built from source. " + |
889 |
| - "For instructions, please see https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/LLVMBackend.md."); |
| 887 | + throw UserError.invalidOptionValue(CompilerBackend, newValue, "The LLVM backend for GraalVM Native Image is missing and needs to be built from source. " + |
| 888 | + "For instructions, please see https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/LLVMBackend.md."); |
890 | 889 | }
|
891 | 890 |
|
892 | 891 | /* See GR-14405, https://github.com/oracle/graal/issues/1056 */
|
@@ -1277,6 +1276,10 @@ public Boolean getValueOrDefault(UnmodifiableEconomicMap<OptionKey<?>, Object> v
|
1277 | 1276 | deprecated = true, deprecationMessage = "This option was introduced to simplify migration to GraalVM 23.0 and will be removed in a future release")//
|
1278 | 1277 | public static final HostedOptionKey<Boolean> AllowDeprecatedBuilderClassesOnImageClasspath = new HostedOptionKey<>(false);
|
1279 | 1278 |
|
| 1279 | + @Option(help = "Initialize JDK classes at build time the same way it was done before GraalVM 25.", type = OptionType.Debug, // |
| 1280 | + deprecated = true, deprecationMessage = "This option was introduced to simplify migration to GraalVM 25 and will be removed in a future release")// |
| 1281 | + public static final HostedOptionKey<Boolean> InitializeJDKAtBuildTimeMigration = new HostedOptionKey<>(false); |
| 1282 | + |
1280 | 1283 | @APIOption(name = "exact-reachability-metadata", defaultValue = "")//
|
1281 | 1284 | @Option(help = "file:doc-files/ExactReachabilityMetadataHelp.txt")//
|
1282 | 1285 | public static final HostedOptionKey<AccumulatingLocatableMultiOptionValue.Strings> ThrowMissingRegistrationErrors = new HostedOptionKey<>(AccumulatingLocatableMultiOptionValue.Strings.build());
|
@@ -1381,4 +1384,63 @@ public static class TruffleStableOptions {
|
1381 | 1384 |
|
1382 | 1385 | @Option(help = "file:doc-files/LibGraalClassLoader.txt")//
|
1383 | 1386 | public static final HostedOptionKey<String> LibGraalClassLoader = new HostedOptionKey<>("");
|
| 1387 | + |
| 1388 | + private static final String FUTURE_DEFAULTS_OPTION = "future-defaults"; |
| 1389 | + |
| 1390 | + private static final String FUTURE_DEFAULTS_ALL_NAME = "all"; |
| 1391 | + private static final String FUTURE_DEFAULTS_NONE_NAME = "none"; |
| 1392 | + private static final String FUTURE_DEFAULTS_RUN_TIME_INITIALIZE_JDK_NAME = "run-time-initialized-jdk"; |
| 1393 | + |
| 1394 | + private static final Set<String> FUTURE_DEFAULTS_ALL_VALUES = Set.of(FUTURE_DEFAULTS_RUN_TIME_INITIALIZE_JDK_NAME, FUTURE_DEFAULTS_ALL_NAME, FUTURE_DEFAULTS_NONE_NAME); |
| 1395 | + private static final String FUTURE_DEFAULTS_ALLOWED_VALUES_TEXT = "'" + FUTURE_DEFAULTS_ALL_NAME + "'" + |
| 1396 | + ", '" + FUTURE_DEFAULTS_RUN_TIME_INITIALIZE_JDK_NAME + "'" + |
| 1397 | + ", or '" + FUTURE_DEFAULTS_NONE_NAME + "'"; |
| 1398 | + |
| 1399 | + static { |
| 1400 | + assert FUTURE_DEFAULTS_ALL_VALUES.stream().allMatch(FUTURE_DEFAULTS_ALLOWED_VALUES_TEXT::contains) : "A value is missing in the user-facing help text"; |
| 1401 | + } |
| 1402 | + |
| 1403 | + @APIOption(name = FUTURE_DEFAULTS_OPTION, defaultValue = FUTURE_DEFAULTS_NONE_NAME) // |
| 1404 | + @Option(help = "Enable the future default behaviors for Native Image. Comma-separated list can contain " + FUTURE_DEFAULTS_ALLOWED_VALUES_TEXT + ". " + |
| 1405 | + "For example: '--" + FUTURE_DEFAULTS_OPTION + "=" + FUTURE_DEFAULTS_ALL_NAME + "'.", type = OptionType.User) // |
| 1406 | + public static final HostedOptionKey<AccumulatingLocatableMultiOptionValue.Strings> FutureDefaults = new HostedOptionKey<>( |
| 1407 | + AccumulatingLocatableMultiOptionValue.Strings.buildWithCommaDelimiter(), |
| 1408 | + SubstrateOptions::validateFutureDefaults) { |
| 1409 | + @Override |
| 1410 | + protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, AccumulatingLocatableMultiOptionValue.Strings oldValue, AccumulatingLocatableMultiOptionValue.Strings newValue) { |
| 1411 | + super.onValueUpdate(values, oldValue, newValue); |
| 1412 | + } |
| 1413 | + }; |
| 1414 | + |
| 1415 | + private static EconomicSet<String> futureDefaults; |
| 1416 | + |
| 1417 | + @Platforms(Platform.HOSTED_ONLY.class) |
| 1418 | + public static void validateFutureDefaults(HostedOptionKey<AccumulatingLocatableMultiOptionValue.Strings> optionKey) { |
| 1419 | + futureDefaults = EconomicSet.create(FUTURE_DEFAULTS_ALL_VALUES.size()); |
| 1420 | + var valuesWithOrigin = optionKey.getValue().getValuesWithOrigins(); |
| 1421 | + valuesWithOrigin.forEach(valueWithOrigin -> { |
| 1422 | + String value = valueWithOrigin.value(); |
| 1423 | + if (!FUTURE_DEFAULTS_ALL_VALUES.contains(value)) { |
| 1424 | + throw UserError.abort("The '%s' option from %s contains invalid value '%s'. It can only contain: %s.", |
| 1425 | + SubstrateOptionsParser.commandArgument(FutureDefaults, value), |
| 1426 | + valueWithOrigin.origin(), |
| 1427 | + value, |
| 1428 | + FUTURE_DEFAULTS_ALLOWED_VALUES_TEXT); |
| 1429 | + } |
| 1430 | + if (value.equals(FUTURE_DEFAULTS_NONE_NAME)) { |
| 1431 | + if (!valueWithOrigin.origin().commandLineLike()) { |
| 1432 | + throw UserError.abort("The '%s' option can only be used from the command line. Detected usage from %s.", |
| 1433 | + SubstrateOptionsParser.commandArgument(FutureDefaults, FUTURE_DEFAULTS_NONE_NAME), |
| 1434 | + valueWithOrigin.origin()); |
| 1435 | + } |
| 1436 | + futureDefaults.clear(); |
| 1437 | + } |
| 1438 | + |
| 1439 | + futureDefaults.add(value); |
| 1440 | + }); |
| 1441 | + } |
| 1442 | + |
| 1443 | + public boolean isJDKInitializedAtRunTime() { |
| 1444 | + return futureDefaults.contains(FUTURE_DEFAULTS_ALL_NAME) || futureDefaults.contains(FUTURE_DEFAULTS_RUN_TIME_INITIALIZE_JDK_NAME); |
| 1445 | + } |
1384 | 1446 | }
|
0 commit comments