Skip to content

Commit 0765926

Browse files
committed
Enable --future-defaults=complete-reflection-types
1 parent 7bc1551 commit 0765926

File tree

4 files changed

+32
-23
lines changed

4 files changed

+32
-23
lines changed

substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/LegacyReflectionConfigurationParser.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ final class LegacyReflectionConfigurationParser<C, T> extends ReflectionConfigur
4848
super(conditionResolver, delegate, parserOptions);
4949
}
5050

51-
@Override
52-
protected EnumSet<ConfigurationParserOption> supportedOptions() {
53-
EnumSet<ConfigurationParserOption> base = super.supportedOptions();
54-
base.add(ConfigurationParserOption.TREAT_ALL_NAME_ENTRIES_AS_TYPE);
55-
return base;
56-
}
57-
5851
@Override
5952
public void parseAndRegister(Object json, URI origin) {
6053
parseClassArray(asList(json, "first level of document must be an array of class descriptors"));
@@ -64,7 +57,7 @@ public void parseAndRegister(Object json, URI origin) {
6457
protected void parseClass(EconomicMap<String, Object> data) {
6558
checkAttributes(data, "reflection class descriptor object", List.of(NAME_KEY), OPTIONAL_REFLECT_CONFIG_OBJECT_ATTRS);
6659

67-
Optional<TypeDescriptorWithOrigin> type = parseName(data, checkOption(ConfigurationParserOption.TREAT_ALL_NAME_ENTRIES_AS_TYPE));
60+
Optional<TypeDescriptorWithOrigin> type = parseName(data, true);
6861
if (type.isEmpty()) {
6962
return;
7063
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/FutureDefaultsOptions.java

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import com.oracle.svm.core.option.SubstrateOptionsParser;
4242
import com.oracle.svm.core.util.UserError;
4343
import com.oracle.svm.core.util.VMError;
44+
import com.oracle.svm.util.LogUtils;
4445
import com.oracle.svm.util.StringUtil;
4546

4647
import jdk.graal.compiler.options.Option;
@@ -79,8 +80,10 @@ public class FutureDefaultsOptions {
7980

8081
private static final String RUN_TIME_INITIALIZE_SECURITY_PROVIDERS = "run-time-initialize-security-providers";
8182
private static final String RUN_TIME_INITIALIZE_FILE_SYSTEM_PROVIDERS = "run-time-initialize-file-system-providers";
83+
private static final List<String> ALL_FUTURE_DEFAULTS = List.of(RUN_TIME_INITIALIZE_FILE_SYSTEM_PROVIDERS, RUN_TIME_INITIALIZE_SECURITY_PROVIDERS);
84+
8285
private static final String COMPLETE_REFLECTION_TYPES = "complete-reflection-types";
83-
private static final List<String> ALL_FUTURE_DEFAULTS = List.of(RUN_TIME_INITIALIZE_FILE_SYSTEM_PROVIDERS, RUN_TIME_INITIALIZE_SECURITY_PROVIDERS, COMPLETE_REFLECTION_TYPES);
86+
private static final List<String> RETIRED_FUTURE_DEFAULTS = List.of(COMPLETE_REFLECTION_TYPES);
8487

8588
public static final String RUN_TIME_INITIALIZE_FILE_SYSTEM_PROVIDERS_REASON = "Initialize JDK classes at run time (--" + OPTION_NAME + " includes " + RUN_TIME_INITIALIZE_FILE_SYSTEM_PROVIDERS +
8689
")";
@@ -140,6 +143,15 @@ public static void parseAndVerifyOptions() {
140143
getOptionHelpText());
141144
}
142145

146+
if (RETIRED_FUTURE_DEFAULTS.contains(value)) {
147+
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.",
148+
SubstrateOptionsParser.commandArgument(FutureDefaults, value),
149+
valueWithOrigin.origin(),
150+
value,
151+
VM.getVersion());
152+
return;
153+
}
154+
143155
if (!getAllValues().contains(value)) {
144156
throw UserError.abort("The '%s' option from %s contains invalid value '%s'. It can only contain: %s.%n%nUsage:%n%n%s",
145157
SubstrateOptionsParser.commandArgument(FutureDefaults, value),
@@ -169,26 +181,31 @@ public static void parseAndVerifyOptions() {
169181

170182
/* Set build-time properties for user features */
171183
for (String futureDefault : getFutureDefaults()) {
172-
System.setProperty(FutureDefaultsOptions.SYSTEM_PROPERTY_PREFIX + futureDefault, Boolean.TRUE.toString());
184+
setSystemProperty(futureDefault, true);
173185
}
186+
187+
for (String retiredFutureDefault : RETIRED_FUTURE_DEFAULTS) {
188+
setSystemProperty(retiredFutureDefault, true);
189+
}
190+
}
191+
192+
private static void setSystemProperty(String futureDefault, boolean value) {
193+
System.setProperty(FutureDefaultsOptions.SYSTEM_PROPERTY_PREFIX + futureDefault, Boolean.toString(value));
174194
}
175195

176196
public static Set<String> getFutureDefaults() {
177197
return Collections.unmodifiableSet(Objects.requireNonNull(futureDefaults, "must be initialized before usage"));
178198
}
179199

180-
/**
181-
* @see FutureDefaultsOptions#FutureDefaults
182-
*/
183-
public static boolean allFutureDefaults() {
184-
return getFutureDefaults().containsAll(ALL_FUTURE_DEFAULTS);
200+
public static List<String> getRetiredFutureDefaults() {
201+
return RETIRED_FUTURE_DEFAULTS;
185202
}
186203

187204
/**
188205
* @see FutureDefaultsOptions#FutureDefaults
189206
*/
190-
public static boolean completeReflectionTypes() {
191-
return getFutureDefaults().contains(COMPLETE_REFLECTION_TYPES);
207+
public static boolean allFutureDefaults() {
208+
return getFutureDefaults().containsAll(ALL_FUTURE_DEFAULTS);
192209
}
193210

194211
/**

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConfigurationFiles.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141

4242
import com.oracle.svm.configure.ConfigurationFile;
4343
import com.oracle.svm.configure.ConfigurationParserOption;
44-
import com.oracle.svm.core.FutureDefaultsOptions;
4544
import com.oracle.svm.core.option.AccumulatingLocatableMultiOptionValue;
4645
import com.oracle.svm.core.option.BundleMember;
4746
import com.oracle.svm.core.option.HostedOptionKey;
@@ -151,8 +150,8 @@ public static final class Options {
151150
@Option(help = "Testing flag: the 'typeReachable' condition is treated as typeReached so the semantics of programs can change.")//
152151
public static final HostedOptionKey<Boolean> TreatAllTypeReachableConditionsAsTypeReached = new HostedOptionKey<>(false);
153152

154-
@Option(help = "Testing flag: the 'name' is treated as 'type' in reflection configuration.")//
155-
public static final HostedOptionKey<Boolean> TreatAllNameEntriesAsType = new HostedOptionKey<>(false);
153+
@Option(help = "Deprecated, has no effect.", deprecated = true)//
154+
public static final HostedOptionKey<Boolean> TreatAllNameEntriesAsType = new HostedOptionKey<>(true);
156155

157156
@Option(help = "Testing flag: the 'typeReached' condition is always satisfied however it prints the stack trace where it would not be satisfied.")//
158157
public static final HostedOptionKey<Boolean> TrackUnsatisfiedTypeReachedConditions = new HostedOptionKey<>(false);
@@ -181,9 +180,6 @@ public static EnumSet<ConfigurationParserOption> getConfigurationParserOptions()
181180
if (TreatAllTypeReachableConditionsAsTypeReached.getValue()) {
182181
result.add(ConfigurationParserOption.TREAT_ALL_TYPE_REACHABLE_CONDITIONS_AS_TYPE_REACHED);
183182
}
184-
if (TreatAllNameEntriesAsType.getValue() || FutureDefaultsOptions.completeReflectionTypes()) {
185-
result.add(ConfigurationParserOption.TREAT_ALL_NAME_ENTRIES_AS_TYPE);
186-
}
187183
return result;
188184
}
189185

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SystemPropertiesSupport.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ protected SystemPropertiesSupport() {
144144
for (String futureDefault : FutureDefaultsOptions.getFutureDefaults()) {
145145
initializeProperty(FutureDefaultsOptions.SYSTEM_PROPERTY_PREFIX + futureDefault, Boolean.TRUE.toString());
146146
}
147+
for (String futureDefault : FutureDefaultsOptions.getRetiredFutureDefaults()) {
148+
initializeProperty(FutureDefaultsOptions.SYSTEM_PROPERTY_PREFIX + futureDefault, Boolean.TRUE.toString());
149+
}
147150

148151
ArrayList<LazySystemProperty> lazyProperties = new ArrayList<>();
149152
lazyProperties.add(new LazySystemProperty(UserSystemProperty.NAME, this::userNameValue));

0 commit comments

Comments
 (0)