diff options
author | bothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-03-03 23:50:03 +0000 |
---|---|---|
committer | bothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-03-03 23:50:03 +0000 |
commit | c3db176afa2ff0afa4d502ac46ba37a995ef342b (patch) | |
tree | 8da6fb814250474a55396eab60ccc38d2dedbe09 /libjava/java/nio/channels/Channels.java | |
parent | 8f0037668ed1962eaed036e2f7e1e20fdef419a0 (diff) | |
download | ppe42-gcc-c3db176afa2ff0afa4d502ac46ba37a995ef342b.tar.gz ppe42-gcc-c3db176afa2ff0afa4d502ac46ba37a995ef342b.zip |
* java/nio/channels/Channels.java (newInputStream, newOutputStream):
Optimize when argument is a FileChannelImpl.
(newInputStream(FileChannelImpl), newOutputStream(FileChannelImpl)):
New native methods.
* java/nio/channels/natChannels.cc: New file for new native methods.
* Makefile.am: Update accordingly.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@78867 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/nio/channels/Channels.java')
-rw-r--r-- | libjava/java/nio/channels/Channels.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libjava/java/nio/channels/Channels.java b/libjava/java/nio/channels/Channels.java index cb6154e968d..896e1734d80 100644 --- a/libjava/java/nio/channels/Channels.java +++ b/libjava/java/nio/channels/Channels.java @@ -41,8 +41,11 @@ import gnu.java.nio.ChannelInputStream; import gnu.java.nio.ChannelOutputStream; import gnu.java.nio.InputStreamChannel; import gnu.java.nio.OutputStreamChannel; +import gnu.java.nio.channels.FileChannelImpl; import java.io.InputStream; import java.io.OutputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.Reader; import java.io.Writer; import java.nio.charset.Charset; @@ -59,16 +62,23 @@ public final class Channels */ public static InputStream newInputStream(ReadableByteChannel ch) { + if (ch instanceof FileChannelImpl) + return newInputStream((FileChannelImpl) ch); return new ChannelInputStream(ch); } - + /** * Constructs a stream that writes bytes to the given channel. */ public static OutputStream newOutputStream(WritableByteChannel ch) { + if (ch instanceof FileChannelImpl) + return newOutputStream((FileChannelImpl) ch); return new ChannelOutputStream(ch); } + + static native FileInputStream newInputStream(FileChannelImpl ch); + static native FileOutputStream newOutputStream(FileChannelImpl ch); /** * Constructs a channel that reads bytes from the given stream. @@ -77,7 +87,7 @@ public final class Channels { return new InputStreamChannel(in); } - + /** * Constructs a channel that writes bytes to the given stream. */ |