[GR-51606] Introduce a typeReached check for Class.forName. #8335
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.
The core implementation of #7480
This PR applies only for
Class.forName
. The other cases will be covered in the consecutive PRs.A type is reached at run time, right before class-initialization routine starts for the a class or interface, or any of the type's subtypes are reached. Type is reached at build-time, if any of the subtypes is marked as
initialize-at-build-time
and exists in the image. Array types are not marked as reached and as such can not be used in conditions.The JSON elements
typeReached
andtypeReachable
are currently distinguished as different elements and can not be merged. This is due to the possible restriction in semantics if we merge different reflection descriptors with a condition that is different only in a runtime check.The agent still outputs
typeReachable
as the implementation is not finished for all elements.Implementation notes:
ClassInitializationInfo
contains the extra fieldtypeReached
.ClassInitializationInfo
is not a singleton for build-time initialized classes that require tracking for being reached. This is required as the fieldreached
can be mutated at runtime.Review entry points:
Class.forName
: substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/ClassForNameSupport.javaEnsureClassInitializedNode
: substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/classinitialization/EnsureClassInitializedNode.java.