RFR: 8321033: Avoid casting Array to GrowableArray

Kim Barrett kbarrett at openjdk.org
Wed Jun 5 04:17:57 UTC 2024


On Wed, 5 Jun 2024 03:43:46 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> `ModuleEntry::_reads` is declared as an GrowableArray<ModuleEntry*>*, but when stored in a CDS archive, it's assigned to an Array<ModuleEntry*>*. To ensure better type safety, `ModuleEntry::_reads` is changed to a generic pointer which uses two different getters and setters as well as two booleans to ensure the value is interpreted correctly. This was chosen to avoid introducing a new field to the ModuleEntry class, as another pointer and further alignment would increase the size of the ModuleEntry array. Verified with tier1-5 tests.
>
> src/hotspot/share/classfile/moduleEntry.hpp line 73:
> 
>> 71:   void* _reads; // list of modules that are readable by this module
>> 72:   DEBUG_ONLY(bool _reads_is_growable);
>> 73:   DEBUG_ONLY(bool _reads_is_archived);
> 
> These new members should be initialized in the constructor.

Do we really need two bool members?  I've not delved deeply, but it looks like one bool flag would
be sufficient, so long as one is okay with initializing as having a null GA to start with.  This would
also avoid any questions about what it means for both to be true (shouldn't be possible, but bugs
happen, and the new state checks don't catch that) or both false.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19549#discussion_r1626898733


More information about the hotspot-runtime-dev mailing list