[GR-73222] Make exact reflection a future default and refine exact reachability metadata at run time - #14158
Open
graalvmbot wants to merge 15 commits into
Open
[GR-73222] Make exact reflection a future default and refine exact reachability metadata at run time#14158graalvmbot wants to merge 15 commits into
graalvmbot wants to merge 15 commits into
Conversation
graalvmbot
force-pushed
the
vj/GR-73222-exact-reflection-default
branch
3 times, most recently
from
August 13, 2026 07:37
fb639b7 to
7ecc944
Compare
graalvmbot
force-pushed
the
vj/GR-73222-exact-reflection-default
branch
from
August 17, 2026 08:55
115977a to
7a67667
Compare
graalvmbot
force-pushed
the
vj/GR-73222-exact-reflection-default
branch
from
August 18, 2026 09:36
845980c to
19b01ef
Compare
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Deoptimization materializes virtualized objects with Unsafe.allocateInstance, which now goes through exact reachability metadata checks and fails for types without unsafeAllocated metadata, such as Truffle FrameWithoutBoxing during lazy deoptimization. Use KnownIntrinsics.unvalidatedAllocateInstance because this is a VM-internal re-allocation of an object that compiled code had already allocated before escape analysis virtualized it.
Exact-mode metadata and the missing-registration reporting paths are only built with --future-defaults=exact-reflection (or the deprecated --exact-reachability-metadata aliases); other images keep the legacy metadata and reject -XX:+ExactReachabilityMetadata and -XX:ExactReachabilityMetadataPackages at startup. Warn mode and out-of-scope callers only report and keep the legacy behavior, unnamed ClassLoader.defineClass is checked by the parsed class name, and the report helpers no longer return dead values.
The reference manual, the troubleshooting guide, and the Native Image skills described the runtime options without the build-time half of the rule: -R:+ExactReachabilityMetadata and -R:ExactReachabilityMetadataPackages are only accepted in a build that also passes --future-defaults=exact-reflection. Document that restriction with the error it produces, point the deprecated --exact-reachability-metadata aliases at the replacement, and state that in Warn mode, and for callers outside the selected packages, a missing registration is only reported while the call keeps its legacy behavior.
graalvmbot
force-pushed
the
vj/GR-73222-exact-reflection-default
branch
from
August 27, 2026 09:46
2f77a5f to
06bac17
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.