Proposal for adding O_DIRECT support into JDK 9

Andrew Haley aph at
Sun Aug 28 10:23:11 UTC 2016

On 26/08/16 23:31, Lu, Yingqi wrote:

> The proposal adds 4 API methods to java/io/,
> java/io/ to enable the feature. In addition, it add
> O_DIRECT with two more modes "ro" (read-only and direct) and "rwo"
> (read-write and direct) to java/io/
> public FileInputStream(String name, boolean direct) throws FileNotFoundException

Adding a boolean for O_DIRECT does not scale well.  There are many
other flags, and if there is some future expansion it would mean
adding more boolean arguments to the call signature.  It might be
worth considering a more direct way to make the call to open(2).  I
appreciate that not every flag passed to open() makes sense, though.
And there is Windows etc. to think about.  But something like

  new FileInputStream(filename, File.DIRECT | File.APPEND)

is much more scalable and involves less argument marshalling.


More information about the core-libs-dev mailing list