[GR-62449] Ensure that class initialization status is stable between layers. #11303
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.
This PR ensures that
java.lang.Class
initialization status is stable between layers: it registers the computed initialization kind extracted from the previous layer as the configured init kind in this layer when theAnalysisType
is initialized. This will cause base layer types to have a strict initialization kind in this layer which will prevent further changes to the initialization kind, even in ways that would otherwise be considered compatible, e.g., RUN_TIME -> BUILD_TIME. Similarly, if a different initialization kind was already registered in this layer registration will fail.Additionally this PR removes
PersistedAnalysisType.isInitializedAtBuildTime
which is redundant.Note 1: I previously tried serializing the configured init kind for each type and then using that as the configured init in the next layer but that doesn't work: when querying the configured init kind in this layer if a class had a non-strict init kind, i.e., specified via a package prefix, then that config effectively becomes strict in the next layer, i.e., specified via the concrete type. This will prevent switching a non-strict init kind to a strict one when for example a sub-type init kind dictates it.