This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: what's the point of java.nio?


Adam Megacz wrote:

Er, I must be a dunce or something.  I've read through all the nio
introductions I can find, and I still can't figure out why Sun
introduced an entire package instead of two methods:

 static InputStream InputStream.select(InputStream[])
 static boolean Socket.nonBlockingConnect()

It looks like given these two functions I could implement all of
java.nio on top of java.io.  And the converse (io on nio) is certainly
true (libgcj does it).

So the only conclusion I'm left with is that it's somehow easier to
implement the native method support for nio more efficiently, but I
can't see how that is the case.

Can anybody clue me in?


InputStream was an existing class. If you change it you have to do it in a manner that ALL existing programs would continue to work. It would also be best if ALL existing InputStream subclasses behaved properly under your new select() method.

You never say what select() on a FileInputStream would do. How about select() on a ByteArrayInputStream or PipedInputStream? How would you even implement select() on a PipedInputStream? I like non-blocking output too, what would you do for that.

You would also have to add methods to make InputStreams blocking and non-blocking. These of course would have to be backwards compatible with ALL existing code.


Seems like a tall order, but maybe I am missing something.


David Daney



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]