The following snippet is supposed to throw FileAlreadyExistsException when it tries to open the current directory for writing with the "create new" option also set:
OpenOption[] opts = { WRITE, CREATE_NEW };
Files.newByteChannel(Path.of(""), opts);
However, on Linux, it throws an unexpected ArrayIndexOutOfBoundsException with the stack trace looking like
at java.base/sun.nio.fs.UnixChannelFactory.open(UnixChannelFactory.java:203)
at java.base/sun.nio.fs.UnixChannelFactory.newFileChannel(UnixChannelFactory.java:133)
at java.base/sun.nio.fs.UnixChannelFactory.newFileChannel(UnixChannelFactory.java:146)
at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:216)
OpenOption[] opts = { WRITE, CREATE_NEW };
Files.newByteChannel(Path.of(""), opts);
However, on Linux, it throws an unexpected ArrayIndexOutOfBoundsException with the stack trace looking like
at java.base/sun.nio.fs.UnixChannelFactory.open(UnixChannelFactory.java:203)
at java.base/sun.nio.fs.UnixChannelFactory.newFileChannel(UnixChannelFactory.java:133)
at java.base/sun.nio.fs.UnixChannelFactory.newFileChannel(UnixChannelFactory.java:146)
at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:216)
- relates to
-
JDK-8024695 new File("").exists() returns false whereas it is the current working directory
-
- Resolved
-
- links to
-
Commit(master) openjdk/jdk/0414dcec
-
Review(master) openjdk/jdk/23560