RFR: 8321429: (fc) FileChannel.lock creates a FileKey containing two long index values, they could be stored as int values [v3]

Brian Burkhalter bpb at openjdk.org
Thu Dec 7 18:15:05 UTC 2023


On Thu, 7 Dec 2023 09:26:18 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8321429: Compute FileKey hash code directly instead of calling Objects.hash()
>
> src/java.base/windows/classes/sun/nio/ch/FileKey.java line 50:
> 
>> 48:     @Override
>> 49:     public int hashCode() {
>> 50:         return dwVolumeSerialNumber + nFileIndexHigh + nFileIndexLow;
> 
> I assume that that it's not too common to use FileChannel.lock to lock many regions of a file so the quality of the hashCode might not be important. However, looking at it now makes me wonder about the addition, maybe it should do the usual multiple by prime and add the next component, as if calling Objects.hashCode.

So changed in 414fad626d812a6b3b8976816f6351125f7481bf.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17009#discussion_r1419423446


More information about the nio-dev mailing list