RFR: 8316000: File.setExecutable silently fails if file does not exist

Alan Bateman alanb at openjdk.org
Tue Sep 12 06:30:38 UTC 2023


On Tue, 12 Sep 2023 01:36:34 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> On Windows, do not return `true` from the `java.io.File` methods `setReadable(boolean, boolean)` and `setExecutable(boolean, boolean)` if the file does not exist.
>
> src/java.base/windows/native/libjava/WinNTFileSystem_md.c line 479:
> 
>> 477:     if (access == java_io_FileSystem_ACCESS_READ ||
>> 478:         access == java_io_FileSystem_ACCESS_EXECUTE) {
>> 479:         return _waccess(pathbuf, 0) == 0 ? enable : JNI_FALSE;
> 
> Here `enable` is returned for backward compatibility, but per the specification it seems that `JNI_TRUE` should be returned instead.

I don't think this is right, at least it doesn't work with ACLs and file system security so it can't test if the file is executable. Also I have a concern about mixing win32 and C runtime functions here.  The main issue with these setXXX methods is that don't map to DOS file attributes or ACL based security so they will need to fail for some cases.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15673#discussion_r1322486689


More information about the core-libs-dev mailing list