Commit dd0a905f by Per Bothner

Channels.java (newInputStream, [...]): Optimize when argument is a FileChannelImpl.


	* 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.

From-SVN: r78867
parent d79944f4
2004-03-03 Per Bothner <per@bothner.com>
* 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.
2004-03-02 Jan Hubicka <jh@suse.cz> 2004-03-02 Jan Hubicka <jh@suse.cz>
* configure.host: Pass -fno-omit-frame-pointer for i386. * configure.host: Pass -fno-omit-frame-pointer for i386.
...@@ -8,15 +17,6 @@ ...@@ -8,15 +17,6 @@
* java/lang/natPosixProcess.cc (startProcess): Fix thinko. * java/lang/natPosixProcess.cc (startProcess): Fix thinko.
2004-03-01 Per Bothner <per@bothner.com>
* 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.
2004-02-29 Per Bothner <per@bothner.com> 2004-02-29 Per Bothner <per@bothner.com>
* java/nio/channels/FileChannelImpl.java: Moved to package * java/nio/channels/FileChannelImpl.java: Moved to package
......
...@@ -2852,6 +2852,7 @@ java/lang/reflect/natMethod.cc \ ...@@ -2852,6 +2852,7 @@ java/lang/reflect/natMethod.cc \
java/lang/reflect/natProxy.cc \ java/lang/reflect/natProxy.cc \
java/net/natNetworkInterface.cc \ java/net/natNetworkInterface.cc \
java/net/natInetAddress.cc \ java/net/natInetAddress.cc \
java/nio/channels/natChannels.cc \
java/nio/natDirectByteBufferImpl.cc \ java/nio/natDirectByteBufferImpl.cc \
java/text/natCollator.cc \ java/text/natCollator.cc \
java/util/natResourceBundle.cc \ java/util/natResourceBundle.cc \
......
...@@ -41,8 +41,11 @@ import gnu.java.nio.ChannelInputStream; ...@@ -41,8 +41,11 @@ import gnu.java.nio.ChannelInputStream;
import gnu.java.nio.ChannelOutputStream; import gnu.java.nio.ChannelOutputStream;
import gnu.java.nio.InputStreamChannel; import gnu.java.nio.InputStreamChannel;
import gnu.java.nio.OutputStreamChannel; import gnu.java.nio.OutputStreamChannel;
import gnu.java.nio.channels.FileChannelImpl;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.Reader; import java.io.Reader;
import java.io.Writer; import java.io.Writer;
import java.nio.charset.Charset; import java.nio.charset.Charset;
...@@ -59,16 +62,23 @@ public final class Channels ...@@ -59,16 +62,23 @@ public final class Channels
*/ */
public static InputStream newInputStream(ReadableByteChannel ch) public static InputStream newInputStream(ReadableByteChannel ch)
{ {
if (ch instanceof FileChannelImpl)
return newInputStream((FileChannelImpl) ch);
return new ChannelInputStream(ch); return new ChannelInputStream(ch);
} }
/** /**
* Constructs a stream that writes bytes to the given channel. * Constructs a stream that writes bytes to the given channel.
*/ */
public static OutputStream newOutputStream(WritableByteChannel ch) public static OutputStream newOutputStream(WritableByteChannel ch)
{ {
if (ch instanceof FileChannelImpl)
return newOutputStream((FileChannelImpl) ch);
return new ChannelOutputStream(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. * Constructs a channel that reads bytes from the given stream.
...@@ -77,7 +87,7 @@ public final class Channels ...@@ -77,7 +87,7 @@ public final class Channels
{ {
return new InputStreamChannel(in); return new InputStreamChannel(in);
} }
/** /**
* Constructs a channel that writes bytes to the given stream. * Constructs a channel that writes bytes to the given stream.
*/ */
......
// natChannels.cc - Native part of Channels class.
/* Copyright (C) 2004 Free Software Foundation
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
#include <config.h>
#include <gcj/cni.h>
#include <java/nio/channels/Channels.h>
#include <java/io/FileInputStream.h>
#include <java/io/FileOutputStream.h>
#include <gnu/java/nio/channels/FileChannelImpl.h>
using java::nio::channels::Channels;
using java::io::FileInputStream;
using java::io::FileOutputStream;
using gnu::java::nio::channels::FileChannelImpl;
FileInputStream*
Channels::newInputStream(FileChannelImpl* ch)
{
// Needs to be native to bypass Java access protection.
return new FileInputStream (ch);
}
FileOutputStream*
Channels::newOutputStream(FileChannelImpl* ch)
{
// Needs to be native to bypass Java access protection.
return new FileOutputStream (ch);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment