RFR: 8343019: Primitive caches must use boxed instances from the archive

Jiangli Zhou jiangli at openjdk.org
Tue Oct 29 00:48:11 UTC 2024


On Mon, 28 Oct 2024 23:15:54 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:

> As an example, if `IntegerCache.high` is set to `1` during archiving, then `ModuleLoaderMap.PLATFORM_LOADER_INDEX=1` ends up pointing to archived instance and `ModuleLoaderMap.APP_LOADER_INDEX=2` points to non-archived instance which are then persisted in the archive as part of the sub-graph rooted at `ModuleLoaderMap.map`.

The minimum Integer cache `high` value is 127 (https://github.com/openjdk/jdk/blob/f0075d593db657182e1857e54710a1052e9d1cf0/src/java.base/share/classes/java/lang/Integer.java#L946). `Integer.valueOf` [spec](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Integer.html#equals(java.lang.Object)) also mentions "will always cache values in the range -128 to 127, inclusive, and may cache other values outside of this range". 

I agree with @iwanowww', the concern about the issue described by @iwanowww's comment above still exists when archived (heap object) subgraph contains instances of boxed type outside the cached range and when equality of identity hash comparison is assumed.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/21737#issuecomment-2442940697


More information about the core-libs-dev mailing list