Sounds kind of reasonable. I've just done some profiling to see what state things are in these days. I'm using Java 11 (openjdk 11.0.8 2020-07-14) on Linux, with an ext4 filesystem. I ran things a few times, so everything's cached anyway.
The profiling is done using the Stopwatch class. I basically have a 10000-iteration loop that counts the result of whether something's a symlink or not, which is eventually printed out (to avoid anything being optimised out).
The directories, files and symlinks are all in the same directory, and their filenames are exactly the same length as each other (21 chars). Just in case that could have a bearing (eg copying across the JNI boundary).
I first ran that on all combinations of dir, symlink-to-dir, file, symlink-to-file. Got some fun results:
| file | sym-file | dir | sym-dir
NIO | 12ms | 13ms | 16ms | 40ms
Posix | 31ms | 19ms | 19ms | 21ms
Then, just to check, I ran that loop in another 100-iteration loop, to check how variable the timing is. I then get this:
| file | sym-file | dir | sym-dir
NIO | 9ms..18ms (mean 10ms) | 9ms..16ms (mean 9ms) | 9ms..17ms (mean 9ms) | 9ms..43ms (mean 10ms)
Posix | 17ms..21ms (mean 17ms) | 17ms..25ms (mean 17ms) | 17ms..20ms (mean 17ms) | 16ms..29ms (mean 17ms)
So I guess after enough calls, the NIO one gets heavily hotspotted, which can't be done so easily for the posix version.
So the results: NIO is always faster than the Posix JNI thing for plain files and directories. NIO starts off significantly slower for symlinks to directories (this is consistently the case across multiple single-shot runs), but once the optimiser has had enough fun with it, that goes away.
Eventually, NIO becomes roughly twice as fast as Posix/JNI. IMO, switching to NIO would be worthwhile. It'd be less code on our side, and the initial hit of 'is symlink' on a symlink-to-directory being a bit slower is probably worth taking.
Sound reasonable?
Cheers,
Phil