2424 */
2525package com .oracle .svm .core ;
2626
27+ import java .util .Collections ;
28+ import java .util .LinkedHashSet ;
29+ import java .util .List ;
30+ import java .util .Objects ;
31+ import java .util .Set ;
32+ import java .util .stream .Collectors ;
33+
34+ import org .graalvm .collections .EconomicMap ;
35+ import org .graalvm .nativeimage .ImageInfo ;
36+ import org .graalvm .nativeimage .Platform ;
37+ import org .graalvm .nativeimage .Platforms ;
38+
2739import com .oracle .svm .core .hub .ClassForNameSupport ;
2840import com .oracle .svm .core .option .APIOption ;
2941import com .oracle .svm .core .option .AccumulatingLocatableMultiOptionValue ;
3345import com .oracle .svm .core .util .VMError ;
3446import com .oracle .svm .util .LogUtils ;
3547import com .oracle .svm .util .StringUtil ;
48+
3649import jdk .graal .compiler .options .Option ;
3750import jdk .graal .compiler .options .OptionKey ;
3851import jdk .graal .compiler .options .OptionType ;
39- import org .graalvm .collections .EconomicMap ;
40- import org .graalvm .nativeimage .ImageInfo ;
41- import org .graalvm .nativeimage .Platform ;
42- import org .graalvm .nativeimage .Platforms ;
43-
44- import java .util .Collections ;
45- import java .util .LinkedHashSet ;
46- import java .util .List ;
47- import java .util .Objects ;
48- import java .util .Set ;
49- import java .util .stream .Collectors ;
5052
5153/**
5254 * Enables the --future-defaults=value flag that is used for evolution of Native Image semantics.
@@ -83,13 +85,14 @@ public class FutureDefaultsOptions {
8385 private static final String RUN_TIME_INITIALIZE_FILE_SYSTEM_PROVIDERS = "run-time-initialize-file-system-providers" ;
8486 private static final String RUN_TIME_INITIALIZE_RESOURCE_BUNDLES = "run-time-initialize-resource-bundles" ;
8587 private static final String CLASS_FOR_NAME_RESPECTS_CLASS_LOADER = "class-for-name-respects-class-loader" ;
86- private static final List <String > ALL_FUTURE_DEFAULTS = List .of (CLASS_FOR_NAME_RESPECTS_CLASS_LOADER , RUN_TIME_INITIALIZE_FILE_SYSTEM_PROVIDERS , RUN_TIME_INITIALIZE_SECURITY_PROVIDERS , RUN_TIME_INITIALIZE_RESOURCE_BUNDLES );
88+ private static final List <String > ALL_FUTURE_DEFAULTS = List .of (CLASS_FOR_NAME_RESPECTS_CLASS_LOADER , RUN_TIME_INITIALIZE_FILE_SYSTEM_PROVIDERS , RUN_TIME_INITIALIZE_SECURITY_PROVIDERS ,
89+ RUN_TIME_INITIALIZE_RESOURCE_BUNDLES );
8790
8891 private static final String COMPLETE_REFLECTION_TYPES = "complete-reflection-types" ;
8992 private static final List <String > RETIRED_FUTURE_DEFAULTS = List .of (COMPLETE_REFLECTION_TYPES );
9093
9194 public static final String RUN_TIME_INITIALIZE_FILE_SYSTEM_PROVIDERS_REASON = "Initialize JDK classes at run time (--" + OPTION_NAME + " includes " + CLASS_FOR_NAME_RESPECTS_CLASS_LOADER +
92- ")" ;
95+ ")" ;
9396 public static final String RUN_TIME_INITIALIZE_SECURITY_PROVIDERS_REASON = "Initialize JDK classes at run time (--" + OPTION_NAME + " includes " + RUN_TIME_INITIALIZE_SECURITY_PROVIDERS + ")" ;
9497 public static final String RUN_TIME_INITIALIZE_RESOURCE_BUNDLES_REASON = "Initialize JDK classes at run time (--" + OPTION_NAME + " includes " + RUN_TIME_INITIALIZE_RESOURCE_BUNDLES + ")" ;
9598 private static final String DEFAULT_NAME = "<default-value>" ;
@@ -109,7 +112,7 @@ private static LinkedHashSet<String> getAllValues() {
109112 @ APIOption (name = OPTION_NAME , defaultValue = DEFAULT_NAME ) //
110113 @ Option (help = "file:doc-files/FutureDefaultsHelp.txt" , type = OptionType .User ) //
111114 static final HostedOptionKey <AccumulatingLocatableMultiOptionValue .Strings > FutureDefaults = new HostedOptionKey <>(
112- AccumulatingLocatableMultiOptionValue .Strings .buildWithCommaDelimiter ()) {
115+ AccumulatingLocatableMultiOptionValue .Strings .buildWithCommaDelimiter ()) {
113116 @ Override
114117 protected void onValueUpdate (EconomicMap <OptionKey <?>, Object > values , AccumulatingLocatableMultiOptionValue .Strings oldValue , AccumulatingLocatableMultiOptionValue .Strings newValue ) {
115118 super .onValueUpdate (values , oldValue , newValue );
@@ -123,7 +126,7 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Accumulat
123126 private static String getOptionHelpText () {
124127 Objects .requireNonNull (FutureDefaultsOptions .FutureDefaults .getDescriptor (), "This must be called after the options are processed." );
125128 return FutureDefaultsOptions .FutureDefaults .getDescriptor ().getHelp ().stream ()
126- .collect (Collectors .joining (System .lineSeparator ()));
129+ .collect (Collectors .joining (System .lineSeparator ()));
127130 }
128131
129132 private static void verifyOptionDescription () {
@@ -157,35 +160,35 @@ public static void parseAndVerifyOptions() {
157160 String value = valueWithOrigin .value ();
158161 if (DEFAULT_NAME .equals (value )) {
159162 throw UserError .abort ("The '%s' from %s is forbidden. It can only contain: %s.%n%nUsage:%n%n%s" ,
160- SubstrateOptionsParser .commandArgument (FutureDefaults , DEFAULT_NAME ),
161- valueWithOrigin .origin (),
162- futureDefaultsAllValues (),
163- getOptionHelpText ());
163+ SubstrateOptionsParser .commandArgument (FutureDefaults , DEFAULT_NAME ),
164+ valueWithOrigin .origin (),
165+ futureDefaultsAllValues (),
166+ getOptionHelpText ());
164167 }
165168
166169 if (RETIRED_FUTURE_DEFAULTS .contains (value )) {
167170 LogUtils .warning ("The '%s' option from %s contains the value '%s' which is enabled by default in this GraalVM release (%s) and can be removed." ,
168- SubstrateOptionsParser .commandArgument (FutureDefaults , value ),
169- valueWithOrigin .origin (),
170- value ,
171- VM .getVersion ());
171+ SubstrateOptionsParser .commandArgument (FutureDefaults , value ),
172+ valueWithOrigin .origin (),
173+ value ,
174+ VM .getVersion ());
172175 return ;
173176 }
174177
175178 if (!getAllValues ().contains (value )) {
176179 throw UserError .abort ("The '%s' option from %s contains invalid value '%s'. It can only contain: %s.%n%nUsage:%n%n%s" ,
177- SubstrateOptionsParser .commandArgument (FutureDefaults , value ),
178- valueWithOrigin .origin (),
179- value ,
180- futureDefaultsAllValues (),
181- getOptionHelpText ());
180+ SubstrateOptionsParser .commandArgument (FutureDefaults , value ),
181+ valueWithOrigin .origin (),
182+ value ,
183+ futureDefaultsAllValues (),
184+ getOptionHelpText ());
182185 }
183186
184187 if (value .equals (NONE_NAME )) {
185188 if (!valueWithOrigin .origin ().commandLineLike ()) {
186189 throw UserError .abort ("The '%s' option can only be used from the command line. Detected usage from %s." ,
187- SubstrateOptionsParser .commandArgument (FutureDefaults , NONE_NAME ),
188- valueWithOrigin .origin ());
190+ SubstrateOptionsParser .commandArgument (FutureDefaults , NONE_NAME ),
191+ valueWithOrigin .origin ());
189192 }
190193 futureDefaults .clear ();
191194 }
0 commit comments