[GR-73222] Make exact reflection a future default and exact reachability metadata a runtime option - #14158
Open
graalvmbot wants to merge 8 commits into
Open
[GR-73222] Make exact reflection a future default and exact reachability metadata a runtime option#14158graalvmbot wants to merge 8 commits into
graalvmbot wants to merge 8 commits into
Conversation
graalvmbot
force-pushed
the
vj/GR-73222-exact-reflection-default
branch
from
August 6, 2026 16:09
9b80b04 to
d38d8fa
Compare
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
graalvmbot
force-pushed
the
vj/GR-73222-exact-reflection-default
branch
from
August 7, 2026 11:40
0067aed to
fb639b7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--exact-reachability-metadataused to serve two purposes at once: it made dynamic access exact, and it was the migration vehicle away from the legacy reflection behavior. This PR splits those two concerns:--future-defaults=exact-reflection— the future default. It makes reflection, JNI, serialization, proxies, unsafe allocation and resource bundles exact, but keeps legacy behavior forClass.forNameand ordinary resource lookups, so that enabling the future default does not turn every unregistered class name or missing resource into aMissingRegistrationError.-XX:+ExactReachabilityMetadata— a global, immutable runtime option that additionally makes class-name lookup and ordinary resource lookup exact.--exact-reachability-metadataat build time only sets the executable's default for it.The resulting state matrix:
--future-defaults=exact-reflection-XX:±ExactReachabilityMetadataClass.forNameand ordinary resourcesBecause exactness is now selected at executable startup, both behaviors have to be available in a single image: the build always encodes a superset of the metadata and the runtime filters it according to the active mode.
Option changes
SubstrateOptions.ThrowMissingRegistrationErrors(hosted, class/package-scoped) is replaced bySubstrateOptions.ConcealedOptions.ExactReachabilityMetadata, aRuntimeOptionKey<Boolean>withImmutable(startup-only, so lookup semantics cannot change while the application runs).--exact-reachability-metadatastays as the@APIOption, now a boolean that sets the executable's runtime default. Package/class arguments are no longer accepted.--exact-reachability-metadata-pathand its help file are removed.MissingRegistrationSupportno longer holds anOptionClassFilter; hosted plugins always behave as if exactness were on, so the metadata needed by either runtime mode is retained.Predicate split
Every former
throwMissingRegistrationErrors()check was audited and moved to exactly one of two predicates inMissingRegistrationUtils:exactReflection()=exact-reflectionfuture default or the runtime option. Used byDynamicHubclass/member queries, hiding and negative queries, array creation, unsafe allocation (SubstrateAllocationSnippets),JNIReflectionDictionaryclass/method/field lookup,ClassLoader#defineClass, proxies, serialization and resource bundles.exactReachabilityMetadata()= the runtime option only. Used byClass.forName/bootstrap/loaded-class lookup inClassRegistries, array class names resolved through those entry points (soDynamicHub.arrayType()cannot leak a future-default error), and ordinary resource lookups inResourcesandNativeImageResourceFileSystem.FutureDefaultsOptions.exactReflection()is@Folded so the future-default half of the predicate is a build-time constant, while the runtime flag stays dynamic — this is required for the allocation snippets, which cannot parse a non-folded lookup.Missing-registration reporting for JNI field/method access and for
defineClassnow returns/throws the error directly instead of relying on the caller to continue, which removes the previoussneakyThrowofClassNotFoundExceptionon thedefineClasspath.Build-time metadata is now mode-independent
ResourcesFeature/Resources: resource include patterns and negative resource queries are always stored, so a missing resource can be distinguished from a resource covered by a glob at runtime in either mode.NativeImageCodeCache: negative field/method/constructor query metadata is always encoded.ReflectionDataBuilder: hiding fields/methods, declaring types of individually registered members, and implicit inner-class registrations are all recorded unconditionally, so the legacy and exact views coexist.LEGACY_ACCESS_FLAGin the encoded metadata;RuntimeMetadataDecoderImplhides their offset when exactness is active, so theFieldobject stays queryable but not accessible.ADDITIONAL_FLAGS_LEGACY_UNSAFE_ALLOCATION_BITinDynamicHub; in exact mode the hub falls back to the explicitly registered unsafe-allocation metadata.RegistryAdapter/ReflectionRegistryAdapter: unresolvable configuration entries always become negative queries instead of throwing; with-H:+StrictConfigurationthey are reported as warnings.Documentation
ExactReachabilityMetadataHelp.txtrewritten for the boolean/runtime semantics;ExactReachabilityMetadataPathHelp.txtdeleted.FutureDefaultsHelp.txtdescribes whatexact-reflectioncovers and points to-XX:+ExactReachabilityMetadatafor the stronger mode.ReachabilityMetadata.md,BuildOptions.md(regenerated table), the troubleshooting guide and the bundled Native Image skill references drop the package/path scoping and document the runtime option.