diff options
Diffstat (limited to 'gnu/java/nio')
-rw-r--r-- | gnu/java/nio/DatagramChannelImpl.java | 2 | ||||
-rw-r--r-- | gnu/java/nio/SelectorImpl.java | 26 | ||||
-rw-r--r-- | gnu/java/nio/SocketChannelImpl.java | 2 | ||||
-rw-r--r-- | gnu/java/nio/charset/Provider.java | 12 |
4 files changed, 26 insertions, 16 deletions
diff --git a/gnu/java/nio/DatagramChannelImpl.java b/gnu/java/nio/DatagramChannelImpl.java index 51c7031fe..4687bf3f5 100644 --- a/gnu/java/nio/DatagramChannelImpl.java +++ b/gnu/java/nio/DatagramChannelImpl.java @@ -201,7 +201,7 @@ public final class DatagramChannelImpl extends DatagramChannel try { DatagramPacket packet; - int len = dst.capacity() - dst.position(); + int len = dst.remaining(); if (dst.hasArray()) { diff --git a/gnu/java/nio/SelectorImpl.java b/gnu/java/nio/SelectorImpl.java index f0f56f9c3..5d4e93156 100644 --- a/gnu/java/nio/SelectorImpl.java +++ b/gnu/java/nio/SelectorImpl.java @@ -43,6 +43,7 @@ import java.nio.channels.ClosedSelectorException; import java.nio.channels.SelectableChannel; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; +import java.nio.channels.SocketChannel; import java.nio.channels.spi.AbstractSelectableChannel; import java.nio.channels.spi.AbstractSelector; import java.nio.channels.spi.SelectorProvider; @@ -284,19 +285,18 @@ public class SelectorImpl extends AbstractSelector // Set new ready write ops for (int i = 0; i < write.length; i++) { - if (key.getNativeFD() == write[i]) - { - ops = ops | SelectionKey.OP_WRITE; - - // if (key.channel ().isConnected ()) - // { - // ops = ops | SelectionKey.OP_WRITE; - // } - // else - // { - // ops = ops | SelectionKey.OP_CONNECT; - // } - } + if (key.getNativeFD() == write[i]) + { + if (key.channel() instanceof SocketChannel) + { + if (((SocketChannel) key.channel ()).isConnected ()) + ops = ops | SelectionKey.OP_WRITE; + else + ops = ops | SelectionKey.OP_CONNECT; + } + else + ops = ops | SelectionKey.OP_WRITE; + } } // FIXME: We dont handle exceptional file descriptors yet. diff --git a/gnu/java/nio/SocketChannelImpl.java b/gnu/java/nio/SocketChannelImpl.java index fcddbd6c3..680eba2f9 100644 --- a/gnu/java/nio/SocketChannelImpl.java +++ b/gnu/java/nio/SocketChannelImpl.java @@ -220,7 +220,7 @@ public final class SocketChannelImpl extends SocketChannel int offset = 0; InputStream input = socket.getInputStream(); int available = input.available(); - int len = dst.capacity() - dst.position(); + int len = dst.remaining(); if ((! isBlocking()) && available == 0) return 0; diff --git a/gnu/java/nio/charset/Provider.java b/gnu/java/nio/charset/Provider.java index 3f25c5988..c7f7ed278 100644 --- a/gnu/java/nio/charset/Provider.java +++ b/gnu/java/nio/charset/Provider.java @@ -39,6 +39,8 @@ package gnu.java.nio.charset; import java.nio.charset.Charset; import java.nio.charset.spi.CharsetProvider; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; @@ -232,8 +234,16 @@ public final class Provider extends CharsetProvider public static synchronized Provider provider () { + // The default provider is safe to instantiate. if (singleton == null) - singleton = new Provider (); + singleton = (Provider) AccessController.doPrivileged + (new PrivilegedAction() + { + public Object run() + { + return new Provider(); + } + }); return singleton; } } |