Should IO#getModifiedTimeOrZero(File) be using JNA for Java 10+?

I guess IO#getModifiedTimeOrZero(File) is built on top of JNA because Java 9- had a bug and File.lastModified only had second resolution, but it has been fixed in Java 10, see https://bugs.openjdk.java.net/browse/JDK-8177809.

Wouldn’t it be better to select strategy depending on Java version, use vanilla Java for Java 10+ and only fallback to JNA otherwise?

I think it’s a good idea to get rid of JNA usage whenever possible.

I can work on a PR.
Is there already some util in sbt to detect Java version?

So actually, such switch already exists.
It’s just that Java is preferred over JNA starting with Java 11 instead of 10. I’ve created a PR.

1 Like