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
This commit is contained in:
Per Bothner 2004-03-03 15:50:03 -08:00
parent d79944f484
commit dd0a905f24
5 changed files with 141 additions and 92 deletions

View File

@ -1,3 +1,12 @@
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>
* configure.host: Pass -fno-omit-frame-pointer for i386.
@ -8,15 +17,6 @@
* 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>
* java/nio/channels/FileChannelImpl.java: Moved to package

View File

@ -2852,6 +2852,7 @@ java/lang/reflect/natMethod.cc \
java/lang/reflect/natProxy.cc \
java/net/natNetworkInterface.cc \
java/net/natInetAddress.cc \
java/nio/channels/natChannels.cc \
java/nio/natDirectByteBufferImpl.cc \
java/text/natCollator.cc \
java/util/natResourceBundle.cc \

View File

@ -2529,6 +2529,7 @@ java/lang/reflect/natMethod.cc \
java/lang/reflect/natProxy.cc \
java/net/natNetworkInterface.cc \
java/net/natInetAddress.cc \
java/nio/channels/natChannels.cc \
java/nio/natDirectByteBufferImpl.cc \
java/text/natCollator.cc \
java/util/natResourceBundle.cc \
@ -2693,10 +2694,10 @@ java/lang/natVMSecurityManager.lo java/lang/ref/natReference.lo \
java/lang/reflect/natArray.lo java/lang/reflect/natConstructor.lo \
java/lang/reflect/natField.lo java/lang/reflect/natMethod.lo \
java/lang/reflect/natProxy.lo java/net/natNetworkInterface.lo \
java/net/natInetAddress.lo java/nio/natDirectByteBufferImpl.lo \
java/text/natCollator.lo java/util/natResourceBundle.lo \
java/util/natTimeZone.lo java/util/zip/natDeflater.lo \
java/util/zip/natInflater.lo
java/net/natInetAddress.lo java/nio/channels/natChannels.lo \
java/nio/natDirectByteBufferImpl.lo java/text/natCollator.lo \
java/util/natResourceBundle.lo java/util/natTimeZone.lo \
java/util/zip/natDeflater.lo java/util/zip/natInflater.lo
lib_org_xml_sax_la_DEPENDENCIES = libgcj.la
lib_org_xml_sax_la_OBJECTS = org/xml/sax/ext/DeclHandler.lo \
org/xml/sax/ext/LexicalHandler.lo \
@ -2736,83 +2737,6 @@ org/w3c/dom/traversal/NodeFilter.lo \
org/w3c/dom/traversal/NodeIterator.lo \
org/w3c/dom/traversal/TreeWalker.lo
lib_gnu_java_awt_peer_gtk_la_DEPENDENCIES =
@GTK_CAIRO_FALSE@lib_gnu_java_awt_peer_gtk_la_OBJECTS = \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GdkClasspathFontPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GdkClasspathFontPeerMetrics.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GdkFontMetrics.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GdkGlyphVector.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GdkGraphics.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GdkGraphics2D.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GdkPixbufDecoder.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkArg.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkArgList.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkButtonPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkCanvasPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkCheckboxGroupPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkCheckboxMenuItemPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkCheckboxPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkChoicePeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkClipboard.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkComponentPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkContainerPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkDialogPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkEmbeddedWindowPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkFileDialogPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkFontPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkFramePeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkGenericPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkImage.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkImagePainter.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkLabelPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkListPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkMainThread.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkMenuBarPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkMenuComponentPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkMenuItemPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkMenuPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkOffScreenImage.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkPanelPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkPopupMenuPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkScrollPanePeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkScrollbarPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkTextAreaPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkTextComponentPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkTextFieldPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkToolkit.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkWindowPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontMetrics.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuComponentPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollBarPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollPanePeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gthread-jni.lo jni/classpath/jcl.lo \
@GTK_CAIRO_FALSE@jni/classpath/jnilink.lo jni/classpath/native_state.lo \
@GTK_CAIRO_FALSE@jni/classpath/primlib.lo
@GTK_CAIRO_TRUE@lib_gnu_java_awt_peer_gtk_la_OBJECTS = \
@GTK_CAIRO_TRUE@gnu/java/awt/peer/gtk/GdkClasspathFontPeer.lo \
@GTK_CAIRO_TRUE@gnu/java/awt/peer/gtk/GdkClasspathFontPeerMetrics.lo \
@ -2894,6 +2818,83 @@ lib_gnu_java_awt_peer_gtk_la_DEPENDENCIES =
@GTK_CAIRO_TRUE@jni/gtk-peer/gthread-jni.lo jni/classpath/jcl.lo \
@GTK_CAIRO_TRUE@jni/classpath/jnilink.lo jni/classpath/native_state.lo \
@GTK_CAIRO_TRUE@jni/classpath/primlib.lo
@GTK_CAIRO_FALSE@lib_gnu_java_awt_peer_gtk_la_OBJECTS = \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GdkClasspathFontPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GdkClasspathFontPeerMetrics.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GdkFontMetrics.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GdkGlyphVector.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GdkGraphics.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GdkGraphics2D.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GdkPixbufDecoder.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkArg.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkArgList.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkButtonPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkCanvasPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkCheckboxGroupPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkCheckboxMenuItemPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkCheckboxPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkChoicePeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkClipboard.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkComponentPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkContainerPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkDialogPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkEmbeddedWindowPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkFileDialogPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkFontPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkFramePeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkGenericPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkImage.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkImagePainter.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkLabelPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkListPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkMainThread.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkMenuBarPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkMenuComponentPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkMenuItemPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkMenuPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkOffScreenImage.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkPanelPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkPopupMenuPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkScrollPanePeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkScrollbarPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkTextAreaPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkTextComponentPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkTextFieldPeer.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkToolkit.lo \
@GTK_CAIRO_FALSE@gnu/java/awt/peer/gtk/GtkWindowPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontMetrics.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuComponentPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollBarPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollPanePeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.lo \
@GTK_CAIRO_FALSE@jni/gtk-peer/gthread-jni.lo jni/classpath/jcl.lo \
@GTK_CAIRO_FALSE@jni/classpath/jnilink.lo jni/classpath/native_state.lo \
@GTK_CAIRO_FALSE@jni/classpath/primlib.lo
lib_gnu_awt_xlib_la_OBJECTS = gnu/gcj/xlib/natClip.lo \
gnu/gcj/xlib/natColormap.lo gnu/gcj/xlib/natDisplay.lo \
gnu/gcj/xlib/natDrawable.lo gnu/gcj/xlib/natFont.lo \
@ -3832,6 +3833,7 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/nio/channels/UnresolvedAddressException.P \
.deps/java/nio/channels/UnsupportedAddressTypeException.P \
.deps/java/nio/channels/WritableByteChannel.P \
.deps/java/nio/channels/natChannels.P \
.deps/java/nio/channels/spi/AbstractInterruptibleChannel.P \
.deps/java/nio/channels/spi/AbstractSelectableChannel.P \
.deps/java/nio/channels/spi/AbstractSelectionKey.P \

View File

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

View File

@ -0,0 +1,36 @@
// 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);
}