[crac] RFR: Adapted some FileDescriptor tests for Win [v3]

Radim Vansa rvansa at openjdk.org
Mon Jul 24 09:46:04 UTC 2023


On Mon, 24 Jul 2023 08:25:23 GMT, Roman Marchenko <rmarchenko at openjdk.org> wrote:

> I didn't change JarFileFactory implementation for Linux, so the Windows-specific JarFileFactory.java changed only.

My bad, I did not notice this is modifying the windows-only implementation.

>> src/java.base/windows/native/libjava/FileDescriptor_md.c line 118:
>> 
>>> 116:     }
>>> 117: 
>>> 118:     typedef NTSTATUS(WINAPI* NtQueryObjectFunc)(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG, PULONG);
>> 
>> Rather than using a non-public function, would `GetFileInformationByHandle` work here? You can just test the file attributes matching https://learn.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants
>
> GetFileInformationByHandle doesn't work for sockets. The closest appropriate function would be GetFileType, however it operates with integer file type codes, and has too few codes to distiguish types. Additionally, since I'd like to dump type name into a native description string, I have taken NtQueryObject.

What do you mean by 'not working'? From what I see, you don't really use the function except for identifying that it is really a file/dir. Therefore if it returns an error for a socket, you can immediately fall back to the `Handle %p`. Or does the NtQueryObject actually provide any info about the socket that you read?

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

PR Comment: https://git.openjdk.org/crac/pull/91#issuecomment-1647574127
PR Review Comment: https://git.openjdk.org/crac/pull/91#discussion_r1272008834


More information about the crac-dev mailing list