[GR-59858] Mark type of hidden field reachable. #10104
Merged
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.
Fixes #10080.
The underlying issue is that we miss registering a field's declared type as reachable during reflection metadata processing.
First, the
com.oracle.svm.hosted.reflect.ReflectionDataBuilder
detects a field as being a hiding field, i.e., a field that shadows a superclass element registered for reflection, and it registers it to be excluded from reflection queries. This field, including its declared type, is then included in the image code info bycom.oracle.svm.hosted.image.NativeImageCodeCache#buildRuntimeMetadata
, however its type was never properly registered as reachable.Then, during shadow heap verification when we scan the
com.oracle.svm.core.code.ImageCodeInfo#classes
we detect the corresponding class constant and we wrongly try to register the correspondingAnalysisType
as reachable, but at this stage it is too late, as the analysis has finished and no new types can be registered. This leads to the NPE. Catching the late registration attempt and reporting leads to an improved error message:But the original issue was trying to include an unreachable type in the native image code cache. Fixing the detection condition there leads to an error message that takes us closer to the actual problem:
Finally, the actual fix is to automatically mark the hiding field's declared type as reachable as soon as the field is discovered.