summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/java/nio/channels
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/java/nio/channels')
-rw-r--r--libjava/classpath/java/nio/channels/FileChannel.java14
-rw-r--r--libjava/classpath/java/nio/channels/SelectionKey.java6
-rw-r--r--libjava/classpath/java/nio/channels/spi/AbstractSelectionKey.java6
3 files changed, 8 insertions, 18 deletions
diff --git a/libjava/classpath/java/nio/channels/FileChannel.java b/libjava/classpath/java/nio/channels/FileChannel.java
index 0eefffbe97b..3aa19990917 100644
--- a/libjava/classpath/java/nio/channels/FileChannel.java
+++ b/libjava/classpath/java/nio/channels/FileChannel.java
@@ -114,12 +114,7 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
*/
public final long write(ByteBuffer[] srcs) throws IOException
{
- long result = 0;
-
- for (int i = 0; i < srcs.length; i++)
- result += write(srcs[i]);
-
- return result;
+ return write(srcs, 0, srcs.length);
}
/**
@@ -169,12 +164,7 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
*/
public final long read(ByteBuffer[] dsts) throws IOException
{
- long result = 0;
-
- for (int i = 0; i < dsts.length; i++)
- read(dsts[i]);
-
- return result;
+ return read(dsts, 0, dsts.length);
}
/**
diff --git a/libjava/classpath/java/nio/channels/SelectionKey.java b/libjava/classpath/java/nio/channels/SelectionKey.java
index 5219b6bff84..9723faf5262 100644
--- a/libjava/classpath/java/nio/channels/SelectionKey.java
+++ b/libjava/classpath/java/nio/channels/SelectionKey.java
@@ -1,5 +1,5 @@
/* SelectionKey.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -60,7 +60,7 @@ public abstract class SelectionKey
/**
* Attaches obj to the key and returns the old attached object.
*/
- public final Object attach(Object obj)
+ public final synchronized Object attach(Object obj)
{
Object old = attached;
attached = obj;
@@ -70,7 +70,7 @@ public abstract class SelectionKey
/**
* Returns the object attached to the key.
*/
- public final Object attachment()
+ public final synchronized Object attachment()
{
return attached;
}
diff --git a/libjava/classpath/java/nio/channels/spi/AbstractSelectionKey.java b/libjava/classpath/java/nio/channels/spi/AbstractSelectionKey.java
index 5ab8468bf2e..02d09ce10ad 100644
--- a/libjava/classpath/java/nio/channels/spi/AbstractSelectionKey.java
+++ b/libjava/classpath/java/nio/channels/spi/AbstractSelectionKey.java
@@ -1,5 +1,5 @@
/* AbstractSelectionKey.java --
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -57,7 +57,7 @@ public abstract class AbstractSelectionKey extends SelectionKey
/**
* Cancels this key.
*/
- public final void cancel()
+ public final synchronized void cancel()
{
if (isValid())
{
@@ -71,7 +71,7 @@ public abstract class AbstractSelectionKey extends SelectionKey
*
* @return true if this key is valid, false otherwise
*/
- public final boolean isValid()
+ public final synchronized boolean isValid()
{
return ! cancelled;
}
OpenPOWER on IntegriCloud