--- a/src/java.base/share/classes/java/nio/channels/FileChannel.java Thu Jun 21 18:56:35 2018 +0100
+++ b/src/java.base/share/classes/java/nio/channels/FileChannel.java Thu Jun 21 11:10:55 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -335,8 +335,13 @@
public static FileChannel open(Path path, OpenOption... options)
throws IOException
{
- Set<OpenOption> set = new HashSet<>(options.length);
- Collections.addAll(set, options);
+ Set<OpenOption> set;
+ if (options.length == 0) {
+ set = Collections.emptySet();
+ } else {
+ set = new HashSet<>();
+ Collections.addAll(set, options);
+ }
return open(path, set, NO_ATTRIBUTES);
}