From 7113237bf329e1245f096787093aed051ea2dd23 Mon Sep 17 00:00:00 2001 From: mkoch Date: Thu, 25 Sep 2003 10:17:00 +0000 Subject: 2003-09-25 Michael Koch * gnu/java/nio/DatagramChannelImpl.java (DatagramChannelImpl): Made class final. (blocking): Made private. (socket): Made it a NIODatagramSocket and private. (DatagramChannelImpl): create NIODatagramSocket instead of DatagramSocket. (implConfigureBlocking): Set socket timeout. (connect): Check that channel is not closed. (write): Implemented. (write): Rewritten. (read): Implemented. (read): Rewritten. (receive): Implemented. (send): Implemented. * gnu/java/nio/SelectionKeyImpl.java (readyOps): Made private. (interestOps): Made private. (impl): Made private. (ch): Made private. (readyOps): Check if selection key is valid. (interestOps): Likewise. * gnu/java/nio/SelectorImpl.java (closed): Removed. (keys): Made private. (selected): Made private. (finalize): New method. (implCloseSelector): Rewritten. (keys): Return unmodifiable Set. (deregisterCancelledKeys): Fixed typo in method name. * gnu/java/nio/SocketChannelImpl.java (SocketChannelImpl): Made class final. (socket): Made it a NIOSocket and private. (blocking): Made private. (connected): Made private. (connectionPending): New member variable. (SocketChannelImpl): New implementation. (finalizer): Use isConnected(). (connect): Rewritten. (finishConnect): Throws IOException, implemented. (isConnectionPending): Return connectionPending. (read): Rewritten. (write): Rewritten. * gnu/java/nio/NIOConstants.java: New file. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/NIOConstants.java. * Makefile.in: Regenerated. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@71769 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/gnu/java/nio/SelectionKeyImpl.java | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'libjava/gnu/java/nio/SelectionKeyImpl.java') diff --git a/libjava/gnu/java/nio/SelectionKeyImpl.java b/libjava/gnu/java/nio/SelectionKeyImpl.java index 72dc20b15b8..df4faa3a935 100644 --- a/libjava/gnu/java/nio/SelectionKeyImpl.java +++ b/libjava/gnu/java/nio/SelectionKeyImpl.java @@ -1,5 +1,5 @@ /* SelectionKeyImpl.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -37,6 +37,7 @@ exception statement from your version. */ package gnu.java.nio; +import java.nio.channels.CancelledKeyException; import java.nio.channels.SelectableChannel; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; @@ -45,10 +46,10 @@ import java.nio.channels.spi.AbstractSelectionKey; public class SelectionKeyImpl extends AbstractSelectionKey { int fd; - int readyOps; - int interestOps; - SelectorImpl impl; - SelectableChannel ch; + private int readyOps; + private int interestOps; + private SelectorImpl impl; + private SelectableChannel ch; public SelectionKeyImpl (SelectableChannel ch, SelectorImpl impl, int fd) { @@ -64,22 +65,34 @@ public class SelectionKeyImpl extends AbstractSelectionKey public int readyOps () { + if (!isValid()) + throw new CancelledKeyException(); + return readyOps; } public SelectionKey readyOps (int ops) { + if (!isValid()) + throw new CancelledKeyException(); + readyOps = ops; return this; } public int interestOps () { + if (!isValid()) + throw new CancelledKeyException(); + return interestOps; } public SelectionKey interestOps (int ops) { + if (!isValid()) + throw new CancelledKeyException(); + interestOps = ops; return this; } -- cgit v1.2.1