|
30 | 30 | import java.util.Objects; |
31 | 31 | import java.util.Set; |
32 | 32 | import java.util.stream.Collectors; |
| 33 | +import java.util.stream.Stream; |
33 | 34 |
|
34 | 35 | import org.graalvm.collections.EconomicMap; |
35 | 36 | import org.graalvm.nativeimage.ImageInfo; |
|
40 | 41 | import com.oracle.svm.core.option.APIOption; |
41 | 42 | import com.oracle.svm.core.option.AccumulatingLocatableMultiOptionValue; |
42 | 43 | import com.oracle.svm.core.option.HostedOptionKey; |
| 44 | +import com.oracle.svm.core.option.LocatableMultiOptionValue; |
43 | 45 | import com.oracle.svm.core.option.SubstrateOptionsParser; |
44 | 46 | import com.oracle.svm.core.util.UserError; |
45 | 47 | import com.oracle.svm.core.util.VMError; |
@@ -116,8 +118,7 @@ private static LinkedHashSet<String> getAllValues() { |
116 | 118 | @Override |
117 | 119 | protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, AccumulatingLocatableMultiOptionValue.Strings oldValue, AccumulatingLocatableMultiOptionValue.Strings newValue) { |
118 | 120 | super.onValueUpdate(values, oldValue, newValue); |
119 | | - /* temporary simple pwdctest, will do full parsing */ |
120 | | - if (newValue.values().contains("all") || newValue.values().contains(CLASS_FOR_NAME_RESPECTS_CLASS_LOADER)) { |
| 121 | + if (computeFutureDefaults(newValue.getValuesWithOrigins()).contains(CLASS_FOR_NAME_RESPECTS_CLASS_LOADER)) { |
121 | 122 | ClassForNameSupport.Options.ClassForNameRespectsClassLoader.update(values, true); |
122 | 123 | } |
123 | 124 | } |
@@ -154,8 +155,20 @@ private static void verifyOptionDescription() { |
154 | 155 | @Platforms(Platform.HOSTED_ONLY.class) |
155 | 156 | public static void parseAndVerifyOptions() { |
156 | 157 | verifyOptionDescription(); |
157 | | - futureDefaults = new LinkedHashSet<>(getAllValues().size()); |
158 | 158 | var valuesWithOrigin = FutureDefaults.getValue().getValuesWithOrigins(); |
| 159 | + futureDefaults = computeFutureDefaults(valuesWithOrigin); |
| 160 | + /* Set build-time properties for user features */ |
| 161 | + for (String futureDefault : getFutureDefaults()) { |
| 162 | + setSystemProperty(futureDefault); |
| 163 | + } |
| 164 | + |
| 165 | + for (String retiredFutureDefault : RETIRED_FUTURE_DEFAULTS) { |
| 166 | + setSystemProperty(retiredFutureDefault); |
| 167 | + } |
| 168 | + } |
| 169 | + |
| 170 | + private static LinkedHashSet<String> computeFutureDefaults(Stream<LocatableMultiOptionValue.ValueWithOrigin<String>> valuesWithOrigin) { |
| 171 | + LinkedHashSet<String> result = new LinkedHashSet<>(); |
159 | 172 | valuesWithOrigin.forEach(valueWithOrigin -> { |
160 | 173 | String value = valueWithOrigin.value(); |
161 | 174 | if (DEFAULT_NAME.equals(value)) { |
@@ -190,26 +203,18 @@ public static void parseAndVerifyOptions() { |
190 | 203 | SubstrateOptionsParser.commandArgument(FutureDefaults, NONE_NAME), |
191 | 204 | valueWithOrigin.origin()); |
192 | 205 | } |
193 | | - futureDefaults.clear(); |
| 206 | + result.clear(); |
194 | 207 | } |
195 | 208 |
|
196 | 209 | if (value.equals(ALL_NAME)) { |
197 | | - futureDefaults.addAll(ALL_FUTURE_DEFAULTS); |
| 210 | + result.addAll(ALL_FUTURE_DEFAULTS); |
198 | 211 | } else if (value.equals(RUN_TIME_INITIALIZE_JDK)) { |
199 | | - futureDefaults.addAll(List.of(RUN_TIME_INITIALIZE_SECURITY_PROVIDERS, RUN_TIME_INITIALIZE_FILE_SYSTEM_PROVIDERS, RUN_TIME_INITIALIZE_RESOURCE_BUNDLES)); |
| 212 | + result.addAll(List.of(RUN_TIME_INITIALIZE_SECURITY_PROVIDERS, RUN_TIME_INITIALIZE_FILE_SYSTEM_PROVIDERS, RUN_TIME_INITIALIZE_RESOURCE_BUNDLES)); |
200 | 213 | } else { |
201 | | - futureDefaults.add(value); |
| 214 | + result.add(value); |
202 | 215 | } |
203 | 216 | }); |
204 | | - |
205 | | - /* Set build-time properties for user features */ |
206 | | - for (String futureDefault : getFutureDefaults()) { |
207 | | - setSystemProperty(futureDefault); |
208 | | - } |
209 | | - |
210 | | - for (String retiredFutureDefault : RETIRED_FUTURE_DEFAULTS) { |
211 | | - setSystemProperty(retiredFutureDefault); |
212 | | - } |
| 217 | + return result; |
213 | 218 | } |
214 | 219 |
|
215 | 220 | private static void setSystemProperty(String futureDefault) { |
|
0 commit comments