RFR: 8294982: Implementation of Classfile API [v20]

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Feb 16 12:58:56 UTC 2023


On Thu, 16 Feb 2023 12:46:09 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   added 4-byte Unicode text to Utf8EntryTest
>
> src/java.base/share/classes/jdk/internal/classfile/impl/SplitConstantPool.java line 271:
> 
>> 269: 
>> 270:     private <E extends PoolEntry> E internalAdd(E cpi, int hash) {
>> 271:         int newIndex = size-parentSize;
> 
> I'm not sure I get this. The new entry is constructed with an index set to the pool size. That said, when we build the entry we don't yet know if the entry is already in the pool. The EntryMap data structure seems to have logic to detect duplicates (e.g. adding an already added entry is a no-op) - but this method seems to (a) add the CP entry to the `newEntries` array anyway and (b) happily return the entry with the index set to the pool size (which might, or might not, be the correct final index). What am I missing?

Nevermind - this method is only called if the entry is not found (using `findEntry`) :-)

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

PR: https://git.openjdk.org/jdk/pull/10982



More information about the build-dev mailing list