On Tue, 12 May 2026 13:00:07 GMT, Per Minborg <[email protected]> wrote:

> This PR proposes to replace older `Collection.unmodifiable` wrappers with 
> `Set.of()` instead. This can improve performance, reduce footprint, and 
> reduce maintenance. There is also occasional use of `Map.of()` in nearby 
> places where `Set.of()` was introduced.
> 
> The PR also contains two optimizations in `PlatformMBeanProviderImpl` that 
> remove `synchronized` from two methods.
> 
> ---------
> - [X] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

src/java.base/linux/classes/sun/nio/fs/LinuxFileSystem.java line 73:

> 71:     @Override
> 72:     public Set<String> supportedFileAttributeViews() {
> 73:         return 
> SupportedFileFileAttributeViewsHolder.SUPPORTED_FILE_ATTRIBUTE_VIEWS;

Like NetworkChannel::supportedSockets, I wouldn't expect 
FileSystem::supportedFileAttributeViews to in performance critical code. The 
method is specified to return an unmodifable set and I would expect the 
compatibility impact of contains(null) to be low. It would be a behavior change 
of course so would need to go into the CSR.

src/java.base/share/classes/sun/nio/ch/ServerSocketChannelImpl.java line 272:

> 270: 
> 271:         private static Set<SocketOption<?>> defaultUnixDomainOptions() {
> 272:             return Set.of(StandardSocketOptions.SO_RCVBUF);

The supportedOptions is defined by NetworkChannel and there are 5 
implementation. I see the PR has changed one channel implementation. If we do 
one then we should do all 5. This method is not performance critical, it tends 
to get used to test if a non-standard option is supported. So it might not be 
worth doing.

As regards the spec, it doesn't specify that the returned set is unmodifiable 
and doesn't specify how contains(null) is handled. For the latter, it would be 
a behavior change to throw NPE. The compatibility risk is probably low but 
would need be tracked by a CSR and probably release note.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/31135#discussion_r3235956536
PR Review Comment: https://git.openjdk.org/jdk/pull/31135#discussion_r3235936722

Reply via email to