I'm working to remove all system calls from an existing Java code base. We run our application in a commercially provided, closed-source, JVM. When the JVM makes a system call via a getRuntime.exec() java call the entire JVM process forks which leads to serious performance hits. We run on a linux platform but ideally try to keep things as portable as possible.
I'm running into problems replacing a sync() call we currently use via the getRuntime.exec() method. I know there is this sync() method and flush() as well. And based on this post I'm looking to do a sync and flush with all open file streams.
My issue is that I don't have direct knowledge of what file streams and descriptors are out there. I thought one way around this would be to check the /proc/(jvm process number)/fd folder but I can't find a good way to reliably get the JVM process number using pure java. I thought I might be able to get all objects of a certain class (the FileDescriptor class) but from what I'm reading this isn't feasible either.
Does anyone have suggestions on how to duplicate a *nix sync() call in pure java?