RFR: 8297682: Use Collections.emptyIterator where applicable
Pavel Rappo
prappo at openjdk.org
Mon Nov 28 15:04:12 UTC 2022
On Mon, 7 Nov 2022 17:30:20 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:
> Instead of `Collections.emptyList().iterator()` we can use `Collections.emptyIterator()` method.
> Actual implementation of `java.util.Collections.EmptyList#iterator` does exactly this - just calls `emptyIterator` method.
src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java line 192:
> 190: return allowedList.iterator();
> 191: } catch (SecurityException x) {
> 192: return Collections.emptyIterator(); //disallowed
Alternatively, you could use the exception parameter to capture that comment:
} catch (SecurityException disallowed) {
-------------
PR: https://git.openjdk.org/jdk/pull/11025
More information about the compiler-dev
mailing list