RFR: 8313743: Make fields final in sun.nio.ch [v2]

Andrey Turbanov aturbanov at openjdk.org
Fri Aug 4 12:41:53 UTC 2023


On Fri, 4 Aug 2023 10:38:16 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Andrey Turbanov has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8313743: Make fields final in sun.nio.ch
>>   
>>   update copyrights
>
> src/java.base/share/classes/sun/nio/ch/OptionKey.java line 31:
> 
>> 29:  * Represents the level/name of a socket option
>> 30:  */
>> 31: record OptionKey(int level, int name) {
> 
> This changes equality, will need to examine the usages in generated code to check that it is okay.

`OptionKey` is used only as a value in HashMap `sun.nio.ch.SocketOptionRegistry.LazyInitialization#options`.
The only usage of this map is `sun.nio.ch.SocketOptionRegistry#findOption`
https://github.com/openjdk/jdk/blob/e8a37b90db8dca4dc3653970b2d66d2faf8ef452/src/java.base/share/classes/sun/nio/ch/SocketOptionRegistry.java.template#L144-L147
Returned `OptionKey` is then only compared with `null` and then deconstructed to `level`/`name` parts.

Hence, changing equiality doesn't change the behavior.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14980#discussion_r1284369631


More information about the nio-dev mailing list