On Tue, 31 Mar 2026 14:35:33 GMT, Chen Liang <[email protected]> wrote:
>> On mainline Integer's cache is not final because the archived data may be >> invalid and need to be thrown away if a system property is changed. (This >> has always been the biggest headache with AOT) >> >> @xmas92 I think only `IntegerCache.cache` is non-final `@Stable`. Others >> seem to be final `@Stable`. A final `@Stable` is meaningful for arrays >> because a read of such an array element is considered a compiler constant if >> it is non-zero/null. > >> If in preview, `static final` caches with `null` and `@Stable static` caches >> with an empty array. > > If we do not touch the cache array at all in preview, we can leave that array > null because it won't be touched by code and thus won't be dealt by JIT. > On mainline Integer's cache is not final because the archived data may be > invalid and need to be thrown away if a system property is changed. (This has > always been the biggest headache with AOT) Right so the cache can have an unstable `@stable` non-null value. Scary. Will be nice when Integer lose their identity and we do not have to worry about these sort of things. > `@Stable` is meaningful for arrays because a read of such an array element is > considered a compiler constant if it is non-zero/null. Did not know that the `@Stable` property was not shallow. Thanks for the information! ------------- PR Review Comment: https://git.openjdk.org/valhalla/pull/2249#discussion_r3027510126
