aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/gnu/java/nio
diff options
context:
space:
mode:
authorMark Wielaard <mark@gcc.gnu.org>2006-08-14 23:12:35 +0000
committerMark Wielaard <mark@gcc.gnu.org>2006-08-14 23:12:35 +0000
commitac1ed908de999523efc36f38e69bca1aadfe0808 (patch)
tree97037d2c09c8384d80531f67ec36a01205df6bdb /libjava/classpath/gnu/java/nio
parentabab460491408e05ea93fb85e1975296a87df504 (diff)
downloadgcc-ac1ed908de999523efc36f38e69bca1aadfe0808.zip
gcc-ac1ed908de999523efc36f38e69bca1aadfe0808.tar.gz
gcc-ac1ed908de999523efc36f38e69bca1aadfe0808.tar.bz2
Imported GNU Classpath 0.92
2006-08-14 Mark Wielaard <mark@klomp.org> Imported GNU Classpath 0.92 * HACKING: Add more importing hints. Update automake version requirement. * configure.ac (gconf-peer): New enable AC argument. Add --disable-gconf-peer and --enable-default-preferences-peer to classpath configure when gconf is disabled. * scripts/makemake.tcl: Set gnu/java/util/prefs/gconf and gnu/java/awt/dnd/peer/gtk to bc. Classify gnu/java/security/Configuration.java as generated source file. * gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java, gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java, gnu/java/lang/management/VMClassLoadingMXBeanImpl.java, gnu/java/lang/management/VMRuntimeMXBeanImpl.java, gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java, gnu/java/lang/management/VMThreadMXBeanImpl.java, gnu/java/lang/management/VMMemoryMXBeanImpl.java, gnu/java/lang/management/VMCompilationMXBeanImpl.java: New VM stub classes. * java/lang/management/VMManagementFactory.java: Likewise. * java/net/VMURLConnection.java: Likewise. * gnu/java/nio/VMChannel.java: Likewise. * java/lang/Thread.java (getState): Add stub implementation. * java/lang/Class.java (isEnum): Likewise. * java/lang/Class.h (isEnum): Likewise. * gnu/awt/xlib/XToolkit.java (getClasspathTextLayoutPeer): Removed. * javax/naming/spi/NamingManager.java: New override for StackWalker functionality. * configure, sources.am, Makefile.in, gcj/Makefile.in, include/Makefile.in, testsuite/Makefile.in: Regenerated. From-SVN: r116139
Diffstat (limited to 'libjava/classpath/gnu/java/nio')
-rw-r--r--libjava/classpath/gnu/java/nio/PipeImpl.java32
-rw-r--r--libjava/classpath/gnu/java/nio/SelectionKeyImpl.java22
-rw-r--r--libjava/classpath/gnu/java/nio/SelectorImpl.java9
-rw-r--r--libjava/classpath/gnu/java/nio/SocketChannelSelectionKeyImpl.java69
-rw-r--r--libjava/classpath/gnu/java/nio/channels/FileChannelImpl.java49
-rw-r--r--libjava/classpath/gnu/java/nio/charset/Provider.java30
6 files changed, 147 insertions, 64 deletions
diff --git a/libjava/classpath/gnu/java/nio/PipeImpl.java b/libjava/classpath/gnu/java/nio/PipeImpl.java
index f7b01c8..cccaa39 100644
--- a/libjava/classpath/gnu/java/nio/PipeImpl.java
+++ b/libjava/classpath/gnu/java/nio/PipeImpl.java
@@ -37,6 +37,7 @@ exception statement from your version. */
package gnu.java.nio;
+
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.Pipe;
@@ -47,12 +48,14 @@ class PipeImpl extends Pipe
public static final class SourceChannelImpl extends Pipe.SourceChannel
{
private int native_fd;
+ private VMChannel vmch;
public SourceChannelImpl (SelectorProvider selectorProvider,
int native_fd)
{
super (selectorProvider);
this.native_fd = native_fd;
+ vmch = VMChannel.getVMChannel(this);
}
protected final void implCloseSelectableChannel()
@@ -64,19 +67,19 @@ class PipeImpl extends Pipe
protected void implConfigureBlocking (boolean blocking)
throws IOException
{
- throw new Error ("Not implemented");
+ vmch.setBlocking(blocking);
}
public final int read (ByteBuffer src)
throws IOException
{
- throw new Error ("Not implemented");
+ return vmch.read(src);
}
public final long read (ByteBuffer[] srcs)
throws IOException
{
- return read (srcs, 0, srcs.length);
+ return vmch.readScattering(srcs, 0, srcs.length);
}
public final synchronized long read (ByteBuffer[] srcs, int offset,
@@ -89,13 +92,7 @@ class PipeImpl extends Pipe
|| len > srcs.length - offset)
throw new IndexOutOfBoundsException();
- long bytesRead = 0;
-
- for (int index = 0; index < len; index++)
- bytesRead += read (srcs [offset + index]);
-
- return bytesRead;
-
+ return vmch.readScattering(srcs, offset, len);
}
public final int getNativeFD()
@@ -107,12 +104,14 @@ class PipeImpl extends Pipe
public static final class SinkChannelImpl extends Pipe.SinkChannel
{
private int native_fd;
+ private VMChannel vmch;
public SinkChannelImpl (SelectorProvider selectorProvider,
int native_fd)
{
super (selectorProvider);
this.native_fd = native_fd;
+ vmch = VMChannel.getVMChannel(this);
}
protected final void implCloseSelectableChannel()
@@ -124,19 +123,19 @@ class PipeImpl extends Pipe
protected final void implConfigureBlocking (boolean blocking)
throws IOException
{
- throw new Error ("Not implemented");
+ vmch.setBlocking(blocking);
}
public final int write (ByteBuffer dst)
throws IOException
{
- throw new Error ("Not implemented");
+ return vmch.write(dst);
}
public final long write (ByteBuffer[] srcs)
throws IOException
{
- return write (srcs, 0, srcs.length);
+ return vmch.writeGathering(srcs, 0, srcs.length);
}
public final synchronized long write (ByteBuffer[] srcs, int offset, int len)
@@ -147,13 +146,8 @@ class PipeImpl extends Pipe
|| len < 0
|| len > srcs.length - offset)
throw new IndexOutOfBoundsException();
-
- long bytesWritten = 0;
- for (int index = 0; index < len; index++)
- bytesWritten += write (srcs [offset + index]);
-
- return bytesWritten;
+ return vmch.writeGathering(srcs, offset, len);
}
public final int getNativeFD()
diff --git a/libjava/classpath/gnu/java/nio/SelectionKeyImpl.java b/libjava/classpath/gnu/java/nio/SelectionKeyImpl.java
index a1f125e..8745377 100644
--- a/libjava/classpath/gnu/java/nio/SelectionKeyImpl.java
+++ b/libjava/classpath/gnu/java/nio/SelectionKeyImpl.java
@@ -1,5 +1,5 @@
/* SelectionKeyImpl.java --
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -47,8 +47,8 @@ public abstract class SelectionKeyImpl extends AbstractSelectionKey
{
private int readyOps;
private int interestOps;
- private SelectorImpl impl;
- SelectableChannel ch;
+ private final SelectorImpl impl;
+ final SelectableChannel ch;
public SelectionKeyImpl (SelectableChannel ch, SelectorImpl impl)
{
@@ -61,7 +61,7 @@ public abstract class SelectionKeyImpl extends AbstractSelectionKey
return ch;
}
- public int readyOps ()
+ public synchronized int readyOps ()
{
if (!isValid())
throw new CancelledKeyException();
@@ -69,7 +69,7 @@ public abstract class SelectionKeyImpl extends AbstractSelectionKey
return readyOps;
}
- public SelectionKey readyOps (int ops)
+ public synchronized SelectionKey readyOps (int ops)
{
if (!isValid())
throw new CancelledKeyException();
@@ -83,15 +83,21 @@ public abstract class SelectionKeyImpl extends AbstractSelectionKey
if (!isValid())
throw new CancelledKeyException();
- return interestOps;
+ synchronized (impl.selectedKeys())
+ {
+ return interestOps;
+ }
}
public SelectionKey interestOps (int ops)
{
if (!isValid())
throw new CancelledKeyException();
-
- interestOps = ops;
+
+ synchronized (impl.selectedKeys())
+ {
+ interestOps = ops;
+ }
return this;
}
diff --git a/libjava/classpath/gnu/java/nio/SelectorImpl.java b/libjava/classpath/gnu/java/nio/SelectorImpl.java
index e10f715..d0ec487 100644
--- a/libjava/classpath/gnu/java/nio/SelectorImpl.java
+++ b/libjava/classpath/gnu/java/nio/SelectorImpl.java
@@ -1,5 +1,5 @@
/* SelectorImpl.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.
@@ -379,16 +379,19 @@ public class SelectorImpl extends AbstractSelector
result = new DatagramChannelSelectionKey (ch, this);
else if (ch instanceof ServerSocketChannelImpl)
result = new ServerSocketChannelSelectionKey (ch, this);
+ else if (ch instanceof gnu.java.nio.SocketChannelImpl)
+ result = new gnu.java.nio.SocketChannelSelectionKeyImpl((gnu.java.nio.SocketChannelImpl)ch, this);
else
throw new InternalError ("No known channel type");
synchronized (keys)
{
keys.add (result);
+
+ result.interestOps (ops);
+ result.attach (att);
}
- result.interestOps (ops);
- result.attach (att);
return result;
}
}
diff --git a/libjava/classpath/gnu/java/nio/SocketChannelSelectionKeyImpl.java b/libjava/classpath/gnu/java/nio/SocketChannelSelectionKeyImpl.java
new file mode 100644
index 0000000..30fb2df
--- /dev/null
+++ b/libjava/classpath/gnu/java/nio/SocketChannelSelectionKeyImpl.java
@@ -0,0 +1,69 @@
+/* SocketChannelSelectionKey.java -- Selection key for Socket Channel
+ Copyright (C) 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+
+/**
+ * @author Michael Barker <mike@middlesoft.co.uk>
+ *
+ */
+public class SocketChannelSelectionKeyImpl extends SelectionKeyImpl
+{
+
+ SocketChannelImpl ch;
+
+ /**
+ * @param ch
+ * @param impl
+ */
+ public SocketChannelSelectionKeyImpl(SocketChannelImpl ch, SelectorImpl impl)
+ {
+ super(ch, impl);
+ this.ch = (SocketChannelImpl) ch;
+ }
+
+ /**
+ * Returns the native file/socket descriptor as an int.
+ */
+ public int getNativeFD()
+ {
+ return ch.getPlainSocketImpl().getNativeFD();
+ }
+
+}
diff --git a/libjava/classpath/gnu/java/nio/channels/FileChannelImpl.java b/libjava/classpath/gnu/java/nio/channels/FileChannelImpl.java
index 671ae5b..ed439e1 100644
--- a/libjava/classpath/gnu/java/nio/channels/FileChannelImpl.java
+++ b/libjava/classpath/gnu/java/nio/channels/FileChannelImpl.java
@@ -40,6 +40,7 @@ package gnu.java.nio.channels;
import gnu.classpath.Configuration;
import gnu.java.nio.FileLockImpl;
+import gnu.java.nio.VMChannel;
import java.io.File;
import java.io.FileNotFoundException;
@@ -102,6 +103,7 @@ public final class FileChannelImpl extends FileChannel
// we want to make sure this has the value -1. This is the most
// efficient way to accomplish that.
private int fd = -1;
+ private VMChannel ch;
private int mode;
@@ -123,6 +125,7 @@ public final class FileChannelImpl extends FileChannel
description = path;
fd = open (path, mode);
this.mode = mode;
+ this.ch = VMChannel.getVMChannel(this);
// First open the file and then check if it is a a directory
// to avoid race condition.
@@ -155,6 +158,7 @@ public final class FileChannelImpl extends FileChannel
this.fd = fd;
this.mode = mode;
this.description = "descriptor(" + fd + ")";
+ this.ch = VMChannel.getVMChannel(this);
}
private native int open (String path, int mode) throws FileNotFoundException;
@@ -181,6 +185,7 @@ public final class FileChannelImpl extends FileChannel
public int read (ByteBuffer dst) throws IOException
{
+ /*
int result;
byte[] buffer = new byte [dst.remaining ()];
@@ -190,6 +195,8 @@ public final class FileChannelImpl extends FileChannel
dst.put (buffer, 0, result);
return result;
+ */
+ return ch.read(dst);
}
public int read (ByteBuffer dst, long position)
@@ -214,33 +221,12 @@ public final class FileChannelImpl extends FileChannel
public long read (ByteBuffer[] dsts, int offset, int length)
throws IOException
{
- long result = 0;
-
- for (int i = offset; i < offset + length; i++)
- {
- result += read (dsts [i]);
- }
-
- return result;
+ return ch.readScattering(dsts, offset, length);
}
public int write (ByteBuffer src) throws IOException
{
- int len = src.remaining ();
- if (src.hasArray())
- {
- byte[] buffer = src.array();
- write(buffer, src.arrayOffset() + src.position(), len);
- src.position(src.position() + len);
- }
- else
- {
- // Use a more efficient native method! FIXME!
- byte[] buffer = new byte [len];
- src.get (buffer, 0, len);
- write (buffer, 0, len);
- }
- return len;
+ return ch.write(src);
}
public int write (ByteBuffer src, long position)
@@ -274,14 +260,7 @@ public final class FileChannelImpl extends FileChannel
public long write(ByteBuffer[] srcs, int offset, int length)
throws IOException
{
- long result = 0;
-
- for (int i = offset;i < offset + length;i++)
- {
- result += write (srcs[i]);
- }
-
- return result;
+ return ch.writeGathering(srcs, offset, length);
}
public native MappedByteBuffer mapImpl (char mode, long position, int size)
@@ -563,4 +542,12 @@ public final class FileChannelImpl extends FileChannel
+ ",mode=" + mode + ","
+ description + "]");
}
+
+ /**
+ * @return The native file descriptor.
+ */
+ public int getNativeFD()
+ {
+ return fd;
+ }
}
diff --git a/libjava/classpath/gnu/java/nio/charset/Provider.java b/libjava/classpath/gnu/java/nio/charset/Provider.java
index ad3b1da..b56e5a9 100644
--- a/libjava/classpath/gnu/java/nio/charset/Provider.java
+++ b/libjava/classpath/gnu/java/nio/charset/Provider.java
@@ -155,9 +155,9 @@ public final class Provider extends CharsetProvider
/**
* Load non-mandatory charsets.
*/
- private void loadExtended ()
+ private synchronized void loadExtended ()
{
- if(extendedLoaded)
+ if (extendedLoaded)
return;
addCharset (new ISO_8859_3 ()); // ISO-8859-3 aka ISO-LATIN-3
@@ -165,6 +165,12 @@ public final class Provider extends CharsetProvider
addCharset (new ISO_8859_8 ()); // ISO-8859-8 (Hebrew)
// Some more codepages
+ addCharset (new Cp424());
+ addCharset (new Cp437());
+ addCharset (new Cp737());
+ addCharset (new Cp775());
+ addCharset (new Cp850());
+ addCharset (new Cp852());
addCharset (new Cp855()); // IBM Cyrillic
addCharset (new Cp857()); // IBM Turkish
addCharset (new Cp860()); // MSDOS Portugese
@@ -176,6 +182,24 @@ public final class Provider extends CharsetProvider
addCharset (new Cp866()); // MSDOS Russian
addCharset (new Cp869()); // IBM modern Greek
addCharset (new Cp874()); // IBM Thai
+
+ addCharset (new MacCentralEurope());
+ addCharset (new MacCroatian());
+ addCharset (new MacCyrillic());
+ addCharset (new MacDingbat());
+ addCharset (new MacGreek());
+ addCharset (new MacIceland());
+ addCharset (new MacRoman());
+ addCharset (new MacRomania());
+ addCharset (new MacSymbol());
+ addCharset (new MacThai());
+ addCharset (new MacTurkish());
+ addCharset (new MS874());
+
+ addCharset (new Windows1255());
+ addCharset (new Windows1256());
+ addCharset (new Windows1258());
+
extendedLoaded = true;
}
@@ -199,7 +223,7 @@ public final class Provider extends CharsetProvider
public Charset charsetForName (String charsetName)
{
Charset cs = (Charset) charsets.get(canonicalNames.get(charsetName.toLowerCase()));
- if(cs == null && !extendedLoaded)
+ if (cs == null)
{
loadExtended();
cs = (Charset) charsets.get(canonicalNames.get(charsetName.toLowerCase()));