This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
FYI: Patch: gnu.java.nio
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Thu, 9 Oct 2003 20:05:19 +0200
- Subject: FYI: Patch: gnu.java.nio
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi list,
I commited the attached patch to trunk to improve java.nio.
Michael
- --
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQE/haNkWSOgCCdjSDsRAkoKAJ94f1Jsswp5/MUd1kDN9CX4HdjqAgCfbcBb
UoMMg+AuhAHkSmrZ6Xelwn8=
=xan8
-----END PGP SIGNATURE-----
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2231
diff -u -b -B -r1.2231 ChangeLog
--- ChangeLog 9 Oct 2003 17:34:09 -0000 1.2231
+++ ChangeLog 9 Oct 2003 17:48:02 -0000
@@ -1,5 +1,23 @@
2003-10-09 Michael Koch <konqueror@gmx.de>
+ * gnu/java/nio/SelectorImpl.java (register):
+ Use ServerSocketChannelSelectionKey for server socket channels,
+ removed unneeded comments.
+ * gnu/java/nio/ServerSocketChannelImpl.java
+ (ServerSocketChannelImpl): Made class public final.
+ (impl): New member variable.
+ (ServerSocketChannelImpl): Initialize member variables correctly.
+ (initServerSocket): New method.
+ (getNativeFD): Likewise.
+ * gnu/java/nio/ServerSocketChannelSelectionKey.java,
+ gnu/java/nio/natServerSocketChannelImpl.cc: New files.
+ * Makefile.am (ordinary_java_source_files):
+ Added gnu/java/nio/ServerSocketChannelSelectionKey.java.
+ (nat_source_files): Added gnu/java/nio/natServerSocketChannelImpl.cc.
+ * Makefile.in: Regenrated.
+
+2003-10-09 Michael Koch <konqueror@gmx.de>
+
* java/nio/channels/spi/AbstractSelectableChannel.java
(registered): Made private.
(blocking): Likewise.
Index: Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.am,v
retrieving revision 1.329
diff -u -b -B -r1.329 Makefile.am
--- Makefile.am 8 Oct 2003 16:28:24 -0000 1.329
+++ Makefile.am 9 Oct 2003 17:48:05 -0000
@@ -2193,6 +2193,7 @@
gnu/java/nio/SelectorImpl.java \
gnu/java/nio/SelectorProviderImpl.java \
gnu/java/nio/ServerSocketChannelImpl.java \
+gnu/java/nio/ServerSocketChannelSelectionKey.java \
gnu/java/nio/SocketChannelImpl.java \
gnu/java/nio/SocketChannelSelectionKey.java \
gnu/java/nio/charset/ISO_8859_1.java \
@@ -2658,6 +2659,7 @@
gnu/java/net/protocol/core/natCoreInputStream.cc \
gnu/java/nio/natFileLockImpl.cc \
gnu/java/nio/natSelectorImpl.cc \
+gnu/java/nio/natServerSocketChannelImpl.cc \
java/io/natFile.cc \
java/io/natFileDescriptor.cc \
java/io/natObjectInputStream.cc \
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.in,v
retrieving revision 1.353
diff -u -b -B -r1.353 Makefile.in
--- Makefile.in 8 Oct 2003 16:28:25 -0000 1.353
+++ Makefile.in 9 Oct 2003 17:48:10 -0000
@@ -1912,6 +1912,7 @@
gnu/java/nio/SelectorImpl.java \
gnu/java/nio/SelectorProviderImpl.java \
gnu/java/nio/ServerSocketChannelImpl.java \
+gnu/java/nio/ServerSocketChannelSelectionKey.java \
gnu/java/nio/SocketChannelImpl.java \
gnu/java/nio/SocketChannelSelectionKey.java \
gnu/java/nio/charset/ISO_8859_1.java \
@@ -2376,6 +2377,7 @@
gnu/java/net/protocol/core/natCoreInputStream.cc \
gnu/java/nio/natFileLockImpl.cc \
gnu/java/nio/natSelectorImpl.cc \
+gnu/java/nio/natServerSocketChannelImpl.cc \
java/io/natFile.cc \
java/io/natFileDescriptor.cc \
java/io/natObjectInputStream.cc \
@@ -2553,12 +2555,13 @@
gnu/java/net/natPlainSocketImpl.lo \
gnu/java/net/protocol/core/natCoreInputStream.lo \
gnu/java/nio/natFileLockImpl.lo gnu/java/nio/natSelectorImpl.lo \
-java/io/natFile.lo java/io/natFileDescriptor.lo \
-java/io/natObjectInputStream.lo java/io/natVMObjectStreamClass.lo \
-java/lang/natCharacter.lo java/lang/natClass.lo \
-java/lang/natClassLoader.lo java/lang/natConcreteProcess.lo \
-java/lang/natDouble.lo java/lang/natFloat.lo java/lang/natMath.lo \
-java/lang/natObject.lo java/lang/natRuntime.lo java/lang/natString.lo \
+gnu/java/nio/natServerSocketChannelImpl.lo java/io/natFile.lo \
+java/io/natFileDescriptor.lo java/io/natObjectInputStream.lo \
+java/io/natVMObjectStreamClass.lo java/lang/natCharacter.lo \
+java/lang/natClass.lo java/lang/natClassLoader.lo \
+java/lang/natConcreteProcess.lo java/lang/natDouble.lo \
+java/lang/natFloat.lo java/lang/natMath.lo java/lang/natObject.lo \
+java/lang/natRuntime.lo java/lang/natString.lo \
java/lang/natStringBuffer.lo java/lang/natSystem.lo \
java/lang/natThread.lo java/lang/natVMSecurityManager.lo \
java/lang/ref/natReference.lo java/lang/reflect/natArray.lo \
@@ -3037,6 +3040,7 @@
.deps/gnu/java/nio/SelectorImpl.P \
.deps/gnu/java/nio/SelectorProviderImpl.P \
.deps/gnu/java/nio/ServerSocketChannelImpl.P \
+.deps/gnu/java/nio/ServerSocketChannelSelectionKey.P \
.deps/gnu/java/nio/SocketChannelImpl.P \
.deps/gnu/java/nio/SocketChannelSelectionKey.P \
.deps/gnu/java/nio/charset/ISO_8859_1.P \
@@ -3049,6 +3053,7 @@
.deps/gnu/java/nio/charset/UTF_16LE.P \
.deps/gnu/java/nio/charset/UTF_8.P .deps/gnu/java/nio/natFileLockImpl.P \
.deps/gnu/java/nio/natSelectorImpl.P \
+.deps/gnu/java/nio/natServerSocketChannelImpl.P \
.deps/gnu/java/rmi/RMIMarshalledObjectInputStream.P \
.deps/gnu/java/rmi/RMIMarshalledObjectOutputStream.P \
.deps/gnu/java/rmi/dgc/DGCImpl.P .deps/gnu/java/rmi/dgc/DGCImpl_Skel.P \
Index: gnu/java/nio/SelectorImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/nio/SelectorImpl.java,v
retrieving revision 1.9
diff -u -b -B -r1.9 SelectorImpl.java
--- gnu/java/nio/SelectorImpl.java 26 Sep 2003 03:50:45 -0000 1.9
+++ gnu/java/nio/SelectorImpl.java 9 Oct 2003 17:48:10 -0000
@@ -253,17 +253,17 @@
if (ch instanceof SocketChannelImpl)
{
SocketChannelImpl sc = (SocketChannelImpl) ch;
- result = new SocketChannelSelectionKey (ch, this); // FIXME: last argument
+ result = new SocketChannelSelectionKey (ch, this);
}
else if (ch instanceof DatagramChannelImpl)
{
DatagramChannelImpl dc = (DatagramChannelImpl) ch;
- result = new DatagramChannelSelectionKey (ch, this); // FIXME: last argument
+ result = new DatagramChannelSelectionKey (ch, this);
}
else if (ch instanceof ServerSocketChannelImpl)
{
ServerSocketChannelImpl ssc = (ServerSocketChannelImpl) ch;
- result = new SocketChannelSelectionKey (ch, this); // FIXME: last argument
+ result = new ServerSocketChannelSelectionKey (ch, this);
}
else
{
Index: gnu/java/nio/ServerSocketChannelImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/nio/ServerSocketChannelImpl.java,v
retrieving revision 1.7
diff -u -b -B -r1.7 ServerSocketChannelImpl.java
--- gnu/java/nio/ServerSocketChannelImpl.java 18 Jun 2003 08:56:55 -0000 1.7
+++ gnu/java/nio/ServerSocketChannelImpl.java 9 Oct 2003 17:48:10 -0000
@@ -38,6 +38,7 @@
package gnu.java.nio;
+import gnu.java.net.PlainSocketImpl;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
@@ -47,9 +48,10 @@
import java.nio.channels.SocketChannel;
import java.nio.channels.spi.SelectorProvider;
-class ServerSocketChannelImpl extends ServerSocketChannel
+public final class ServerSocketChannelImpl extends ServerSocketChannel
{
ServerSocket serverSocket;
+ PlainSocketImpl impl;
boolean blocking = true;
boolean connected = false;
@@ -57,7 +59,20 @@
throws IOException
{
super (provider);
- serverSocket = new ServerSocket ();
+ impl = new PlainSocketImpl();
+ initServerSocket();
+ }
+
+ /*
+ * This method is only need to call a package private constructor
+ * of java.net.ServerSocket. It only initializes the member variables
+ * "serverSocket".
+ */
+ private native void initServerSocket() throws IOException;
+
+ public int getNativeFD()
+ {
+ return impl.getNativeFD();
}
public void finalizer()
Index: gnu/java/nio/ServerSocketChannelSelectionKey.java
===================================================================
RCS file: gnu/java/nio/ServerSocketChannelSelectionKey.java
diff -N gnu/java/nio/ServerSocketChannelSelectionKey.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/nio/ServerSocketChannelSelectionKey.java 9 Oct 2003 17:48:10 -0000
@@ -0,0 +1,56 @@
+/* ServerSocketChannelSelectionKey.java --
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.nio;
+
+import java.nio.channels.spi.AbstractSelectableChannel;
+
+public final class ServerSocketChannelSelectionKey
+ extends SelectionKeyImpl
+{
+ public ServerSocketChannelSelectionKey (AbstractSelectableChannel channel,
+ SelectorImpl selector)
+ {
+ super (channel, selector);
+ }
+
+ public int getNativeFD()
+ {
+ return ((ServerSocketChannelImpl) ch).getNativeFD();
+ }
+}
Index: gnu/java/nio/natServerSocketChannelImpl.cc
===================================================================
RCS file: gnu/java/nio/natServerSocketChannelImpl.cc
diff -N gnu/java/nio/natServerSocketChannelImpl.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/nio/natServerSocketChannelImpl.cc 9 Oct 2003 17:48:10 -0000
@@ -0,0 +1,25 @@
+// natServerSocketChannelImpl.cc
+
+/* Copyright (C) 2003 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 <platform.h>
+
+#include <errno.h>
+#include <string.h>
+
+#include <gnu/java/net/PlainSocketImpl.h>
+#include <gnu/java/nio/ServerSocketChannelImpl.h>
+#include <java/net/ServerSocket.h>
+
+void
+gnu::java::nio::ServerSocketChannelImpl::initServerSocket()
+{
+ serverSocket = new ::java::net::ServerSocket (impl);
+}