Basically a native call is made in java.io.UnixFileSystem to getSpace(...):
/* -- Disk usage -- */
public native long getSpace(File f, int t);
This native method ends up calling via JNI the method defined in this file of the JDK's repository:
https://github.com/openjdk/jdk/blob/master/src/java.base/unix/native/libjava/UnixFileSystem_md.c
In this file, at line 466, you find the following implementation (parts inside the if/else statements have been omitted for brevity):
JNIEXPORT jlong JNICALL
Java_java_io_UnixFileSystem_getSpace(JNIEnv *env, jobject this,
jobject file, jint t)
{
jlong rv = 0L;
WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
#ifdef MACOSX
struct statfs fsstat;
#else
struct statvfs64 fsstat;
int res;
#endif
memset(&fsstat, 0, sizeof(fsstat));
#ifdef MACOSX
if (statfs(path, &fsstat) == 0) {
switch(t) {
// omitted
}
}
#else
RESTARTABLE(statvfs64(path, &fsstat), res);
if (res == 0) {
switch(t) {
// omitted
}
}
#endif
} END_PLATFORM_STRING(env, path);
return rv;
}
So as you can see, if you are using MACOSX the C library function statfs is called, otherwise the function statvfs64 is called.