Skip to content

Commit 66c5f66

Browse files
committed
[GR-49932] Introduce OptionMigrationMessage.
PullRequest: graal/17242
2 parents 71adbb3 + 1941e24 commit 66c5f66

File tree

11 files changed

+108
-60
lines changed

11 files changed

+108
-60
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import com.oracle.svm.core.option.HostedOptionKey;
5555
import com.oracle.svm.core.option.HostedOptionValues;
5656
import com.oracle.svm.core.option.LocatableMultiOptionValue;
57+
import com.oracle.svm.core.option.OptionMigrationMessage;
5758
import com.oracle.svm.core.option.RuntimeOptionKey;
5859
import com.oracle.svm.core.option.SubstrateOptionsParser;
5960
import com.oracle.svm.core.thread.VMOperationControl;
@@ -337,7 +338,8 @@ public static void setOptimizeValueUpdateHandler(ValueUpdateHandler<Optimization
337338
@Option(help = "Path passed to the linker as the -rpath (list of comma-separated directories)")//
338339
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> LinkerRPath = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
339340

340-
@Option(help = {"Directory of the image file to be generated", "Use the '-o' option instead."}, type = OptionType.User)//
341+
@OptionMigrationMessage("Use the '-o' option instead.")//
342+
@Option(help = "Directory of the image file to be generated", type = OptionType.User)//
341343
public static final HostedOptionKey<String> Path = new HostedOptionKey<>(null);
342344

343345
public static final class GCGroup implements APIOptionGroup {

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

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,75 +34,76 @@
3434
import java.util.stream.Collectors;
3535
import java.util.stream.Stream;
3636

37-
import jdk.graal.compiler.options.Option;
38-
import jdk.graal.compiler.options.OptionStability;
39-
import jdk.graal.compiler.options.OptionType;
40-
4137
import com.oracle.svm.core.option.BundleMember;
4238
import com.oracle.svm.core.option.HostedOptionKey;
4339
import com.oracle.svm.core.option.LocatableMultiOptionValue;
40+
import com.oracle.svm.core.option.OptionMigrationMessage;
4441
import com.oracle.svm.core.util.UserError;
4542

43+
import jdk.graal.compiler.options.Option;
44+
import jdk.graal.compiler.options.OptionStability;
45+
import jdk.graal.compiler.options.OptionType;
46+
4647
/**
4748
* Gathers configuration files from specified directories without having to provide each
4849
* configuration file individually.
4950
*/
5051
public final class ConfigurationFiles {
5152

5253
public static final class Options {
54+
5355
@Option(help = "Directories directly containing configuration files for dynamic features at runtime.", type = OptionType.User, stability = OptionStability.STABLE)//
5456
@BundleMember(role = BundleMember.Role.Input)//
5557
static final HostedOptionKey<LocatableMultiOptionValue.Paths> ConfigurationFileDirectories = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
5658

5759
@Option(help = "Resource path above configuration resources for dynamic features at runtime.", type = OptionType.User)//
5860
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> ConfigurationResourceRoots = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
5961

62+
@OptionMigrationMessage("Use a reflect-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead.")//
6063
@Option(help = "file:doc-files/ReflectionConfigurationFilesHelp.txt", type = OptionType.User)//
6164
@BundleMember(role = BundleMember.Role.Input)//
6265
public static final HostedOptionKey<LocatableMultiOptionValue.Paths> ReflectionConfigurationFiles = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
63-
@Option(help = {"Resources describing program elements to be made available for reflection (see ReflectionConfigurationFiles).",
64-
"Use a reflect-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead."}, type = OptionType.User)//
66+
@Option(help = "Resources describing program elements to be made available for reflection (see ReflectionConfigurationFiles).", type = OptionType.User)//
6567
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> ReflectionConfigurationResources = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
6668

69+
@OptionMigrationMessage("Use a proxy-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead.")//
6770
@Option(help = "file:doc-files/ProxyConfigurationFilesHelp.txt", type = OptionType.User)//
6871
@BundleMember(role = BundleMember.Role.Input)//
6972
public static final HostedOptionKey<LocatableMultiOptionValue.Paths> DynamicProxyConfigurationFiles = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
70-
@Option(help = {"Resources describing program elements to be made available for reflection (see ProxyConfigurationFiles).",
71-
"Use a proxy-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead."}, type = OptionType.User)//
73+
@Option(help = "Resources describing program elements to be made available for reflection (see ProxyConfigurationFiles).", type = OptionType.User)//
7274
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> DynamicProxyConfigurationResources = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
7375

76+
@OptionMigrationMessage("Use a serialization-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead.")//
7477
@Option(help = "file:doc-files/SerializationConfigurationFilesHelp.txt", type = OptionType.User)//
7578
@BundleMember(role = BundleMember.Role.Input)//
7679
public static final HostedOptionKey<LocatableMultiOptionValue.Paths> SerializationConfigurationFiles = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
77-
@Option(help = {"Resources describing program elements to be made available for serialization (see SerializationConfigurationFiles).",
78-
"Use a serialization-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead."}, type = OptionType.User)//
80+
@Option(help = "Resources describing program elements to be made available for serialization (see SerializationConfigurationFiles).", type = OptionType.User)//
7981
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> SerializationConfigurationResources = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
8082

83+
@OptionMigrationMessage("Use a serialization-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead.")//
8184
@Option(help = "file:doc-files/SerializationConfigurationFilesHelp.txt", type = OptionType.User)//
8285
@BundleMember(role = BundleMember.Role.Input)//
8386
public static final HostedOptionKey<LocatableMultiOptionValue.Paths> SerializationDenyConfigurationFiles = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
8487
@Option(help = "Resources describing program elements that must not be made available for serialization.", type = OptionType.User)//
8588
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> SerializationDenyConfigurationResources = new HostedOptionKey<>(
8689
LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
8790

88-
@Option(help = {"Files describing Java resources to be included in the image according to the schema at " +
89-
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/resource-config-schema-v1.0.0.json",
90-
"Use a resource-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead."}, type = OptionType.User)//
91+
@OptionMigrationMessage("Use a resource-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead.")//
92+
@Option(help = "Files describing Java resources to be included in the image according to the schema at " +
93+
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/resource-config-schema-v1.0.0.json", type = OptionType.User)//
9194
@BundleMember(role = BundleMember.Role.Input)//
9295
public static final HostedOptionKey<LocatableMultiOptionValue.Paths> ResourceConfigurationFiles = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
93-
@Option(help = {"Resources describing Java resources to be included in the image according to the schema at " +
94-
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/resource-config-schema-v1.0.0.json",
95-
"Use a resource-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead."}, type = OptionType.User)//
96+
@Option(help = "Resources describing Java resources to be included in the image according to the schema at " +
97+
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/resource-config-schema-v1.0.0.json", type = OptionType.User)//
9698
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> ResourceConfigurationResources = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
9799

98-
@Option(help = {"Files describing program elements to be made accessible via JNI according to the schema at " +
99-
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/jni-config-schema-v1.1.0.json",
100-
"Use a jni-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead."}, type = OptionType.User)//
100+
@OptionMigrationMessage("Use a jni-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead.")//
101+
@Option(help = "Files describing program elements to be made accessible via JNI according to the schema at " +
102+
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/jni-config-schema-v1.1.0.json", type = OptionType.User)//
101103
@BundleMember(role = BundleMember.Role.Input)//
102104
public static final HostedOptionKey<LocatableMultiOptionValue.Paths> JNIConfigurationFiles = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
103-
@Option(help = {"Resources describing program elements to be made accessible via JNI according to the schema at " +
104-
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/jni-config-schema-v1.1.0.json",
105-
"Use a jni-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead."}, type = OptionType.User)//
105+
@Option(help = "Resources describing program elements to be made accessible via JNI according to the schema at " +
106+
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/jni-config-schema-v1.1.0.json", type = OptionType.User)//
106107
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> JNIConfigurationResources = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
107108

108109
@Option(help = "Files describing stubs allowing foreign calls.", type = OptionType.User)//
@@ -111,14 +112,13 @@ public static final class Options {
111112
@Option(help = "Resources describing stubs allowing foreign calls.", type = OptionType.User)//
112113
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> ForeignResources = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
113114

114-
@Option(help = {"Files describing predefined classes that can be loaded at runtime according to the schema at " +
115-
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/predefined-classes-config-schema-v1.0.0.json",
116-
"Use a predefined-classes-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead."}, type = OptionType.User)//
115+
@OptionMigrationMessage("Use a predefined-classes-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead.")//
116+
@Option(help = "Files describing predefined classes that can be loaded at runtime according to the schema at " +
117+
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/predefined-classes-config-schema-v1.0.0.json", type = OptionType.User)//
117118
@BundleMember(role = BundleMember.Role.Input)//
118119
public static final HostedOptionKey<LocatableMultiOptionValue.Paths> PredefinedClassesConfigurationFiles = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
119-
@Option(help = {"Resources describing predefined classes that can be loaded at runtime according to the schema at " +
120-
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/predefined-classes-config-schema-v1.0.0.json",
121-
"Use a predefined-classes-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead."}, type = OptionType.User)//
120+
@Option(help = "Resources describing predefined classes that can be loaded at runtime according to the schema at " +
121+
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/predefined-classes-config-schema-v1.0.0.json", type = OptionType.User)//
122122
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> PredefinedClassesConfigurationResources = new HostedOptionKey<>(
123123
LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
124124

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/doc-files/ProxyConfigurationFilesHelp.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
One or several (comma-separated) paths to JSON files that specify lists of interfaces that define Java proxy classes.
2-
Use a proxy-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead.
32

43
The JSON structure is described in the following schema:
54

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/doc-files/ReflectionConfigurationFilesHelp.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
One or several (comma-separated) paths to JSON files that specify which program elements should be made available via reflection.
2-
Use a reflect-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead.
32

43
The JSON object schema is described at:
54

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/doc-files/SerializationConfigurationFilesHelp.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
One or several (comma-separated) paths to JSON files that specify lists of serialization configurations.
2-
Use a serialization-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead.
32

43
The structure is described in the following schema:
54

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
26+
package com.oracle.svm.core.option;
27+
28+
import java.lang.annotation.ElementType;
29+
import java.lang.annotation.Retention;
30+
import java.lang.annotation.RetentionPolicy;
31+
import java.lang.annotation.Target;
32+
33+
import jdk.graal.compiler.options.Option;
34+
35+
/**
36+
* If an {@link Option} is additionally annotated with {@link OptionMigrationMessage}, the message
37+
* will be shown to guide users when the option is listed as experimental in the build output.
38+
*/
39+
@Retention(RetentionPolicy.RUNTIME)
40+
@Target({ElementType.FIELD})
41+
public @interface OptionMigrationMessage {
42+
String value();
43+
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/OptionUtils.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
2525
package com.oracle.svm.core.option;
2626

2727
import java.io.IOException;
28+
import java.lang.annotation.Annotation;
29+
import java.lang.reflect.Field;
2830
import java.nio.file.Path;
2931
import java.util.Arrays;
3032
import java.util.List;
@@ -35,6 +37,7 @@
3537
import com.oracle.svm.core.SubstrateUtil;
3638
import com.oracle.svm.core.util.UserError;
3739

40+
import jdk.graal.compiler.options.OptionDescriptor;
3841
import jdk.graal.compiler.options.OptionKey;
3942

4043
/**
@@ -121,4 +124,13 @@ public InvalidMacroException(String arg0) {
121124
super(arg0);
122125
}
123126
}
127+
128+
public static <T extends Annotation> List<T> getAnnotationsByType(OptionDescriptor optionDescriptor, Class<T> annotationClass) {
129+
try {
130+
Field field = optionDescriptor.getDeclaringClass().getDeclaredField(optionDescriptor.getFieldName());
131+
return List.of(field.getAnnotationsByType(annotationClass));
132+
} catch (NoSuchFieldException e) {
133+
return List.of();
134+
}
135+
}
124136
}

0 commit comments

Comments
 (0)