Skip to content

Commit 715f255

Browse files
committed
[GR-44733] Public flag for missing registration errors.
PullRequest: graal/17804
2 parents e27620f + 8bab9b8 commit 715f255

File tree

5 files changed

+43
-35
lines changed

5 files changed

+43
-35
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,9 @@ public static void updateMaxJavaStackTraceDepth(EconomicMap<OptionKey<?>, Object
523523
@Option(help = "Trace VMOperation execution.")//
524524
public static final HostedOptionKey<Boolean> TraceVMOperations = new HostedOptionKey<>(false);
525525

526-
@APIOption(name = "trace-class-initialization")//
527-
@Option(help = "Comma-separated list of fully-qualified class names that class initialization is traced for.")//
526+
private static final String DEPRECATION_MESSAGE_TCI = "This option is not required anymore with the strict image heap enabled by default.";
527+
@APIOption(name = "trace-class-initialization", deprecated = DEPRECATION_MESSAGE_TCI)//
528+
@Option(help = "Comma-separated list of fully-qualified class names that class initialization is traced for.", deprecated = true, deprecationMessage = DEPRECATION_MESSAGE_TCI)//
528529
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> TraceClassInitialization = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());
529530

530531
@APIOption(name = "trace-object-instantiation")//
@@ -1100,7 +1101,7 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, String ol
11001101
public static final HostedOptionKey<Boolean> VerifyFrameAccess = new HostedOptionKey<>(false);
11011102

11021103
@SuppressWarnings("unused")//
1103-
@APIOption(name = "configure-reflection-metadata")//
1104+
@APIOption(name = "configure-reflection-metadata", deprecated = "This option has no function anymore.")//
11041105
@Option(help = "Enable runtime instantiation of reflection objects for non-invoked methods.", type = OptionType.Expert, deprecated = true)//
11051106
public static final HostedOptionKey<Boolean> ConfigureReflectionMetadata = new HostedOptionKey<>(true);
11061107

@@ -1136,10 +1137,12 @@ public Boolean getValueOrDefault(UnmodifiableEconomicMap<OptionKey<?>, Object> v
11361137
deprecated = true, deprecationMessage = "This option was introduced to simplify migration to GraalVM 23.0 and will be removed in a future release")//
11371138
public static final HostedOptionKey<Boolean> AllowDeprecatedBuilderClassesOnImageClasspath = new HostedOptionKey<>(false);
11381139

1139-
@Option(help = "file:doc-files/MissingRegistrationHelp.txt")//
1140+
@APIOption(name = "exact-reachability-metadata", defaultValue = "")//
1141+
@Option(help = "file:doc-files/ExactReachabilityMetadataHelp.txt")//
11401142
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> ThrowMissingRegistrationErrors = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.build());
11411143

1142-
@Option(help = "file:doc-files/MissingRegistrationPathsHelp.txt")//
1144+
@APIOption(name = "exact-reachability-metadata-path")//
1145+
@Option(help = "file:doc-files/ExactReachabilityMetadataPathHelp.txt")//
11431146
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> ThrowMissingRegistrationErrorsPaths = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.build());
11441147

11451148
public enum ReportingMode {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Enables exact and user-friendly handling of reflection, resources, JNI, and serialization.
2+
When reachability metadata for an element is specified, the native executable will have expected and predictable behavior.
3+
When reachability metadata for an element is not specified, the binary will fail fast with a subtype of `java.lang.Error`
4+
that explains exactly which element was missing. The errors can happen on reflection, resource, JNI, and serialization accesses.
5+
6+
Note: '--exact-reachability-metadata' will become the default in future versions of Native Image. It is recommended to adopt the mode early
7+
to avoid breakage during migration to newer GraalVM versions.
8+
9+
If errors occur in third-party code, exact reachability metadata can be applied only to a single package with
10+
'--exact-reachability-metadata=pkg'. To apply to whole jars, modules, and class-path entries please use
11+
'--exact-reachability-metadata-path'. Using '--exact-reachability-metadata=<pkg>' with arguments is allowed in every scope:
12+
13+
1. On command line
14+
2. Embedded in a 'native-image.properties' file of some zip/jar file on module-path
15+
3. Embedded in a 'native-image.properties' file of some zip/jar file on class-path
16+
17+
If used without arguments (only '--exact-reachability-metadata'), the errors will be thrown when calling the corresponding query from any
18+
class in scope of the option. Using '--exact-reachability-metadata' without arguments is only allowed on command line or when
19+
embedded in a 'native-image.properties' file of some zip/jar file on the module-path (but not on class-path).
20+
In the module path case, the option will cause all classes of the module to trigger missing registration errors.
21+
If used without arguments on command line all classes will trigger missing registration errors.
22+
23+
If the option is embedded in 'native-image.properties' file in some zip/jar file all class-names
24+
and package-names passed to the option have to be found in the zip/jar files the option is embedded
25+
in. Using '--exact-reachability-metadata' with arguments on command line does not have that restriction.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Trigger exact handling of reflection, resources, JNI, and serialization from all types in the given class-path or module-path entries.
2+
3+
This option requires arguments that are of the same type as the arguments passed via -p (--module-path) or -cp (--class-path):
4+
5+
--exact-reachability-metadata-path <class-search path of directories and jar files>
6+
7+
The given entries are searched and all classes inside are registered as '--exact-reachability-metadata' classes.
8+
9+
This option is only allowed to be used on command line. The option will be rejected if it is provided
10+
by 'Args' in a 'native-image.properties' file that is embedded in a jar file.

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

Lines changed: 0 additions & 19 deletions
This file was deleted.

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

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)