I was looking through the list of Java bytecode instructions and I noticed that there aren’t any I/O instructions. That intrigued me. How does the JVM execute methods like System.out.println when it doesn’t support I/O instructions?
If it uses some form of memory mapped I/O then how does it communicate with the OS to read file descriptors, etc? Does the JVM implement its own layer of abstraction for handling I/O operations? Are the Java I/O packages (java.io & java.nio) implemented in C/C++ instead?
If you look at the library source code, you’ll see that all interfacing with low-level APIs (OS etc) is done using native code.
For example, take
FileOutputStream:And then there’s the corresponding C file (often OS-specific).