4

I have an application that I am trying to run in an in-memory file system but my application has a dependency that uses java.io as opposed to java.nio. Is there any way I can change the JVM's default file system to remedy this?

Michael Chav
  • 441
  • 5
  • 15
  • 1
    This reference indicates that, "There is no one-to-one correspondence between the two APIs," that suggests to me that even if you could swap java.nio for java.io it might not work because the two are not compatible with each other. https://docs.oracle.com/javase/tutorial/essential/io/legacy.html – Freiheit Aug 10 '16 at 18:49
  • 2
    Instead of relying on jimfs, can you simply mount another in-memory filesystem in your OS and run your app in that? – Freiheit Aug 10 '16 at 18:50
  • 1
    You could replace java.io classes using a custom classloader. Realistically, you're better off trying to find hooks in the app so it's not using `File` and friends directly. – David Ehrmann Aug 10 '16 at 19:39
  • 2
    There actually is a way to change the default file system (though I don't remember exactly what it is and am not going to look it up now), but for a variety of reasons I think it's a bad idea to replace the default file system unless (maybe) the file system you're replacing it with is one that just layers some extra functionality on top of the default file system. – ColinD Aug 10 '16 at 19:41

0 Answers0