|
24 | 24 | */
|
25 | 25 | package com.oracle.svm.hosted.classinitialization;
|
26 | 26 |
|
27 |
| -import static com.oracle.svm.hosted.NativeImageOptions.DiagnosticsMode; |
28 |
| - |
29 | 27 | import java.util.Arrays;
|
30 | 28 | import java.util.Optional;
|
31 | 29 | import java.util.function.Consumer;
|
32 | 30 |
|
33 | 31 | import org.graalvm.collections.Pair;
|
34 | 32 |
|
35 | 33 | import com.oracle.svm.core.option.OptionOrigin;
|
| 34 | +import com.oracle.svm.core.option.SubstrateOptionsParser; |
| 35 | +import com.oracle.svm.core.util.UserError; |
36 | 36 |
|
37 | 37 | /**
|
38 | 38 | * The initialization kind for a class. The order of the enum values matters, {@link #max} depends
|
@@ -71,12 +71,17 @@ Consumer<String> stringConsumer(ClassInitializationSupport support, OptionOrigin
|
71 | 71 | return name -> support.rerunInitialization(name, reason(origin, name));
|
72 | 72 | } else {
|
73 | 73 | return name -> {
|
74 |
| - if (name.equals("") && !DiagnosticsMode.getValue()) { |
75 |
| - System.err.println( |
76 |
| - "--initialize-at-build-time without arguments has been deprecated when not using --diagnostics-mode. With GraalVM 22.0.0" + |
77 |
| - " --initialize-at-build-time will only work with --diagnostics-mode for debugging purposes.\n" + |
78 |
| - "The reason for deprecation is that --initalize-at-build-time does not compose, i.e., a single library can make assumptions that the whole classpath can be safely initialized at build time;" + |
79 |
| - " that assumption is often incorrect."); |
| 74 | + if (name.equals("") && !origin.commandLineLike()) { |
| 75 | + String msg = "--initialize-at-build-time without arguments is not allowed." + System.lineSeparator() + |
| 76 | + "Origin of the option: " + origin + System.lineSeparator() + |
| 77 | + "The reason for deprecation is that --initalize-at-build-time does not compose, i.e., a single library can make assumptions that the whole classpath can be safely initialized at build time;" + |
| 78 | + " that assumption is often incorrect."; |
| 79 | + if (ClassInitializationOptions.AllowDeprecatedInitializeAllClassesAtBuildTime.getValue()) { |
| 80 | + System.err.println("Warning: " + msg); |
| 81 | + } else { |
| 82 | + throw UserError.abort("%s%nAs a temporary workaround, %s allows turning this error into a warning.", msg, |
| 83 | + SubstrateOptionsParser.commandArgument(ClassInitializationOptions.AllowDeprecatedInitializeAllClassesAtBuildTime, "+")); |
| 84 | + } |
80 | 85 | }
|
81 | 86 | support.initializeAtBuildTime(name, reason(origin, name));
|
82 | 87 | };
|
|
0 commit comments