Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GR-51606] Introduce a typeReached check for Class.forName. #8335

Closed
wants to merge 1 commit into from

Conversation

graalvmbot
Copy link
Collaborator

@graalvmbot graalvmbot commented Feb 8, 2024

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 and typeReachable 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:

  • The ClassInitializationInfo contains the extra field typeReached.
  • The ClassInitializationInfo is not a singleton for build-time initialized classes that require tracking for being reached. This is required as the field reached can be mutated at runtime.

Review entry points:

  1. For the runtime computation of reached and build-time metadata construction: substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/classinitialization/ClassInitializationInfo.java
  2. For the usage of the mechanism in Class.forName: substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/ClassForNameSupport.java
  3. For parsing the JSON files: substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConfigurationParser.java
  4. For interactions with optimizations related to class initalization follow the EnsureClassInitializedNode: substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/classinitialization/EnsureClassInitializedNode.java.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Feb 8, 2024
@graalvmbot graalvmbot force-pushed the vj/GR-51606-type-reachable-for-name branch 4 times, most recently from 09fc585 to 1b60288 Compare February 19, 2024 11:02
@graalvmbot graalvmbot force-pushed the vj/GR-51606-type-reachable-for-name branch 7 times, most recently from 604b171 to d1352c3 Compare March 4, 2024 19:38
@graalvmbot graalvmbot force-pushed the vj/GR-51606-type-reachable-for-name branch 5 times, most recently from 5219c0d to b323fcd Compare March 12, 2024 13:27
@graalvmbot graalvmbot force-pushed the vj/GR-51606-type-reachable-for-name branch 8 times, most recently from c3519c8 to b0c6869 Compare March 14, 2024 17:27
@graalvmbot graalvmbot force-pushed the vj/GR-51606-type-reachable-for-name branch from f1bea88 to c73d231 Compare March 22, 2024 14:04
@graalvmbot graalvmbot force-pushed the vj/GR-51606-type-reachable-for-name branch 3 times, most recently from 6d569be to 3e48173 Compare April 15, 2024 12:37
@graalvmbot graalvmbot force-pushed the vj/GR-51606-type-reachable-for-name branch 6 times, most recently from d1fd7f5 to b8f6644 Compare April 22, 2024 21:11
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 if the type is initialized (successfuly, or unsuccesfully), or any of the type's subtypes are reached. Type is also reached if any of the subtypes is marked as `initialize-at-build-time`.

The JSON elements `typeReached` and `typeReachable` 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:
* The `ClassInitializationInfo` is contains the extra field `typeReached`.
* The `ClassInitializationInfo` is not a singleton for build-time initialized classes that require tracking for being reached. This is required as the field `reached` can be mutated at runtime.

Review entry points:
1) For the runtime computation of reached and build-time metadata construction: substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/classinitialization/ClassInitializationInfo.java
2) For the usage of the mechanism in `Class.forName`: substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/ClassForNameSupport.java
3) For parsing the JSON files: substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConfigurationParser.java
4) For interactions with optimizations related to class initalization follow the `EnsureClassInitializedNode`: substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/classinitialization/EnsureClassInitializedNode.java.
@graalvmbot graalvmbot force-pushed the vj/GR-51606-type-reachable-for-name branch from b8f6644 to 19009b6 Compare April 23, 2024 20:30
@graalvmbot graalvmbot closed this Apr 24, 2024
@graalvmbot graalvmbot deleted the vj/GR-51606-type-reachable-for-name branch April 24, 2024 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants