aboutsummaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
author(no author) <(no author)@138bc75d-0d04-0410-961f-82ee72b054a4>2002-11-25 04:26:34 +0000
committer(no author) <(no author)@138bc75d-0d04-0410-961f-82ee72b054a4>2002-11-25 04:26:34 +0000
commit42be37ca6dca3440cf7b0582abbd268d0fc9f8b0 (patch)
tree89699bceb70a3d5066ff17bc08df6b94f2983f49 /libjava
parentb6e64bcf8715a1d5f6bce7678f9d4c9f82711dce (diff)
This commit was manufactured by cvs2svn to create branch
'tree-ssa-20020619-branch'. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/tree-ssa-20020619-branch@59447 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r--libjava/gnu/java/nio/FileChannelImpl.java234
-rw-r--r--libjava/gnu/java/nio/PipeImpl.java57
-rw-r--r--libjava/gnu/java/nio/SelectorProviderImpl.java77
-rw-r--r--libjava/gnu/java/nio/charset/ISO_8859_1.java132
-rw-r--r--libjava/gnu/java/nio/charset/Provider.java135
-rw-r--r--libjava/gnu/java/nio/charset/US_ASCII.java137
-rw-r--r--libjava/gnu/java/nio/charset/UTF_16.java75
-rw-r--r--libjava/gnu/java/nio/charset/UTF_16BE.java75
-rw-r--r--libjava/gnu/java/nio/charset/UTF_16Decoder.java169
-rw-r--r--libjava/gnu/java/nio/charset/UTF_16Encoder.java153
-rw-r--r--libjava/gnu/java/nio/charset/UTF_16LE.java75
-rw-r--r--libjava/gnu/java/nio/charset/UTF_8.java279
-rw-r--r--libjava/java/awt/color/ICC_ProfileGray.java71
-rw-r--r--libjava/java/awt/color/ICC_ProfileRGB.java80
-rw-r--r--libjava/java/nio/BufferOverflowException.java51
-rw-r--r--libjava/java/nio/BufferUnderflowException.java51
-rw-r--r--libjava/java/nio/CharBuffer.java291
-rw-r--r--libjava/java/nio/DoubleBuffer.java225
-rw-r--r--libjava/java/nio/FloatBuffer.java224
-rw-r--r--libjava/java/nio/IntBuffer.java225
-rw-r--r--libjava/java/nio/InvalidMarkException.java52
-rw-r--r--libjava/java/nio/LongBuffer.java226
-rw-r--r--libjava/java/nio/ReadOnlyBufferException.java52
-rw-r--r--libjava/java/nio/ShortBuffer.java226
-rw-r--r--libjava/java/nio/channels/AsynchronousCloseException.java52
-rw-r--r--libjava/java/nio/channels/CancelledKeyException.java52
-rw-r--r--libjava/java/nio/channels/ClosedByInterruptException.java52
-rw-r--r--libjava/java/nio/channels/ClosedSelectorException.java52
-rw-r--r--libjava/java/nio/channels/ConnectionPendingException.java52
-rw-r--r--libjava/java/nio/channels/FileChannel.java135
-rw-r--r--libjava/java/nio/channels/FileLockInterruptionException.java54
-rw-r--r--libjava/java/nio/channels/IllegalSelectorException.java52
-rw-r--r--libjava/java/nio/channels/NoConnectionPendingException.java52
-rw-r--r--libjava/java/nio/channels/NonReadableChannelException.java52
-rw-r--r--libjava/java/nio/channels/NonWritableChannelException.java52
-rw-r--r--libjava/java/nio/channels/NotYetBoundException.java52
-rw-r--r--libjava/java/nio/channels/NotYetConnectedException.java52
-rw-r--r--libjava/java/nio/channels/OverlappingFileLockException.java52
-rw-r--r--libjava/java/nio/channels/UnresolvedAddressException.java52
-rw-r--r--libjava/java/nio/channels/UnsupportedAddressTypeException.java52
-rw-r--r--libjava/java/nio/charset/CharsetDecoder.java312
-rw-r--r--libjava/java/nio/charset/CharsetEncoder.java360
-rw-r--r--libjava/java/nio/charset/CoderResult.java193
-rw-r--r--libjava/testsuite/libjava.lang/pr8676.java11
-rw-r--r--libjava/testsuite/libjava.lang/pr8676.out0
45 files changed, 5165 insertions, 0 deletions
diff --git a/libjava/gnu/java/nio/FileChannelImpl.java b/libjava/gnu/java/nio/FileChannelImpl.java
new file mode 100644
index 00000000000..26b48e5e51c
--- /dev/null
+++ b/libjava/gnu/java/nio/FileChannelImpl.java
@@ -0,0 +1,234 @@
+/* FileChannelImpl.java --
+ Copyright (C) 2002 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.io.EOFException;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.ByteBuffer;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.FileChannel;
+
+/**
+ * This file is not user visible !
+ * But alas, Java does not have a concept of friendly packages
+ * so this class is public.
+ * Instances of this class are created by invoking getChannel
+ * Upon a Input/Output/RandomAccessFile object.
+ */
+
+public class FileChannelImpl extends FileChannel
+{
+ public long address;
+ public int length;
+ public int fd;
+ public MappedByteBuffer buf;
+ public Object file_obj; // just to keep it live...
+
+ /**
+ * This method came from java.io.RandomAccessFile
+ * It is private there so we will repeat it here.
+ */
+// private native long lengthInternal (int native_fd) throws IOException;
+ private long lengthInternal (int native_fd) throws IOException
+ {
+ return 0;
+ };
+
+ public FileChannelImpl (int fd, Object obj)
+ {
+ this.fd = fd;
+ this.file_obj = obj;
+ }
+
+ public long size () throws IOException
+ {
+ return lengthInternal (fd);
+ }
+
+ protected void implCloseChannel() throws IOException
+ {
+ if (address != 0)
+ {
+ nio_unmmap_file (fd, address, (int) length);
+ }
+
+ // FIXME
+ fd = 0;
+
+ if (file_obj instanceof RandomAccessFile)
+ {
+ RandomAccessFile o = (RandomAccessFile) file_obj;
+ o.close();
+ }
+ else if (file_obj instanceof FileInputStream)
+ {
+ FileInputStream o = (FileInputStream) file_obj;
+ o.close();
+ }
+ else if (file_obj instanceof FileOutputStream)
+ {
+ FileOutputStream o = (FileOutputStream) file_obj;
+ o.close();
+ }
+ }
+
+ public int read (ByteBuffer dst) throws IOException
+ {
+ int w = 0;
+ int s = (int)size();
+
+ if (buf == null)
+ {
+ throw new EOFException("file not mapped");
+ }
+
+ for (int i=0; i<s; i++)
+ {
+ dst.put( buf.get() );
+ }
+
+ return s;
+ }
+
+ public long read (ByteBuffer[] dsts) throws IOException
+ {
+ return read (dsts, 0, dsts.length);
+ }
+
+ public long read (ByteBuffer[] dsts, int offset, int length)
+ throws IOException
+ {
+ long result = 0;
+
+ for (int i = offset; i < offset + length; i++)
+ {
+ result += write (dsts[i]);
+ }
+
+ return result;
+ }
+
+ public int write (ByteBuffer src) throws IOException
+ {
+ int w = 0;
+
+ if (buf == null)
+ {
+ throw new EOFException ("file not mapped");
+ }
+
+ while (src.hasRemaining ())
+ {
+ buf.put (src.get ());
+ w++;
+ }
+
+ return w;
+ }
+
+ public long write(ByteBuffer[] srcs, int offset, int length)
+ throws IOException
+ {
+ long res = 0;
+
+ for (int i = offset;i < offset + length;i++)
+ {
+ res += write (srcs[i]);
+ }
+ return res;
+ }
+
+ public MappedByteBuffer map (FileChannel.MapMode mode, long position,
+ long size)
+ throws IOException
+ {
+// int cmode = mode.m;
+// address = nio_mmap_file (fd, position, size, cmode);
+// length = size;
+// buf = new MappedByteFileBuffer (this);
+// return buf;
+ return null;
+ }
+
+ static MappedByteBuffer create_direct_mapped_buffer (long address,
+ long length)
+ {
+// FileChannelImpl ch = new FileChannelImpl (-1, null);
+// ch.address = address;
+// ch.length = (int) length;
+// ch.buf = new MappedByteFileBuffer (ch);
+// return ch.buf;
+ return null;
+ }
+
+ public long write (ByteBuffer[] srcs)
+ throws IOException
+ {
+ return write (srcs, 0, srcs.length);
+ }
+
+ /**
+ * msync with the disk
+ */
+ public void force (boolean metaData)
+ {
+ nio_msync (fd, address, length);
+ }
+
+// static native long nio_mmap_file (int fd, long pos, int size, int mode);
+
+// static native void nio_unmmap_file (int fd, long address, int size);
+
+// static native void nio_msync (int fd, long address, int length);
+
+ static long nio_mmap_file (int fd, long pos, int size, int mode)
+ {
+ return 0;
+ }
+
+ static void nio_unmmap_file (int fd, long address, int size)
+ {
+ };
+
+ static void nio_msync (int fd, long address, int length)
+ {
+ };
+}
diff --git a/libjava/gnu/java/nio/PipeImpl.java b/libjava/gnu/java/nio/PipeImpl.java
new file mode 100644
index 00000000000..77341e7f4a0
--- /dev/null
+++ b/libjava/gnu/java/nio/PipeImpl.java
@@ -0,0 +1,57 @@
+/* PipeImpl.java --
+ Copyright (C) 2002 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.Pipe;
+
+class PipeImpl extends Pipe
+{
+ public PipeImpl()
+ {
+ }
+
+ public Pipe.SinkChannel sink()
+ {
+ return null;
+ }
+
+ public Pipe.SourceChannel source()
+ {
+ return null;
+ }
+}
diff --git a/libjava/gnu/java/nio/SelectorProviderImpl.java b/libjava/gnu/java/nio/SelectorProviderImpl.java
new file mode 100644
index 00000000000..3fedfc73546
--- /dev/null
+++ b/libjava/gnu/java/nio/SelectorProviderImpl.java
@@ -0,0 +1,77 @@
+/* SelectorProviderImpl.java --
+ Copyright (C) 2002 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.DatagramChannel;
+import java.nio.channels.Pipe;
+import java.nio.channels.ServerSocketChannel;
+import java.nio.channels.SocketChannel;
+import java.nio.channels.spi.SelectorProvider;
+import java.nio.channels.spi.AbstractSelector;
+
+public class SelectorProviderImpl extends SelectorProvider
+{
+ public SelectorProviderImpl ()
+ {
+ }
+
+ public DatagramChannel openDatagramChannel ()
+ {
+ return new DatagramChannelImpl (this);
+ }
+
+ public Pipe openPipe ()
+ {
+ return new PipeImpl ();
+ }
+
+ public AbstractSelector openSelector ()
+ {
+ return new SelectorImpl (this);
+ }
+
+ public ServerSocketChannel openServerSocketChannel ()
+ {
+ return new ServerSocketChannelImpl (this);
+ }
+
+ public SocketChannel openSocketChannel ()
+ {
+ return new SocketChannelImpl (this);
+ }
+}
diff --git a/libjava/gnu/java/nio/charset/ISO_8859_1.java b/libjava/gnu/java/nio/charset/ISO_8859_1.java
new file mode 100644
index 00000000000..f29fa260300
--- /dev/null
+++ b/libjava/gnu/java/nio/charset/ISO_8859_1.java
@@ -0,0 +1,132 @@
+/* ISO_8859_1.java --
+ Copyright (C) 2002 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.charset;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CoderResult;
+
+/**
+ * ISO-8859-1 charset.
+ *
+ * @author Jesse Rosenstock
+ */
+final class ISO_8859_1 extends Charset
+{
+ ISO_8859_1 ()
+ {
+ super ("ISO-8859-1", new String[]{"ISO-LATIN-1"});
+ }
+
+ public boolean contains (Charset cs)
+ {
+ return cs instanceof US_ASCII || cs instanceof ISO_8859_1;
+ }
+
+ public CharsetDecoder newDecoder ()
+ {
+ return new Decoder (this);
+ }
+
+ public CharsetEncoder newEncoder ()
+ {
+ return new Encoder (this);
+ }
+
+ private static final class Decoder extends CharsetDecoder
+ {
+ private Decoder (Charset cs)
+ {
+ super (cs, 1.0f, 1.0f);
+ }
+
+ protected CoderResult decodeLoop (ByteBuffer in, CharBuffer out)
+ {
+ // TODO: Optimize this in the case in.hasArray() / out.hasArray()
+ while (in.hasRemaining ())
+ {
+ byte b = in.get ();
+
+ if (!out.hasRemaining ())
+ {
+ in.position (in.position () - 1);
+ return CoderResult.OVERFLOW;
+ }
+
+ out.put ((char) (b & 0xFF));
+ }
+
+ return CoderResult.UNDERFLOW;
+ }
+ }
+
+ private static final class Encoder extends CharsetEncoder
+ {
+ private Encoder (Charset cs)
+ {
+ super (cs, 1.0f, 1.0f);
+ }
+
+ protected CoderResult encodeLoop (CharBuffer in, ByteBuffer out)
+ {
+ // TODO: Optimize this in the case in.hasArray() / out.hasArray()
+ while (in.hasRemaining ())
+ {
+ char c = in.get ();
+
+ if (c > 0xFF)
+ {
+ in.position (in.position () - 1);
+ return CoderResult.unmappableForLength (1);
+ }
+ if (!out.hasRemaining ())
+ {
+ in.position (in.position () - 1);
+ return CoderResult.OVERFLOW;
+ }
+
+ out.put ((byte) c);
+ }
+
+ return CoderResult.UNDERFLOW;
+ }
+ }
+}
diff --git a/libjava/gnu/java/nio/charset/Provider.java b/libjava/gnu/java/nio/charset/Provider.java
new file mode 100644
index 00000000000..13f637113e5
--- /dev/null
+++ b/libjava/gnu/java/nio/charset/Provider.java
@@ -0,0 +1,135 @@
+/* Provider.java --
+ Copyright (C) 2002 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.charset;
+
+import java.nio.charset.Charset;
+import java.nio.charset.spi.CharsetProvider;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ * Charset provider for the required charsets. Used by
+ * {@link Charset#charsetForName} and * {@link Charset#availableCharsets}.
+ *
+ * @author Jesse Rosenstock
+ * @see Charset
+ */
+public final class Provider extends CharsetProvider
+{
+ private static Provider singleton;
+
+ static
+ {
+ synchronized (Provider.class)
+ {
+ singleton = null;
+ }
+ }
+
+ /**
+ * Map from charset name to charset canonical name.
+ */
+ private final HashMap canonicalNames;
+
+ /**
+ * Map from canonical name to Charset.
+ * TODO: We may want to use soft references. We would then need to keep
+ * track of the class name to regenerate the object.
+ */
+ private final HashMap charsets;
+
+ private Provider ()
+ {
+ // FIXME: We might need to make the name comparison case insensitive.
+ // Verify this with the Sun JDK.
+ canonicalNames = new HashMap ();
+ charsets = new HashMap ();
+
+ // US-ASCII aka ISO646-US
+ addCharset (new US_ASCII ());
+
+ // ISO-8859-1 aka ISO-LATIN-1
+ addCharset (new ISO_8859_1 ());
+
+ // UTF-8
+ addCharset (new UTF_8 ());
+
+ // UTF-16BE
+ addCharset (new UTF_16BE ());
+
+ // UTF-16LE
+ addCharset (new UTF_16LE ());
+
+ // UTF-16
+ addCharset (new UTF_16 ());
+ }
+
+ public Iterator charsets ()
+ {
+ return Collections.unmodifiableCollection (charsets.values ())
+ .iterator ();
+ }
+
+ public Charset charsetForName (String charsetName)
+ {
+ return (Charset) charsets.get (canonicalize (charsetName));
+ }
+
+ private Object canonicalize (String charsetName)
+ {
+ Object o = canonicalNames.get (charsetName);
+ return o == null ? charsetName : o;
+ }
+
+ private void addCharset (Charset cs)
+ {
+ String canonicalName = cs.name ();
+ charsets.put (canonicalName, cs);
+
+ for (Iterator i = cs.aliases ().iterator (); i.hasNext (); )
+ canonicalNames.put (i.next (), canonicalName);
+ }
+
+ public static synchronized Provider provider ()
+ {
+ if (singleton == null)
+ singleton = new Provider ();
+ return singleton;
+ }
+}
diff --git a/libjava/gnu/java/nio/charset/US_ASCII.java b/libjava/gnu/java/nio/charset/US_ASCII.java
new file mode 100644
index 00000000000..a1ff2510402
--- /dev/null
+++ b/libjava/gnu/java/nio/charset/US_ASCII.java
@@ -0,0 +1,137 @@
+/* US_ASCII.java --
+ Copyright (C) 2002 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.charset;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CoderResult;
+
+/**
+ * US-ASCII charset.
+ *
+ * @author Jesse Rosenstock
+ */
+final class US_ASCII extends Charset
+{
+ US_ASCII ()
+ {
+ super ("US-ASCII", new String[]{"ISO646-US"});
+ }
+
+ public boolean contains (Charset cs)
+ {
+ return cs instanceof US_ASCII;
+ }
+
+ public CharsetDecoder newDecoder ()
+ {
+ return new Decoder (this);
+ }
+
+ public CharsetEncoder newEncoder ()
+ {
+ return new Encoder (this);
+ }
+
+ private static final class Decoder extends CharsetDecoder
+ {
+ private Decoder (Charset cs)
+ {
+ super (cs, 1.0f, 1.0f);
+ }
+
+ protected CoderResult decodeLoop (ByteBuffer in, CharBuffer out)
+ {
+ // TODO: Optimize this in the case in.hasArray() / out.hasArray()
+ while (in.hasRemaining ())
+ {
+ byte b = in.get ();
+
+ if (b < 0)
+ {
+ in.position (in.position () - 1);
+ return CoderResult.malformedForLength (1);
+ }
+ if (!out.hasRemaining ())
+ {
+ in.position (in.position () - 1);
+ return CoderResult.OVERFLOW;
+ }
+
+ out.put ((char) b);
+ }
+
+ return CoderResult.UNDERFLOW;
+ }
+ }
+
+ private static final class Encoder extends CharsetEncoder
+ {
+ private Encoder (Charset cs)
+ {
+ super (cs, 1.0f, 1.0f);
+ }
+
+ protected CoderResult encodeLoop (CharBuffer in, ByteBuffer out)
+ {
+ // TODO: Optimize this in the case in.hasArray() / out.hasArray()
+ while (in.hasRemaining ())
+ {
+ char c = in.get ();
+
+ if (c > Byte.MAX_VALUE)
+ {
+ in.position (in.position () - 1);
+ return CoderResult.unmappableForLength (1);
+ }
+ if (!out.hasRemaining ())
+ {
+ in.position (in.position () - 1);
+ return CoderResult.OVERFLOW;
+ }
+
+ out.put ((byte) c);
+ }
+
+ return CoderResult.UNDERFLOW;
+ }
+ }
+}
diff --git a/libjava/gnu/java/nio/charset/UTF_16.java b/libjava/gnu/java/nio/charset/UTF_16.java
new file mode 100644
index 00000000000..18c9be7f4b2
--- /dev/null
+++ b/libjava/gnu/java/nio/charset/UTF_16.java
@@ -0,0 +1,75 @@
+/* UTF_16.java --
+ Copyright (C) 2002 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.charset;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CoderResult;
+
+/**
+ * UTF-16 charset.
+ *
+ * @author Jesse Rosenstock
+ */
+final class UTF_16 extends Charset
+{
+ UTF_16 ()
+ {
+ super ("UTF-16", null);
+ }
+
+ public boolean contains (Charset cs)
+ {
+ return cs instanceof US_ASCII || cs instanceof ISO_8859_1
+ || cs instanceof UTF_8 || cs instanceof UTF_16BE
+ || cs instanceof UTF_16LE || cs instanceof UTF_16;
+ }
+
+ public CharsetDecoder newDecoder ()
+ {
+ return new UTF_16Decoder (this, UTF_16Decoder.UNKNOWN_ENDIAN);
+ }
+
+ public CharsetEncoder newEncoder ()
+ {
+ return new UTF_16Encoder (this, UTF_16Encoder.BIG_ENDIAN, false);
+ }
+}
diff --git a/libjava/gnu/java/nio/charset/UTF_16BE.java b/libjava/gnu/java/nio/charset/UTF_16BE.java
new file mode 100644
index 00000000000..6fb28cdf830
--- /dev/null
+++ b/libjava/gnu/java/nio/charset/UTF_16BE.java
@@ -0,0 +1,75 @@
+/* UTF_16BE.java --
+ Copyright (C) 2002 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.charset;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CoderResult;
+
+/**
+ * UTF-16BE charset.
+ *
+ * @author Jesse Rosenstock
+ */
+final class UTF_16BE extends Charset
+{
+ UTF_16BE ()
+ {
+ super ("UTF-16BE", null);
+ }
+
+ public boolean contains (Charset cs)
+ {
+ return cs instanceof US_ASCII || cs instanceof ISO_8859_1
+ || cs instanceof UTF_8 || cs instanceof UTF_16BE
+ || cs instanceof UTF_16LE || cs instanceof UTF_16;
+ }
+
+ public CharsetDecoder newDecoder ()
+ {
+ return new UTF_16Decoder (this, UTF_16Decoder.BIG_ENDIAN);
+ }
+
+ public CharsetEncoder newEncoder ()
+ {
+ return new UTF_16Encoder (this, UTF_16Encoder.BIG_ENDIAN, true);
+ }
+}
diff --git a/libjava/gnu/java/nio/charset/UTF_16Decoder.java b/libjava/gnu/java/nio/charset/UTF_16Decoder.java
new file mode 100644
index 00000000000..c8e474d5741
--- /dev/null
+++ b/libjava/gnu/java/nio/charset/UTF_16Decoder.java
@@ -0,0 +1,169 @@
+/* UTF_16Decoder.java --
+ Copyright (C) 2002 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.charset;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CoderResult;
+
+/**
+ * Decoder for UTF-16, UTF-15LE, and UTF-16BE.
+ *
+ * @author Jesse Rosenstock
+ */
+final class UTF_16Decoder extends CharsetDecoder
+{
+ // byte orders
+ static final int BIG_ENDIAN = 0;
+ static final int LITTLE_ENDIAN = 1;
+ static final int UNKNOWN_ENDIAN = 2;
+
+ private static final char BYTE_ORDER_MARK = '\uFEFF';
+ private static final char REVERSED_BYTE_ORDER_MARK = '\uFFFE';
+
+ private final int originalByteOrder;
+ private int byteOrder;
+
+ UTF_16Decoder (Charset cs, int byteOrder)
+ {
+ super (cs, 0.5f, 1.0f);
+ this.originalByteOrder = byteOrder;
+ this.byteOrder = byteOrder;
+ }
+
+ protected CoderResult decodeLoop (ByteBuffer in, CharBuffer out)
+ {
+ // TODO: Optimize this in the case in.hasArray() / out.hasArray()
+
+ int inPos = in.position ();
+ try
+ {
+ while (in.remaining () >= 2)
+ {
+ byte b1 = in.get ();
+ byte b2 = in.get ();
+
+ // handle byte order mark
+ if (byteOrder == UNKNOWN_ENDIAN)
+ {
+ char c = (char) ((b1 << 8) | b2);
+ if (c == BYTE_ORDER_MARK)
+ {
+ byteOrder = BIG_ENDIAN;
+ inPos += 2;
+ continue;
+ }
+ else if (c == REVERSED_BYTE_ORDER_MARK)
+ {
+ byteOrder = LITTLE_ENDIAN;
+ inPos += 2;
+ continue;
+ }
+ else
+ {
+ // assume big endian, do not consume bytes,
+ // continue with normal processing
+ byteOrder = BIG_ENDIAN;
+ }
+ }
+
+ char c = byteOrder == BIG_ENDIAN ? (char) ((b1 << 8) | b2)
+ : (char) ((b2 << 8) | b1);
+
+ if (0xD800 <= c && c <= 0xDFFF)
+ {
+ // c is a surrogate
+
+ // make sure c is a high surrogate
+ if (c > 0xDBFF)
+ return CoderResult.malformedForLength (2);
+ if (in.remaining () < 2)
+ return CoderResult.UNDERFLOW;
+ byte b3 = in.get ();
+ byte b4 = in.get ();
+ char d = byteOrder == BIG_ENDIAN ? (char) ((b3 << 8) | b4)
+ : (char) ((b4 << 8) | b3);
+ // make sure d is a low surrogate
+ if (d < 0xDC00 || d > 0xDFFF)
+ return CoderResult.malformedForLength (2);
+ out.put (c);
+ out.put (d);
+ inPos += 4;
+ }
+ else
+ {
+ if (!out.hasRemaining ())
+ return CoderResult.UNDERFLOW;
+ out.put (c);
+ inPos += 2;
+ }
+ }
+
+ return CoderResult.UNDERFLOW;
+ }
+ finally
+ {
+ in.position (inPos);
+ }
+ }
+
+ /**
+ * Writes <code>c</code> to <code>out</code> in the byte order
+ * specified by <code>byteOrder</code>.
+ **/
+ private void put (ByteBuffer out, char c)
+ {
+ if (byteOrder == BIG_ENDIAN)
+ {
+ out.put ((byte) (c >> 8));
+ out.put ((byte) (c & 0xFF));
+ }
+ else
+ {
+ out.put ((byte) (c & 0xFF));
+ out.put ((byte) (c >> 8));
+ }
+ }
+
+ protected void implReset ()
+ {
+ byteOrder = originalByteOrder;
+ }
+}
diff --git a/libjava/gnu/java/nio/charset/UTF_16Encoder.java b/libjava/gnu/java/nio/charset/UTF_16Encoder.java
new file mode 100644
index 00000000000..b0cb9ed8ce1
--- /dev/null
+++ b/libjava/gnu/java/nio/charset/UTF_16Encoder.java
@@ -0,0 +1,153 @@
+/* UTF_16Encoder.java --
+ Copyright (C) 2002 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.charset;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CoderResult;
+
+/**
+ * Encoder for UTF-16, UTF-15LE, and UTF-16BE.
+ *
+ * @author Jesse Rosenstock
+ */
+final class UTF_16Encoder extends CharsetEncoder
+{
+ // byte orders
+ static final int BIG_ENDIAN = 0;
+ static final int LITTLE_ENDIAN = 1;
+
+ private static final char BYTE_ORDER_MARK = '\uFEFF';
+
+ private final int byteOrder;
+ private final boolean useByteOrderMark;
+ private boolean needsByteOrderMark;
+
+ UTF_16Encoder (Charset cs, int byteOrder, boolean useByteOrderMark)
+ {
+ super (cs, 2.0f,
+ useByteOrderMark ? 4.0f : 2.0f,
+ byteOrder == BIG_ENDIAN
+ ? new byte[] { (byte) 0xFF, (byte) 0xFD }
+ : new byte[] { (byte) 0xFD, (byte) 0xFF });
+ this.byteOrder = byteOrder;
+ this.useByteOrderMark = useByteOrderMark;
+ this.needsByteOrderMark = useByteOrderMark;
+ }
+
+ protected CoderResult encodeLoop (CharBuffer in, ByteBuffer out)
+ {
+ // TODO: Optimize this in the case in.hasArray() / out.hasArray()
+
+ if (needsByteOrderMark)
+ {
+ if (out.remaining () < 2)
+ return CoderResult.OVERFLOW;
+ put (out, BYTE_ORDER_MARK);
+ needsByteOrderMark = false;
+ }
+
+ int inPos = in.position ();
+ try
+ {
+ while (in.hasRemaining ())
+ {
+ char c = in.get ();
+
+ if (0xD800 <= c && c <= 0xDFFF)
+ {
+ // c is a surrogate
+
+ // make sure c is a high surrogate
+ if (c > 0xDBFF)
+ return CoderResult.malformedForLength (1);
+ if (in.remaining () < 1)
+ return CoderResult.UNDERFLOW;
+ char d = in.get ();
+ // make sure d is a low surrogate
+ if (d < 0xDC00 || d > 0xDFFF)
+ return CoderResult.malformedForLength (1);
+ put (out, c);
+ put (out, d);
+ inPos += 2;
+ }
+ else
+ {
+ if (out.remaining () < 2)
+ return CoderResult.OVERFLOW;
+ put (out, c);
+ inPos++;
+ }
+ }
+
+ return CoderResult.UNDERFLOW;
+ }
+ finally
+ {
+ in.position (inPos);
+ }
+ }
+
+ /**
+ * Writes <code>c</code> to <code>out</code> in the byte order
+ * specified by <code>byteOrder</code>.
+ **/
+ private void put (ByteBuffer out, char c)
+ {
+ if (byteOrder == BIG_ENDIAN)
+ {
+ out.put ((byte) (c >> 8));
+ out.put ((byte) (c & 0xFF));
+ }
+ else
+ {
+ out.put ((byte) (c & 0xFF));
+ out.put ((byte) (c >> 8));
+ }
+ }
+
+ protected void implReset ()
+ {
+ needsByteOrderMark = useByteOrderMark;
+ }
+
+ // TODO: override canEncode(char) and canEncode(CharSequence)
+ // for performance
+}
diff --git a/libjava/gnu/java/nio/charset/UTF_16LE.java b/libjava/gnu/java/nio/charset/UTF_16LE.java
new file mode 100644
index 00000000000..b914ae07273
--- /dev/null
+++ b/libjava/gnu/java/nio/charset/UTF_16LE.java
@@ -0,0 +1,75 @@
+/* UTF_16LE.java --
+ Copyright (C) 2002 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.charset;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CoderResult;
+
+/**
+ * UTF-16LE charset.
+ *
+ * @author Jesse Rosenstock
+ */
+final class UTF_16LE extends Charset
+{
+ UTF_16LE ()
+ {
+ super ("UTF-16LE", null);
+ }
+
+ public boolean contains (Charset cs)
+ {
+ return cs instanceof US_ASCII || cs instanceof ISO_8859_1
+ || cs instanceof UTF_8 || cs instanceof UTF_16BE
+ || cs instanceof UTF_16LE || cs instanceof UTF_16;
+ }
+
+ public CharsetDecoder newDecoder ()
+ {
+ return new UTF_16Decoder (this, UTF_16Decoder.LITTLE_ENDIAN);
+ }
+
+ public CharsetEncoder newEncoder ()
+ {
+ return new UTF_16Encoder (this, UTF_16Encoder.LITTLE_ENDIAN, true);
+ }
+}
diff --git a/libjava/gnu/java/nio/charset/UTF_8.java b/libjava/gnu/java/nio/charset/UTF_8.java
new file mode 100644
index 00000000000..aa623b2f2cf
--- /dev/null
+++ b/libjava/gnu/java/nio/charset/UTF_8.java
@@ -0,0 +1,279 @@
+/* UTF_8.java --
+ Copyright (C) 2002 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.charset;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CoderResult;
+
+/**
+ * UTF-8 charset.
+ *
+ * <p> UTF-8 references:
+ * <ul>
+ * <li> <a href="http://ietf.org/rfc/rfc2279.txt">RFC 2279</a>
+ * <li> The <a href="http://www.unicode.org/unicode/standard/standard.html">
+ * Unicode standard</a> and
+ * <a href="http://www.unicode.org/versions/corrigendum1.html">
+ * Corrigendum</a>
+ * </ul>
+ *
+ * @author Jesse Rosenstock
+ */
+final class UTF_8 extends Charset
+{
+ UTF_8 ()
+ {
+ super ("UTF-8", null);
+ }
+
+ public boolean contains (Charset cs)
+ {
+ return cs instanceof US_ASCII || cs instanceof ISO_8859_1
+ || cs instanceof UTF_8 || cs instanceof UTF_16BE
+ || cs instanceof UTF_16LE || cs instanceof UTF_16;
+ }
+
+ public CharsetDecoder newDecoder ()
+ {
+ return new Decoder (this);
+ }
+
+ public CharsetEncoder newEncoder ()
+ {
+ return new Encoder (this);
+ }
+
+ private static final class Decoder extends CharsetDecoder
+ {
+ private Decoder (Charset cs)
+ {
+ super (cs, 1.0f, 1.0f);
+ }
+
+ protected CoderResult decodeLoop (ByteBuffer in, CharBuffer out)
+ {
+ // TODO: Optimize this in the case in.hasArray() / out.hasArray()
+ int inPos = 0;
+ try
+ {
+ while (in.hasRemaining ())
+ {
+ char c;
+ byte b1 = in.get ();
+ int highNibble = (b1 >> 4) & 0xF;
+
+ switch (highNibble)
+ {
+ case 0: case 1: case 2: case 3:
+ case 4: case 5: case 6: case 7:
+ if (out.remaining () < 1)
+ return CoderResult.OVERFLOW;
+ out.put ((char) b1);
+ inPos++;
+ break;
+
+ case 0xC: case 0xD:
+ byte b2;
+ if (in.remaining () < 1)
+ return CoderResult.UNDERFLOW;
+ if (out.remaining () < 1)
+ return CoderResult.OVERFLOW;
+ if (!isContinuation (b2 = in.get ()))
+ return CoderResult.malformedForLength (1);
+ c = (char) (((b1 & 0x1F) << 6) | (b2 & 0x3F));
+ // check that we had the shortest encoding
+ if (c <= 0x7F)
+ return CoderResult.malformedForLength (2);
+ out.put (c);
+ inPos += 2;
+ break;
+
+ case 0xE:
+ byte b3;
+ if (in.remaining () < 2)
+ return CoderResult.UNDERFLOW;
+ if (out.remaining () < 1)
+ return CoderResult.OVERFLOW;
+ if (!isContinuation (b2 = in.get ()))
+ return CoderResult.malformedForLength (1);
+ if (!isContinuation (b3 = in.get ()))
+ return CoderResult.malformedForLength (1);
+ c = (char) (((b1 & 0x0F) << 12)
+ | ((b2 & 0x3F) << 6)
+ | (b3 & 0x3F));
+ // check that we had the shortest encoding
+ if (c <= 0x7FF)
+ return CoderResult.malformedForLength (3);
+ out.put (c);
+ inPos += 3;
+ break;
+
+ default:
+ return CoderResult.malformedForLength (1);
+ }
+ }
+
+ return CoderResult.UNDERFLOW;
+ }
+ finally
+ {
+ // In case we did a get(), then encountered an error, reset the
+ // position to before the error. If there was no error, this
+ // will benignly reset the position to the value it already has.
+ in.position (inPos);
+ }
+ }
+
+ private static boolean isContinuation (byte b)
+ {
+ return (b & 0xC0) == 0x80;
+ }
+ }
+
+ private static final class Encoder extends CharsetEncoder
+ {
+ private Encoder (Charset cs)
+ {
+ // According to
+ // http://www-106.ibm.com/developerworks/unicode/library/utfencodingforms/index.html
+ // On average, English takes slightly over one unit per code point.
+ // Most Latin-script languages take about 1.1 bytes. Greek, Russian,
+ // Arabic and Hebrew take about 1.7 bytes, and most others (including
+ // Japanese, Chinese, Korean and Hindi) take about 3 bytes.
+ // We assume we will be dealing with latin scripts, and use 1.1
+ // for averageBytesPerChar.
+ super (cs, 1.1f, 4.0f);
+ }
+
+ protected CoderResult encodeLoop (CharBuffer in, ByteBuffer out)
+ {
+ int inPos = 0;
+ try
+ {
+ // TODO: Optimize this in the case in.hasArray() / out.hasArray()
+ while (in.hasRemaining ())
+ {
+ int remaining = out.remaining ();
+ char c = in.get ();
+
+ // UCS-4 range (hex.) UTF-8 octet sequence (binary)
+ // 0000 0000-0000 007F 0xxxxxxx
+ // 0000 0080-0000 07FF 110xxxxx 10xxxxxx
+ // 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
+
+ // Scalar Value UTF-16 byte 1 byte 2 byte 3 byte 4
+ // 0000 0000 0xxx xxxx 0000 0000 0xxx xxxx 0xxx xxxx
+ // 0000 0yyy yyxx xxxx 0000 0yyy yyxx xxxx 110y yyyy 10xx xxxx
+ // zzzz yyyy yyxx xxxx zzzz yyyy yyxx xxxx 1110 zzzz 10yy yyyy 10xx xxxx
+ // u uuuu zzzz yyyy yyxx xxxx 1101 10ww wwzz zzyy 1111 0uuu 10uu zzzz 10yy yyyy 10xx xxxx
+ // + 1101 11yy yyxx xxxx
+ // Note: uuuuu = wwww + 1
+
+ if (c <= 0x7F)
+ {
+ if (remaining < 1)
+ return CoderResult.OVERFLOW;
+ out.put ((byte) c);
+ inPos++;
+ }
+ else if (c <= 0x7FF)
+ {
+ if (remaining < 2)
+ return CoderResult.OVERFLOW;
+ out.put ((byte) (0xC0 | (c >> 6)));
+ out.put ((byte) (0x80 | (c & 0x3F)));
+ inPos++;
+ }
+ else if (0xD800 <= c && c <= 0xDFFF)
+ {
+ if (remaining < 4)
+ return CoderResult.OVERFLOW;
+
+ // we got a low surrogate without a preciding high one
+ if (c > 0xDBFF)
+ return CoderResult.malformedForLength (1);
+
+ // high surrogates
+ if (!in.hasRemaining ())
+ return CoderResult.UNDERFLOW;
+
+ char d = in.get ();
+
+ // make sure d is a low surrogate
+ if (d < 0xDC00 || d > 0xDFFF)
+ return CoderResult.malformedForLength (1);
+
+ // make the 32 bit value
+ // int value2 = (c - 0xD800) * 0x400 + (d - 0xDC00) + 0x10000;
+ int value = (((c & 0x3FF) << 10) | (d & 0x3FF)) + 0x10000;
+ // assert value == value2;
+ out.put ((byte) (0xF0 | (value >> 18)));
+ out.put ((byte) (0x80 | ((value >> 12) & 0x3F)));
+ out.put ((byte) (0x80 | ((value >> 6) & 0x3F)));
+ out.put ((byte) (0x80 | ((value ) & 0x3F)));
+
+ inPos += 2;
+ }
+ else
+ {
+ if (remaining < 3)
+ return CoderResult.OVERFLOW;
+
+ out.put ((byte) (0xE0 | (c >> 12)));
+ out.put ((byte) (0x80 | ((c >> 6) & 0x3F)));
+ out.put ((byte) (0x80 | (c & 0x3F)));
+ inPos++;
+ }
+ }
+
+ return CoderResult.UNDERFLOW;
+ }
+ finally
+ {
+ // In case we did a get(), then encountered an error, reset the
+ // position to before the error. If there was no error, this
+ // will benignly reset the position to the value it already has.
+ in.position (inPos);
+ }
+ }
+ }
+}
diff --git a/libjava/java/awt/color/ICC_ProfileGray.java b/libjava/java/awt/color/ICC_ProfileGray.java
new file mode 100644
index 00000000000..6aed7eefe0f
--- /dev/null
+++ b/libjava/java/awt/color/ICC_ProfileGray.java
@@ -0,0 +1,71 @@
+/* ICC_ProfileGray.java -- the ICC profile for a Gray colorspace
+ Copyright (C) 2002 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 java.awt.color;
+
+/**
+ * STUBBED
+ * @since 1.2
+ */
+public class ICC_ProfileGray extends ICC_Profile
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = -1124721290732002649L;
+
+ ICC_ProfileGray()
+ {
+ super(ColorSpace.CS_GRAY);
+ }
+
+ public float[] getMediaWhitePoint()
+ {
+ return null;
+ }
+
+ public float getGamma()
+ {
+ return 0;
+ }
+
+ public short[] getTRC()
+ {
+ return null;
+ }
+} // class ICC_ProfileGray
diff --git a/libjava/java/awt/color/ICC_ProfileRGB.java b/libjava/java/awt/color/ICC_ProfileRGB.java
new file mode 100644
index 00000000000..aab7578b22e
--- /dev/null
+++ b/libjava/java/awt/color/ICC_ProfileRGB.java
@@ -0,0 +1,80 @@
+/* ICC_ProfileRGB.java -- the ICC profile for a RGB colorspace
+ Copyright (C) 2002 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 java.awt.color;
+
+/**
+ * STUBBED
+ * @since 1.2
+ */
+public class ICC_ProfileRGB extends ICC_Profile
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = 8505067385152579334L;
+
+ public static final int REDCOMPONENT = 0;
+ public static final int GREENCOMPONENT = 1;
+ public static final int BLUECOMPONENT = 2;
+
+ ICC_ProfileRGB()
+ {
+ super(ColorSpace.CS_sRGB);
+ }
+
+ public float[] getMediaWhitePoint()
+ {
+ return null;
+ }
+
+ public float[][] getMatrix()
+ {
+ return null;
+ }
+
+ public float getGamma(int component)
+ {
+ return 0;
+ }
+
+ public short[] getTRC(int component)
+ {
+ return null;
+ }
+} // class ICC_ProfileRGB
diff --git a/libjava/java/nio/BufferOverflowException.java b/libjava/java/nio/BufferOverflowException.java
new file mode 100644
index 00000000000..68dcd541dec
--- /dev/null
+++ b/libjava/java/nio/BufferOverflowException.java
@@ -0,0 +1,51 @@
+/* BufferOverflowException.java --
+ Copyright (C) 2002 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 java.nio;
+
+/**
+ * @since 1.4
+ */
+public class BufferOverflowException extends RuntimeException
+{
+ /**
+ * Creates the exception
+ */
+ public BufferOverflowException ()
+ {
+ }
+}
diff --git a/libjava/java/nio/BufferUnderflowException.java b/libjava/java/nio/BufferUnderflowException.java
new file mode 100644
index 00000000000..2ff1bc40bea
--- /dev/null
+++ b/libjava/java/nio/BufferUnderflowException.java
@@ -0,0 +1,51 @@
+/* BufferUnderflowException.java --
+ Copyright (C) 2002 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 java.nio;
+
+/**
+ * @since 1.4
+ */
+public class BufferUnderflowException extends RuntimeException
+{
+ /**
+ * Creates the exception
+ */
+ public BufferUnderflowException ()
+ {
+ }
+}
diff --git a/libjava/java/nio/CharBuffer.java b/libjava/java/nio/CharBuffer.java
new file mode 100644
index 00000000000..2a21ef93ff5
--- /dev/null
+++ b/libjava/java/nio/CharBuffer.java
@@ -0,0 +1,291 @@
+/* CharBuffer.java --
+ Copyright (C) 2002 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 java.nio;
+
+public abstract class CharBuffer extends Buffer
+{
+ private ByteOrder endian = ByteOrder.BIG_ENDIAN;
+
+ protected char [] backing_buffer;
+
+ public static CharBuffer allocate (int capacity)
+ {
+ return null;
+ }
+
+ /**
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ */
+ final public static CharBuffer wrap (char[] array, int offset, int length)
+ {
+ if ((offset < 0) ||
+ (offset > array.length) ||
+ (length < 0) ||
+ (length > (array.length - offset)))
+ throw new IndexOutOfBoundsException ();
+
+ return null;
+ }
+
+ final public static CharBuffer wrap (CharSequence a)
+ {
+ return wrap (a, 0, a.length ());
+ }
+
+ /**
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ */
+ final public static CharBuffer wrap (CharSequence a, int offset, int length)
+ {
+ char [] buffer = new char [length];
+
+ for (int i = offset; i < length; i++)
+ {
+ buffer [i] = a.charAt (i);
+ }
+
+ return wrap (buffer, 0, length);
+ }
+
+ final public static CharBuffer wrap (char[] array)
+ {
+ return wrap (array, 0, array.length);
+ }
+
+ /**
+ * @exception BufferUnderflowException FIXME
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ */
+ final public CharBuffer get (char[] dst, int offset, int length)
+ {
+ for (int i = offset; i < offset + length; i++)
+ {
+ dst [i] = get ();
+ }
+ return this;
+ }
+
+ /**
+ * @exception BufferUnderflowException FIXME
+ */
+ final public CharBuffer get (char[] dst)
+ {
+ return get (dst, 0, dst.length);
+ }
+
+ /**
+ * @exception BufferOverflowException FIXME
+ * @exception IllegalArgumentException FIXME
+ * @exception ReadOnlyBufferException FIXME
+ */
+ final public CharBuffer put (CharBuffer src)
+ {
+ while (src.hasRemaining ())
+ put (src.get ());
+
+ return this;
+ }
+
+ /**
+ * @exception BufferOverflowException FIXME
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ * @exception ReadOnlyBufferException FIXME
+ */
+ final public CharBuffer put (char[] src, int offset, int length)
+ {
+ for (int i = offset; i < offset + length; i++)
+ put (src [i]);
+
+ return this;
+ }
+
+ /**
+ * @exception BufferOverflowException FIXME
+ * @exception ReadOnlyBufferException FIXME
+ */
+ public final CharBuffer put (char[] src)
+ {
+ return put (src, 0, src.length);
+ }
+
+ public final boolean hasArray ()
+ {
+ return backing_buffer != null;
+ }
+
+ /**
+ * @exception ReadOnlyBufferException FIXME
+ * @exception UnsupportedOperationException FIXME
+ */
+ public final char[] array ()
+ {
+ return backing_buffer;
+ }
+
+ /**
+ * @exception ReadOnlyBufferException FIXME
+ * @exception UnsupportedOperationException FIXME
+ */
+ public final int arrayOffset ()
+ {
+ return 0;
+ }
+
+ public int hashCode ()
+ {
+ return super.hashCode ();
+ }
+
+ public boolean equals (Object obj)
+ {
+ if (obj instanceof CharBuffer)
+ return compareTo (obj) == 0;
+
+ return false;
+ }
+
+ /**
+ * @exception ClassCastException FIXME
+ */
+ public int compareTo(Object obj)
+ {
+ CharBuffer a = (CharBuffer) obj;
+
+ if (a.remaining () != remaining ())
+ return 1;
+
+ if (! hasArray () || ! a.hasArray ())
+ return 1;
+
+ int r = remaining ();
+ int i1 = pos;
+ int i2 = a.pos;
+
+ for (int i = 0; i < r; i++)
+ {
+ int t = (int) (get (i1)- a.get (i2));
+
+ if (t != 0)
+ return (int) t;
+ }
+ return 0;
+ }
+
+ /**
+ * @exception BufferUnderflowException FIXME
+ */
+ public abstract char get ();
+
+ /**
+ * @exception BufferOverflowException FIXME
+ * @exception ReadOnlyBufferException FIXME
+ */
+ public abstract CharBuffer put (char b);
+
+ /**
+ * @exception IndexOutOfBoundsException FIXME
+ */
+ public abstract char get (int index);
+
+ /**
+ * @exception IndexOutOfBoundsException FIXME
+ * @exception ReadOnlyBufferException FIXME
+ */
+ public abstract CharBuffer put (int index, char b);
+
+ /**
+ * @exception ReadOnlyBufferException FIXME
+ */
+ public abstract CharBuffer compact ();
+
+ public abstract boolean isDirect ();
+
+ public abstract CharBuffer slice ();
+
+ public abstract CharBuffer duplicate ();
+
+ public abstract CharBuffer asReadOnlyBuffer ();
+
+ public String toString ()
+ {
+ return "";
+ }
+
+ public final int length ()
+ {
+ return 0;
+ }
+
+ public abstract ByteOrder order ();
+
+ /**
+ * @exception IndexOutOfBoundsException FIXME
+ */
+ public abstract CharSequence subSequence (int start, int length);
+
+ /**
+ * @exception BufferOverflowException FIXME
+ * @exception IndexOutOfBoundsException FIXME
+ * @exception ReadOnlyBufferException FIXME
+ */
+ public CharBuffer put (String str, int start, int length)
+ {
+ return null;
+ }
+
+ /**
+ * @exception BufferOverflowException FIXME
+ * @exception ReadOnlyBufferException FIXME
+ */
+ public final CharBuffer put (String str)
+ {
+ return null;
+ }
+
+ /**
+ * @exception IndexOutOfBoundsException FIXME
+ */
+ public final char charAt (int index)
+ {
+ return ' ';
+ }
+}
diff --git a/libjava/java/nio/DoubleBuffer.java b/libjava/java/nio/DoubleBuffer.java
new file mode 100644
index 00000000000..7059b6e2430
--- /dev/null
+++ b/libjava/java/nio/DoubleBuffer.java
@@ -0,0 +1,225 @@
+/* DoubleBuffer.java --
+ Copyright (C) 2002 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 java.nio;
+
+import gnu.java.nio.DoubleBufferImpl;
+
+public abstract class DoubleBuffer extends Buffer
+{
+ private ByteOrder endian = ByteOrder.BIG_ENDIAN;
+ protected double [] backing_buffer;
+
+ public static DoubleBuffer allocateDirect(int capacity)
+ {
+ return new DoubleBufferImpl(capacity, 0, capacity);
+ }
+
+ public static DoubleBuffer allocate(int capacity)
+ {
+ return new DoubleBufferImpl(capacity, 0, capacity);
+ }
+
+ final public static DoubleBuffer wrap (double[] array, int offset, int length)
+ {
+ return new DoubleBufferImpl(array, offset, length);
+ }
+
+ final public static DoubleBuffer wrap(String a)
+ {
+ int len = a.length();
+ double[] buffer = new double[len];
+
+ for (int i=0;i<len;i++)
+ {
+ buffer[i] = (double) a.charAt(i);
+ }
+
+ return wrap(buffer, 0, len);
+ }
+
+ final public static DoubleBuffer wrap(double[] array)
+ {
+ return wrap(array, 0, array.length);
+ }
+
+ final public DoubleBuffer get (double[] dst, int offset, int length)
+ {
+ for (int i = offset; i < offset + length; i++)
+ {
+ dst[i] = get();
+ }
+
+ return this;
+ }
+
+ final public DoubleBuffer get(double[] dst)
+ {
+ return get(dst, 0, dst.length);
+ }
+
+ final public DoubleBuffer put(DoubleBuffer src)
+ {
+ while (src.hasRemaining())
+ put(src.get());
+
+ return this;
+ }
+
+ final public DoubleBuffer put (double[] src, int offset, int length)
+ {
+ for (int i = offset; i < offset + length; i++)
+ put(src[i]);
+
+ return this;
+ }
+
+ public final DoubleBuffer put(double[] src)
+ {
+ return put(src, 0, src.length);
+ }
+
+ public final boolean hasArray()
+ {
+ return (backing_buffer != null);
+ }
+
+ public final double[] array()
+ {
+ return backing_buffer;
+ }
+
+ public final int arrayOffset()
+ {
+ return 0;
+ }
+
+ public int hashCode()
+ {
+ return super.hashCode();
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof DoubleBuffer)
+ {
+ return compareTo(obj) == 0;
+ }
+
+ return false;
+ }
+
+ public int compareTo(Object ob)
+ {
+ DoubleBuffer a = (DoubleBuffer) ob;
+
+ if (a.remaining() != remaining())
+ return 1;
+
+ if (! hasArray() ||
+ ! a.hasArray())
+ {
+ return 1;
+ }
+
+ int r = remaining();
+ int i1 = position ();
+ int i2 = a.position ();
+
+ for (int i=0;i<r;i++)
+ {
+ int t = (int) (get(i1)- a.get(i2));
+ if (t != 0)
+ {
+ return (int) t;
+ }
+ }
+
+ return 0;
+ }
+
+ public final ByteOrder order()
+ {
+ return endian;
+ }
+
+ public final DoubleBuffer order(ByteOrder bo)
+ {
+ endian = bo;
+ return this;
+ }
+
+ public abstract double get();
+ public abstract DoubleBuffer put (double b);
+ public abstract double get(int index);
+ public abstract DoubleBuffer put(int index, double b);
+ public abstract DoubleBuffer compact();
+ public abstract boolean isDirect();
+ public abstract DoubleBuffer slice();
+ public abstract DoubleBuffer duplicate();
+ public abstract DoubleBuffer asReadOnlyBuffer();
+ public abstract ShortBuffer asShortBuffer();
+ public abstract CharBuffer asCharBuffer();
+ public abstract IntBuffer asIntBuffer();
+ public abstract LongBuffer asLongBuffer();
+ public abstract FloatBuffer asFloatBuffer();
+ public abstract DoubleBuffer asDoubleBuffer();
+ public abstract char getChar();
+ public abstract DoubleBuffer putChar(char value);
+ public abstract char getChar(int index);
+ public abstract DoubleBuffer putChar(int index, char value);
+ public abstract short getShort();
+ public abstract DoubleBuffer putShort(short value);
+ public abstract short getShort(int index);
+ public abstract DoubleBuffer putShort(int index, short value);
+ public abstract int getInt();
+ public abstract DoubleBuffer putInt(int value);
+ public abstract int getInt(int index);
+ public abstract DoubleBuffer putInt(int index, int value);
+ public abstract long getLong();
+ public abstract DoubleBuffer putLong(long value);
+ public abstract long getLong(int index);
+ public abstract DoubleBuffer putLong(int index, long value);
+ public abstract float getFloat();
+ public abstract DoubleBuffer putFloat(float value);
+ public abstract float getFloat(int index);
+ public abstract DoubleBuffer putFloat(int index, float value);
+ public abstract double getDouble();
+ public abstract DoubleBuffer putDouble(double value);
+ public abstract double getDouble(int index);
+ public abstract DoubleBuffer putDouble(int index, double value);
+}
diff --git a/libjava/java/nio/FloatBuffer.java b/libjava/java/nio/FloatBuffer.java
new file mode 100644
index 00000000000..f06ef187791
--- /dev/null
+++ b/libjava/java/nio/FloatBuffer.java
@@ -0,0 +1,224 @@
+/* FloatBuffer.java --
+ Copyright (C) 2002 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 java.nio;
+
+import gnu.java.nio.FloatBufferImpl;
+
+public abstract class FloatBuffer extends Buffer
+{
+ private ByteOrder endian = ByteOrder.BIG_ENDIAN;
+ protected float [] backing_buffer;
+
+ public static FloatBuffer allocateDirect(int capacity)
+ {
+ return new FloatBufferImpl (capacity, 0, capacity);
+ }
+
+ public static FloatBuffer allocate(int capacity)
+ {
+ return new FloatBufferImpl (capacity, 0, capacity);
+ }
+
+ final public static FloatBuffer wrap(float[] array, int offset, int length)
+ {
+ return new FloatBufferImpl(array, offset, length);
+ }
+
+ final public static FloatBuffer wrap(String a)
+ {
+ int len = a.length();
+ float[] buffer = new float[len];
+
+ for (int i=0;i<len;i++)
+ {
+ buffer[i] = (float) a.charAt(i);
+ }
+
+ return wrap(buffer, 0, len);
+ }
+
+ final public static FloatBuffer wrap(float[] array)
+ {
+ return wrap(array, 0, array.length);
+ }
+
+ final public FloatBuffer get(float[] dst, int offset, int length)
+ {
+ for (int i = offset; i < offset + length; i++)
+ {
+ dst[i] = get();
+ }
+
+ return this;
+ }
+
+ final public FloatBuffer get(float[] dst)
+ {
+ return get(dst, 0, dst.length);
+ }
+
+ final public FloatBuffer put(FloatBuffer src)
+ {
+ while (src.hasRemaining())
+ put(src.get());
+
+ return this;
+ }
+
+ final public FloatBuffer put(float[] src, int offset, int length)
+ {
+ for (int i = offset; i < offset + length; i++)
+ put(src[i]);
+
+ return this;
+ }
+
+ public final FloatBuffer put(float[] src)
+ {
+ return put(src, 0, src.length);
+ }
+
+ public final boolean hasArray()
+ {
+ return (backing_buffer != null);
+ }
+
+ public final float[] array()
+ {
+ return backing_buffer;
+ }
+
+ public final int arrayOffset()
+ {
+ return 0;
+ }
+
+ public int hashCode()
+ {
+ return super.hashCode();
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof FloatBuffer)
+ {
+ return compareTo(obj) == 0;
+ }
+ return false;
+ }
+
+ public int compareTo(Object ob)
+ {
+ FloatBuffer a = (FloatBuffer) ob;
+
+ if (a.remaining() != remaining())
+ return 1;
+
+ if (! hasArray() ||
+ ! a.hasArray())
+ {
+ return 1;
+ }
+
+ int r = remaining();
+ int i1 = position ();
+ int i2 = a.position ();
+
+ for (int i=0;i<r;i++)
+ {
+ int t = (int) (get(i1)- a.get(i2));
+ if (t != 0)
+ {
+ return (int) t;
+ }
+ }
+
+ return 0;
+ }
+
+ public final ByteOrder order()
+ {
+ return endian;
+ }
+
+ public final FloatBuffer order(ByteOrder bo)
+ {
+ endian = bo;
+ return this;
+ }
+
+ public abstract float get();
+ public abstract java.nio. FloatBuffer put(float b);
+ public abstract float get(int index);
+ public abstract java.nio. FloatBuffer put(int index, float b);
+ public abstract FloatBuffer compact();
+ public abstract boolean isDirect();
+ public abstract FloatBuffer slice();
+ public abstract FloatBuffer duplicate();
+ public abstract FloatBuffer asReadOnlyBuffer();
+ public abstract ShortBuffer asShortBuffer();
+ public abstract CharBuffer asCharBuffer();
+ public abstract IntBuffer asIntBuffer();
+ public abstract LongBuffer asLongBuffer();
+ public abstract FloatBuffer asFloatBuffer();
+ public abstract DoubleBuffer asDoubleBuffer();
+ public abstract char getChar();
+ public abstract FloatBuffer putChar(char value);
+ public abstract char getChar(int index);
+ public abstract FloatBuffer putChar(int index, char value);
+ public abstract short getShort();
+ public abstract FloatBuffer putShort(short value);
+ public abstract short getShort(int index);
+ public abstract FloatBuffer putShort(int index, short value);
+ public abstract int getInt();
+ public abstract FloatBuffer putInt(int value);
+ public abstract int getInt(int index);
+ public abstract FloatBuffer putInt(int index, int value);
+ public abstract long getLong();
+ public abstract FloatBuffer putLong(long value);
+ public abstract long getLong(int index);
+ public abstract FloatBuffer putLong(int index, long value);
+ public abstract float getFloat();
+ public abstract FloatBuffer putFloat(float value);
+ public abstract float getFloat(int index);
+ public abstract FloatBuffer putFloat(int index, float value);
+ public abstract double getDouble();
+ public abstract FloatBuffer putDouble(double value);
+ public abstract double getDouble(int index);
+ public abstract FloatBuffer putDouble(int index, double value);
+}
diff --git a/libjava/java/nio/IntBuffer.java b/libjava/java/nio/IntBuffer.java
new file mode 100644
index 00000000000..d2d28d36b10
--- /dev/null
+++ b/libjava/java/nio/IntBuffer.java
@@ -0,0 +1,225 @@
+/* IntBuffer.java --
+ Copyright (C) 2002 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 java.nio;
+
+import gnu.java.nio.IntBufferImpl;
+
+public abstract class IntBuffer extends Buffer
+{
+ private ByteOrder endian = ByteOrder.BIG_ENDIAN;
+ protected int [] backing_buffer;
+
+ public static IntBuffer allocateDirect(int capacity)
+ {
+ return new IntBufferImpl (capacity, 0, capacity);
+ }
+
+ public static IntBuffer allocate(int capacity)
+ {
+ return new IntBufferImpl (capacity, 0, capacity);
+ }
+
+ final public static IntBuffer wrap(int[] array, int offset, int length)
+ {
+ return new IntBufferImpl(array, offset, length);
+ }
+
+ final public static IntBuffer wrap(String a)
+ {
+ int len = a.length();
+ int[] buffer = new int[len];
+
+ for (int i=0;i<len;i++)
+ {
+ buffer[i] = (int) a.charAt(i);
+ }
+
+ return wrap(buffer, 0, len);
+ }
+
+ final public static IntBuffer wrap(int[] array)
+ {
+ return wrap(array, 0, array.length);
+ }
+
+ final public IntBuffer get(int[] dst, int offset, int length)
+ {
+ for (int i = offset; i < offset + length; i++)
+ {
+ dst[i] = get();
+ }
+
+ return this;
+ }
+
+ final public IntBuffer get(int[] dst)
+ {
+ return get(dst, 0, dst.length);
+ }
+
+ final public IntBuffer put(IntBuffer src)
+ {
+ while (src.hasRemaining())
+ put(src.get());
+
+ return this;
+ }
+
+ final public IntBuffer put(int[] src, int offset, int length)
+ {
+ for (int i = offset; i < offset + length; i++)
+ put(src[i]);
+
+ return this;
+ }
+
+ public final IntBuffer put(int[] src)
+ {
+ return put(src, 0, src.length);
+ }
+
+ public final boolean hasArray()
+ {
+ return (backing_buffer != null);
+ }
+
+ public final int[] array()
+ {
+ return backing_buffer;
+ }
+
+ public final int arrayOffset()
+ {
+ return 0;
+ }
+
+ public int hashCode()
+ {
+ return super.hashCode();
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof IntBuffer)
+ {
+ return compareTo(obj) == 0;
+ }
+
+ return false;
+ }
+
+ public int compareTo(Object ob)
+ {
+ IntBuffer a = (IntBuffer) ob;
+
+ if (a.remaining() != remaining())
+ return 1;
+
+ if (! hasArray() ||
+ ! a.hasArray())
+ {
+ return 1;
+ }
+
+ int r = remaining();
+ int i1 = position ();
+ int i2 = a.position ();
+
+ for (int i=0;i<r;i++)
+ {
+ int t = (int) (get(i1)- a.get(i2));
+ if (t != 0)
+ {
+ return (int) t;
+ }
+ }
+
+ return 0;
+ }
+
+ public final ByteOrder order()
+ {
+ return endian;
+ }
+
+ public final IntBuffer order(ByteOrder bo)
+ {
+ endian = bo;
+ return this;
+ }
+
+ public abstract int get();
+ public abstract IntBuffer put(int b);
+ public abstract int get(int index);
+ public abstract IntBuffer put(int index, int b);
+ public abstract IntBuffer compact();
+ public abstract boolean isDirect();
+ public abstract IntBuffer slice();
+ public abstract IntBuffer duplicate();
+ public abstract IntBuffer asReadOnlyBuffer();
+ public abstract ShortBuffer asShortBuffer();
+ public abstract CharBuffer asCharBuffer();
+ public abstract IntBuffer asIntBuffer();
+ public abstract LongBuffer asLongBuffer();
+ public abstract FloatBuffer asFloatBuffer();
+ public abstract DoubleBuffer asDoubleBuffer();
+ public abstract char getChar();
+ public abstract IntBuffer putChar(char value);
+ public abstract char getChar(int index);
+ public abstract IntBuffer putChar(int index, char value);
+ public abstract short getShort();
+ public abstract IntBuffer putShort(short value);
+ public abstract short getShort(int index);
+ public abstract IntBuffer putShort(int index, short value);
+ public abstract int getInt();
+ public abstract IntBuffer putInt(int value);
+ public abstract int getInt(int index);
+ public abstract IntBuffer putInt(int index, int value);
+ public abstract long getLong();
+ public abstract IntBuffer putLong(long value);
+ public abstract long getLong(int index);
+ public abstract IntBuffer putLong(int index, long value);
+ public abstract float getFloat();
+ public abstract IntBuffer putFloat(float value);
+ public abstract float getFloat(int index);
+ public abstract IntBuffer putFloat(int index, float value);
+ public abstract double getDouble();
+ public abstract IntBuffer putDouble(double value);
+ public abstract double getDouble(int index);
+ public abstract IntBuffer putDouble(int index, double value);
+}
diff --git a/libjava/java/nio/InvalidMarkException.java b/libjava/java/nio/InvalidMarkException.java
new file mode 100644
index 00000000000..5917855a4c9
--- /dev/null
+++ b/libjava/java/nio/InvalidMarkException.java
@@ -0,0 +1,52 @@
+/* InvalidMarkException.java --
+ Copyright (C) 2002 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 java.nio;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class InvalidMarkException extends IllegalStateException
+{
+ /**
+ * Creates the exception
+ */
+ public InvalidMarkException ()
+ {
+ }
+}
diff --git a/libjava/java/nio/LongBuffer.java b/libjava/java/nio/LongBuffer.java
new file mode 100644
index 00000000000..5bca6d53b70
--- /dev/null
+++ b/libjava/java/nio/LongBuffer.java
@@ -0,0 +1,226 @@
+/* LongBuffer.java --
+ Copyright (C) 2002 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 java.nio;
+
+import gnu.java.nio.LongBufferImpl;
+
+public abstract class LongBuffer extends Buffer
+{
+ private ByteOrder endian = ByteOrder.BIG_ENDIAN;
+ protected long [] backing_buffer;
+
+ public static LongBuffer allocateDirect(int capacity)
+ {
+ return new LongBufferImpl(capacity, 0, capacity);
+ }
+
+ public static LongBuffer allocate(int capacity)
+ {
+ return new LongBufferImpl(capacity, 0, capacity);
+ }
+
+ final public static LongBuffer wrap(long[] array, int offset, int length)
+ {
+ return new LongBufferImpl (array, offset, length);
+ }
+
+ final public static LongBuffer wrap(String a)
+ {
+ int len = a.length();
+ long[] buffer = new long[len];
+
+ for (int i=0;i<len;i++)
+ {
+ buffer[i] = (long) a.charAt(i);
+ }
+
+ return wrap(buffer, 0, len);
+ }
+
+ final public static LongBuffer wrap(long[] array)
+ {
+ return wrap(array, 0, array.length);
+ }
+
+ final public LongBuffer get(long[] dst, int offset, int length)
+ {
+ for (int i = offset; i < offset + length; i++)
+ {
+ dst[i] = get();
+ }
+
+ return this;
+ }
+
+ final public LongBuffer get(long[] dst)
+ {
+ return get(dst, 0, dst.length);
+ }
+
+ final public LongBuffer put(LongBuffer src)
+ {
+ while (src.hasRemaining())
+ put(src.get());
+
+ return this;
+ }
+
+ final public LongBuffer put(long[] src, int offset, int length)
+ {
+ for (int i = offset; i < offset + length; i++)
+ put(src[i]);
+
+ return this;
+ }
+
+ public final LongBuffer put(long[] src)
+ {
+ return put(src, 0, src.length);
+ }
+
+ public final boolean hasArray()
+ {
+ return (backing_buffer != null);
+ }
+
+ public final long[] array()
+ {
+ return backing_buffer;
+ }
+
+ public final int arrayOffset()
+ {
+ return 0;
+ }
+
+ public int hashCode()
+ {
+ return super.hashCode();
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof LongBuffer)
+ {
+ return compareTo(obj) == 0;
+ }
+
+ return false;
+ }
+
+ public int compareTo(Object ob)
+ {
+ LongBuffer a = (LongBuffer) ob;
+
+ if (a.remaining() != remaining())
+ return 1;
+
+ if (! hasArray() ||
+ ! a.hasArray())
+ {
+ return 1;
+ }
+
+ int r = remaining();
+ int i1 = position ();
+ int i2 = a.position ();
+
+ for (int i=0;i<r;i++)
+ {
+ int t = (int) (get(i1)- a.get(i2));
+
+ if (t != 0)
+ {
+ return (int) t;
+ }
+ }
+
+ return 0;
+ }
+
+ public final ByteOrder order()
+ {
+ return endian;
+ }
+
+ public final LongBuffer order(ByteOrder bo)
+ {
+ endian = bo;
+ return this;
+ }
+
+ public abstract long get();
+ public abstract java.nio. LongBuffer put(long b);
+ public abstract long get(int index);
+ public abstract java.nio. LongBuffer put(int index, long b);
+ public abstract LongBuffer compact();
+ public abstract boolean isDirect();
+ public abstract LongBuffer slice();
+ public abstract LongBuffer duplicate();
+ public abstract LongBuffer asReadOnlyBuffer();
+ public abstract ShortBuffer asShortBuffer();
+ public abstract CharBuffer asCharBuffer();
+ public abstract IntBuffer asIntBuffer();
+ public abstract LongBuffer asLongBuffer();
+ public abstract FloatBuffer asFloatBuffer();
+ public abstract DoubleBuffer asDoubleBuffer();
+ public abstract char getChar();
+ public abstract LongBuffer putChar(char value);
+ public abstract char getChar(int index);
+ public abstract LongBuffer putChar(int index, char value);
+ public abstract short getShort();
+ public abstract LongBuffer putShort(short value);
+ public abstract short getShort(int index);
+ public abstract LongBuffer putShort(int index, short value);
+ public abstract int getInt();
+ public abstract LongBuffer putInt(int value);
+ public abstract int getInt(int index);
+ public abstract LongBuffer putInt(int index, int value);
+ public abstract long getLong();
+ public abstract LongBuffer putLong(long value);
+ public abstract long getLong(int index);
+ public abstract LongBuffer putLong(int index, long value);
+ public abstract float getFloat();
+ public abstract LongBuffer putFloat(float value);
+ public abstract float getFloat(int index);
+ public abstract LongBuffer putFloat(int index, float value);
+ public abstract double getDouble();
+ public abstract LongBuffer putDouble(double value);
+ public abstract double getDouble(int index);
+ public abstract LongBuffer putDouble(int index, double value);
+}
diff --git a/libjava/java/nio/ReadOnlyBufferException.java b/libjava/java/nio/ReadOnlyBufferException.java
new file mode 100644
index 00000000000..0fcdc3ac7db
--- /dev/null
+++ b/libjava/java/nio/ReadOnlyBufferException.java
@@ -0,0 +1,52 @@
+/* ReadOnlyBufferException.java --
+ Copyright (C) 2002 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 java.nio;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class ReadOnlyBufferException extends UnsupportedOperationException
+{
+ /**
+ * Creates the exception
+ */
+ public ReadOnlyBufferException ()
+ {
+ }
+}
diff --git a/libjava/java/nio/ShortBuffer.java b/libjava/java/nio/ShortBuffer.java
new file mode 100644
index 00000000000..5301366ceee
--- /dev/null
+++ b/libjava/java/nio/ShortBuffer.java
@@ -0,0 +1,226 @@
+/* ShortBuffer.java --
+ Copyright (C) 2002 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 java.nio;
+
+import gnu.java.nio.ShortBufferImpl;
+
+public abstract class ShortBuffer extends Buffer
+{
+ private ByteOrder endian = ByteOrder.BIG_ENDIAN;
+ protected short [] backing_buffer;
+
+ public static ShortBuffer allocateDirect(int capacity)
+ {
+ return new ShortBufferImpl(capacity, 0, capacity);
+ }
+
+ public static ShortBuffer allocate(int capacity)
+ {
+ return new ShortBufferImpl(capacity, 0, capacity);
+ }
+
+ final public static ShortBuffer wrap(short[] array, int offset, int length)
+ {
+ return new ShortBufferImpl(array, offset, length);
+ }
+
+ final public static ShortBuffer wrap(String a)
+ {
+ int len = a.length();
+ short[] buffer = new short[len];
+
+ for (int i=0;i<len;i++)
+ {
+ buffer[i] = (short) a.charAt(i);
+ }
+
+ return wrap(buffer, 0, len);
+ }
+
+ final public static ShortBuffer wrap(short[] array)
+ {
+ return wrap(array, 0, array.length);
+ }
+
+ final public ShortBuffer get(short[] dst, int offset, int length)
+ {
+ for (int i = offset; i < offset + length; i++)
+ {
+ dst[i] = get();
+ }
+
+ return this;
+ }
+
+ final public ShortBuffer get(short[] dst)
+ {
+ return get(dst, 0, dst.length);
+ }
+
+ final public ShortBuffer put(ShortBuffer src)
+ {
+ while (src.hasRemaining())
+ put(src.get());
+
+ return this;
+ }
+
+ final public ShortBuffer put(short[] src, int offset, int length)
+ {
+ for (int i = offset; i < offset + length; i++)
+ put(src[i]);
+
+ return this;
+ }
+
+ public final ShortBuffer put(short[] src)
+ {
+ return put(src, 0, src.length);
+ }
+
+ public final boolean hasArray()
+ {
+ return (backing_buffer != null);
+ }
+
+ public final short[] array()
+ {
+ return backing_buffer;
+ }
+
+ public final int arrayOffset()
+ {
+ return 0;
+ }
+
+ public int hashCode()
+ {
+ return super.hashCode();
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ShortBuffer)
+ {
+ return compareTo(obj) == 0;
+ }
+
+ return false;
+ }
+
+ public int compareTo(Object ob)
+ {
+ ShortBuffer a = (ShortBuffer) ob;
+
+ if (a.remaining() != remaining())
+ return 1;
+
+ if (! hasArray() ||
+ ! a.hasArray())
+ {
+ return 1;
+ }
+
+ int r = remaining();
+ int i1 = position ();
+ int i2 = a.position ();
+
+ for (int i=0;i<r;i++)
+ {
+ int t = (int) (get(i1)- a.get(i2));
+
+ if (t != 0)
+ {
+ return (int) t;
+ }
+ }
+
+ return 0;
+ }
+
+ public final ByteOrder order()
+ {
+ return endian;
+ }
+
+ public final ShortBuffer order(ByteOrder bo)
+ {
+ endian = bo;
+ return this;
+ }
+
+ public abstract short get();
+ public abstract java.nio. ShortBuffer put(short b);
+ public abstract short get(int index);
+ public abstract java.nio. ShortBuffer put(int index, short b);
+ public abstract ShortBuffer compact();
+ public abstract boolean isDirect();
+ public abstract ShortBuffer slice();
+ public abstract ShortBuffer duplicate();
+ public abstract ShortBuffer asReadOnlyBuffer();
+ public abstract ShortBuffer asShortBuffer();
+ public abstract CharBuffer asCharBuffer();
+ public abstract IntBuffer asIntBuffer();
+ public abstract LongBuffer asLongBuffer();
+ public abstract FloatBuffer asFloatBuffer();
+ public abstract DoubleBuffer asDoubleBuffer();
+ public abstract char getChar();
+ public abstract ShortBuffer putChar(char value);
+ public abstract char getChar(int index);
+ public abstract ShortBuffer putChar(int index, char value);
+ public abstract short getShort();
+ public abstract ShortBuffer putShort(short value);
+ public abstract short getShort(int index);
+ public abstract ShortBuffer putShort(int index, short value);
+ public abstract int getInt();
+ public abstract ShortBuffer putInt(int value);
+ public abstract int getInt(int index);
+ public abstract ShortBuffer putInt(int index, int value);
+ public abstract long getLong();
+ public abstract ShortBuffer putLong(long value);
+ public abstract long getLong(int index);
+ public abstract ShortBuffer putLong(int index, long value);
+ public abstract float getFloat();
+ public abstract ShortBuffer putFloat(float value);
+ public abstract float getFloat(int index);
+ public abstract ShortBuffer putFloat(int index, float value);
+ public abstract double getDouble();
+ public abstract ShortBuffer putDouble(double value);
+ public abstract double getDouble(int index);
+ public abstract ShortBuffer putDouble(int index, double value);
+}
diff --git a/libjava/java/nio/channels/AsynchronousCloseException.java b/libjava/java/nio/channels/AsynchronousCloseException.java
new file mode 100644
index 00000000000..ec4bbc7fd47
--- /dev/null
+++ b/libjava/java/nio/channels/AsynchronousCloseException.java
@@ -0,0 +1,52 @@
+/* AsynchronousCloseException.java --
+ Copyright (C) 2002 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 java.nio.channels;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class AsynchronousCloseException extends ClosedChannelException
+{
+ /**
+ * Creates the exception
+ */
+ public AsynchronousCloseException()
+ {
+ }
+}
diff --git a/libjava/java/nio/channels/CancelledKeyException.java b/libjava/java/nio/channels/CancelledKeyException.java
new file mode 100644
index 00000000000..cf3c5cc352c
--- /dev/null
+++ b/libjava/java/nio/channels/CancelledKeyException.java
@@ -0,0 +1,52 @@
+/* CancelledKeyException.java --
+ Copyright (C) 2002 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 java.nio.channels;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class CancelledKeyException extends IllegalStateException
+{
+ /**
+ * Creates the exception
+ */
+ public CancelledKeyException()
+ {
+ }
+}
diff --git a/libjava/java/nio/channels/ClosedByInterruptException.java b/libjava/java/nio/channels/ClosedByInterruptException.java
new file mode 100644
index 00000000000..b99e016f17d
--- /dev/null
+++ b/libjava/java/nio/channels/ClosedByInterruptException.java
@@ -0,0 +1,52 @@
+/* ClosedByInterruptException.java --
+ Copyright (C) 2002 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 java.nio.channels;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class ClosedByInterruptException extends AsynchronousCloseException
+{
+ /**
+ * Creates the exception
+ */
+ public ClosedByInterruptException()
+ {
+ }
+}
diff --git a/libjava/java/nio/channels/ClosedSelectorException.java b/libjava/java/nio/channels/ClosedSelectorException.java
new file mode 100644
index 00000000000..98a9d505ded
--- /dev/null
+++ b/libjava/java/nio/channels/ClosedSelectorException.java
@@ -0,0 +1,52 @@
+/* ClosedSelectorException.java --
+ Copyright (C) 2002 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 java.nio.channels;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class ClosedSelectorException extends IllegalStateException
+{
+ /**
+ * Creates the exception
+ */
+ public ClosedSelectorException()
+ {
+ }
+}
diff --git a/libjava/java/nio/channels/ConnectionPendingException.java b/libjava/java/nio/channels/ConnectionPendingException.java
new file mode 100644
index 00000000000..876179c01b4
--- /dev/null
+++ b/libjava/java/nio/channels/ConnectionPendingException.java
@@ -0,0 +1,52 @@
+/* ConnectionPendingException.java --
+ Copyright (C) 2002 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 java.nio.channels;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class ConnectionPendingException extends IllegalStateException
+{
+ /**
+ * Creates the exception
+ */
+ public ConnectionPendingException()
+ {
+ }
+}
diff --git a/libjava/java/nio/channels/FileChannel.java b/libjava/java/nio/channels/FileChannel.java
new file mode 100644
index 00000000000..8970b983923
--- /dev/null
+++ b/libjava/java/nio/channels/FileChannel.java
@@ -0,0 +1,135 @@
+/* FileChannel.java --
+ Copyright (C) 2002 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 java.nio.channels;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.spi.AbstractInterruptibleChannel;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public abstract class FileChannel extends AbstractInterruptibleChannel
+ implements ByteChannel, GatheringByteChannel, ScatteringByteChannel
+{
+ public static class MapMode
+ {
+ public int m;
+
+ public static MapMode READ_ONLY = new MapMode(0);
+ public static MapMode READ_WRITE = new MapMode(1);
+ public static MapMode PRIVATE = new MapMode(2);
+
+ /**
+ * Initializes the MapMode.
+ */
+ MapMode(int a)
+ {
+ m = a;
+ }
+
+ public String toString()
+ {
+ return "" + m;
+ }
+ }
+
+ /**
+ * Initializes the channel.
+ */
+ protected FileChannel ()
+ {
+ }
+
+ /**
+ * Maps the file into the memory.
+ *
+ * @exception IOException If an error occurs.
+ */
+ public abstract MappedByteBuffer map(MapMode mode, long position, long size)
+ throws IOException;
+
+ /**
+ * Return the size of the file thus far
+ */
+ public abstract long size() throws IOException;
+
+ /**
+ * Writes data to the channel.
+ *
+ * @exception IOException If an error occurs.
+ */
+ public long write (ByteBuffer[] srcs) throws IOException
+ {
+ long result = 0;
+
+ for (int i = 0; i < srcs.length; i++)
+ {
+ result += write (srcs[i]);
+ }
+
+ return result;
+ }
+
+ /**
+ * Writes data to the channel.
+ */
+ public abstract long write(ByteBuffer[] srcs, int offset, int length)
+ throws IOException;
+
+ /**
+ * Reads data from the channel.
+ */
+ public abstract int read(ByteBuffer dst) throws IOException;
+
+ /**
+ * Closes the channel.
+ *
+ * This is called from @see close.
+ *
+ * @exception IOException If an error occurs.
+ */
+ protected abstract void implCloseChannel() throws IOException;
+
+ /**
+ * msync with the disk
+ */
+ public abstract void force(boolean metaData);
+}
diff --git a/libjava/java/nio/channels/FileLockInterruptionException.java b/libjava/java/nio/channels/FileLockInterruptionException.java
new file mode 100644
index 00000000000..563b0a08fe7
--- /dev/null
+++ b/libjava/java/nio/channels/FileLockInterruptionException.java
@@ -0,0 +1,54 @@
+/* FileLockInterruptionException.java --
+ Copyright (C) 2002 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 java.nio.channels;
+
+import java.io.IOException;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class FileLockInterruptionException extends IOException
+{
+ /**
+ * Creates the exception
+ */
+ public FileLockInterruptionException()
+ {
+ }
+}
diff --git a/libjava/java/nio/channels/IllegalSelectorException.java b/libjava/java/nio/channels/IllegalSelectorException.java
new file mode 100644
index 00000000000..20465e56b1d
--- /dev/null
+++ b/libjava/java/nio/channels/IllegalSelectorException.java
@@ -0,0 +1,52 @@
+/* IllegalSelectorException.java --
+ Copyright (C) 2002 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 java.nio.channels;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class IllegalSelectorException extends IllegalArgumentException
+{
+ /**
+ * Creates the exception
+ */
+ public IllegalSelectorException()
+ {
+ }
+}
diff --git a/libjava/java/nio/channels/NoConnectionPendingException.java b/libjava/java/nio/channels/NoConnectionPendingException.java
new file mode 100644
index 00000000000..f859cf6f651
--- /dev/null
+++ b/libjava/java/nio/channels/NoConnectionPendingException.java
@@ -0,0 +1,52 @@
+/* NoConnectionPendingException.java --
+ Copyright (C) 2002 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 java.nio.channels;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class NoConnectionPendingException extends IllegalStateException
+{
+ /**
+ * Creates the exception
+ */
+ public NoConnectionPendingException()
+ {
+ }
+}
diff --git a/libjava/java/nio/channels/NonReadableChannelException.java b/libjava/java/nio/channels/NonReadableChannelException.java
new file mode 100644
index 00000000000..cb146bb5133
--- /dev/null
+++ b/libjava/java/nio/channels/NonReadableChannelException.java
@@ -0,0 +1,52 @@
+/* NonReadableChannelException.java --
+ Copyright (C) 2002 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 java.nio.channels;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class NonReadableChannelException extends IllegalStateException
+{
+ /**
+ * Creates the exception
+ */
+ public NonReadableChannelException()
+ {
+ }
+}
diff --git a/libjava/java/nio/channels/NonWritableChannelException.java b/libjava/java/nio/channels/NonWritableChannelException.java
new file mode 100644
index 00000000000..a26af3537c2
--- /dev/null
+++ b/libjava/java/nio/channels/NonWritableChannelException.java
@@ -0,0 +1,52 @@
+/* NonWritableChannelException.java --
+ Copyright (C) 2002 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 java.nio.channels;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class NonWritableChannelException extends IllegalStateException
+{
+ /**
+ * Creates the exception
+ */
+ public NonWritableChannelException()
+ {
+ }
+}
diff --git a/libjava/java/nio/channels/NotYetBoundException.java b/libjava/java/nio/channels/NotYetBoundException.java
new file mode 100644
index 00000000000..0367b35e90d
--- /dev/null
+++ b/libjava/java/nio/channels/NotYetBoundException.java
@@ -0,0 +1,52 @@
+/* NotYetBoundException.java --
+ Copyright (C) 2002 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 java.nio.channels;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class NotYetBoundException extends IllegalStateException
+{
+ /**
+ * Creates the exception
+ */
+ public NotYetBoundException()
+ {
+ }
+}
diff --git a/libjava/java/nio/channels/NotYetConnectedException.java b/libjava/java/nio/channels/NotYetConnectedException.java
new file mode 100644
index 00000000000..3c15369611b
--- /dev/null
+++ b/libjava/java/nio/channels/NotYetConnectedException.java
@@ -0,0 +1,52 @@
+/* NotYetConnectedException.java --
+ Copyright (C) 2002 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 java.nio.channels;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class NotYetConnectedException extends IllegalStateException
+{
+ /**
+ * Creates the exception
+ */
+ public NotYetConnectedException()
+ {
+ }
+}
diff --git a/libjava/java/nio/channels/OverlappingFileLockException.java b/libjava/java/nio/channels/OverlappingFileLockException.java
new file mode 100644
index 00000000000..2f856d3ea73
--- /dev/null
+++ b/libjava/java/nio/channels/OverlappingFileLockException.java
@@ -0,0 +1,52 @@
+/* OverlappingFileLockException.java --
+ Copyright (C) 2002 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 java.nio.channels;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class OverlappingFileLockException extends IllegalStateException
+{
+ /**
+ * Creates the exception
+ */
+ public OverlappingFileLockException()
+ {
+ }
+}
diff --git a/libjava/java/nio/channels/UnresolvedAddressException.java b/libjava/java/nio/channels/UnresolvedAddressException.java
new file mode 100644
index 00000000000..1cfdf970dca
--- /dev/null
+++ b/libjava/java/nio/channels/UnresolvedAddressException.java
@@ -0,0 +1,52 @@
+/* UnresolvedAddressException.java --
+ Copyright (C) 2002 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 java.nio.channels;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class UnresolvedAddressException extends IllegalArgumentException
+{
+ /**
+ * Creates the exception
+ */
+ public UnresolvedAddressException()
+ {
+ }
+}
diff --git a/libjava/java/nio/channels/UnsupportedAddressTypeException.java b/libjava/java/nio/channels/UnsupportedAddressTypeException.java
new file mode 100644
index 00000000000..824772a235b
--- /dev/null
+++ b/libjava/java/nio/channels/UnsupportedAddressTypeException.java
@@ -0,0 +1,52 @@
+/* UnsupportedAddressTypeException.java --
+ Copyright (C) 2002 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 java.nio.channels;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public class UnsupportedAddressTypeException extends IllegalArgumentException
+{
+ /**
+ * Creates the exception
+ */
+ public UnsupportedAddressTypeException()
+ {
+ }
+}
diff --git a/libjava/java/nio/charset/CharsetDecoder.java b/libjava/java/nio/charset/CharsetDecoder.java
new file mode 100644
index 00000000000..185de149fd4
--- /dev/null
+++ b/libjava/java/nio/charset/CharsetDecoder.java
@@ -0,0 +1,312 @@
+/* CharsetDecoder.java --
+ Copyright (C) 2002 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 java.nio.charset;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+
+/**
+ * @author Jesse Rosenstock
+ * @since 1.4
+ */
+public abstract class CharsetDecoder
+{
+ private static final int STATE_RESET = 0;
+ private static final int STATE_CODING = 1;
+ private static final int STATE_END = 2;
+ private static final int STATE_FLUSHED = 3;
+
+ private static final String DEFAULT_REPLACEMENT = "\uFFFD";
+
+ private final Charset charset;
+ private final float averageCharsPerByte;
+ private final float maxCharsPerByte;
+ private String replacement;
+
+ private int state = STATE_RESET;
+
+ private CodingErrorAction malformedInputAction
+ = CodingErrorAction.REPORT;
+ private CodingErrorAction unmappableCharacterAction
+ = CodingErrorAction.REPORT;
+
+ private CharsetDecoder (Charset cs, float averageCharsPerByte,
+ float maxCharsPerByte, String replacement)
+ {
+ if (averageCharsPerByte <= 0.0f)
+ throw new IllegalArgumentException ("Non-positive averageCharsPerByte");
+ if (maxCharsPerByte <= 0.0f)
+ throw new IllegalArgumentException ("Non-positive maxCharsPerByte");
+
+ this.charset = cs;
+ this.averageCharsPerByte
+ = averageCharsPerByte;
+ this.maxCharsPerByte
+ = maxCharsPerByte;
+ this.replacement = replacement;
+ implReplaceWith (replacement);
+ }
+
+ protected CharsetDecoder (Charset cs, float averageCharsPerByte,
+ float maxCharsPerByte)
+ {
+ this (cs, averageCharsPerByte, maxCharsPerByte, DEFAULT_REPLACEMENT);
+ }
+
+ public final float averageCharsPerByte ()
+ {
+ return averageCharsPerByte;
+ }
+
+ public final Charset charset ()
+ {
+ return charset;
+ }
+
+ public final CharBuffer decode (ByteBuffer in)
+ throws CharacterCodingException
+ {
+ // XXX: Sun's Javadoc seems to contradict itself saying an
+ // IllegalStateException is thrown "if a decoding operation is already
+ // in progress" and also that "it resets this Decoder".
+ // Should we check to see that the state is reset, or should we
+ // call reset()?
+ if (state != STATE_RESET)
+ throw new IllegalStateException ();
+
+ // REVIEW: Using max instead of average may allocate a very large
+ // buffer. Maybe we should do something more efficient?
+ int remaining = in.remaining ();
+ int n = (int) (remaining * maxCharsPerByte ());
+ CharBuffer out = CharBuffer.allocate (n);
+
+ if (remaining == 0)
+ {
+ state = STATE_FLUSHED;
+ return out;
+ }
+
+ CoderResult cr = decode (in, out, true);
+ if (cr.isError ())
+ cr.throwException ();
+
+ cr = flush (out);
+ if (cr.isError ())
+ cr.throwException ();
+
+ out.flip ();
+ return out;
+ }
+
+ public final CoderResult decode (ByteBuffer in, CharBuffer out,
+ boolean endOfInput)
+ {
+ int newState = endOfInput ? STATE_END : STATE_CODING;
+ // XXX: Need to check for "previous step was an invocation [not] of
+ // this method with a value of true for the endOfInput parameter but
+ // a return value indicating an incomplete decoding operation"
+ // XXX: We will not check the previous return value, just
+ // that the previous call passed true for endOfInput
+ if (state != STATE_RESET && state != STATE_CODING
+ && !(endOfInput && state == STATE_END))
+ throw new IllegalStateException ();
+ state = newState;
+
+ for (;;)
+ {
+ CoderResult cr;
+ try
+ {
+ cr = decodeLoop (in, out);
+ }
+ catch (RuntimeException e)
+ {
+ throw new CoderMalfunctionError (e);
+ }
+
+ if (cr.isOverflow ())
+ return cr;
+
+ if (cr.isUnderflow ())
+ {
+ if (endOfInput && in.hasRemaining ())
+ cr = CoderResult.malformedForLength (in.remaining ());
+ else
+ return cr;
+ }
+
+ CodingErrorAction action = cr.isMalformed ()
+ ? malformedInputAction
+ : unmappableCharacterAction;
+
+ if (action == CodingErrorAction.REPORT)
+ return cr;
+
+ if (action == CodingErrorAction.REPLACE)
+ {
+ if (out.remaining () < replacement.length ())
+ return CoderResult.OVERFLOW;
+ out.put (replacement);
+ }
+
+ in.position (in.position () + cr.length ());
+ }
+ }
+
+ protected abstract CoderResult decodeLoop (ByteBuffer in, CharBuffer out);
+
+ public Charset detectedCharset ()
+ {
+ throw new UnsupportedOperationException ();
+ }
+
+ public final CoderResult flush (CharBuffer out)
+ {
+ // It seems weird that you can flush after reset, but Sun's javadoc
+ // says an IllegalStateException is thrown "If the previous step of the
+ // current decoding operation was an invocation neither of the reset
+ // method nor ... of the three-argument decode method with a value of
+ // true for the endOfInput parameter."
+ // Further note that flush() only requires that there not be
+ // an IllegalStateException if the previous step was a call to
+ // decode with true as the last argument. It does not require
+ // that the call succeeded. decode() does require that it succeeded.
+ // XXX: test this to see if reality matches javadoc
+ if (state != STATE_RESET && state != STATE_END)
+ throw new IllegalStateException ();
+
+ state = STATE_FLUSHED;
+ return implFlush (out);
+ }
+
+ protected CoderResult implFlush (CharBuffer out)
+ {
+ return CoderResult.UNDERFLOW;
+ }
+
+ public final CharsetDecoder onMalformedInput (CodingErrorAction newAction)
+ {
+ if (newAction == null)
+ throw new IllegalArgumentException ("Null action");
+
+ malformedInputAction = newAction;
+ implOnMalformedInput (newAction);
+ return this;
+ }
+
+ protected void implOnMalformedInput (CodingErrorAction newAction)
+ {
+ // default implementation does nothing
+ }
+
+ protected void implOnUnmappableCharacter (CodingErrorAction newAction)
+ {
+ // default implementation does nothing
+ }
+
+ protected void implReplaceWith (String newReplacement)
+ {
+ // default implementation does nothing
+ }
+
+ protected void implReset ()
+ {
+ // default implementation does nothing
+ }
+
+ public boolean isAutoDetecting ()
+ {
+ return false;
+ }
+
+ public boolean isCharsetDetected ()
+ {
+ throw new UnsupportedOperationException ();
+ }
+
+ public CodingErrorAction malformedInputAction ()
+ {
+ return malformedInputAction;
+ }
+
+ public final float maxCharsPerByte ()
+ {
+ return maxCharsPerByte;
+ }
+
+ public final CharsetDecoder onUnmappableCharacter
+ (CodingErrorAction newAction)
+ {
+ if (newAction == null)
+ throw new IllegalArgumentException ("Null action");
+
+ unmappableCharacterAction = newAction;
+ implOnUnmappableCharacter (newAction);
+ return this;
+ }
+
+ public final String replacement ()
+ {
+ return replacement;
+ }
+
+ public final CharsetDecoder replaceWith (String newReplacement)
+ {
+ if (newReplacement == null)
+ throw new IllegalArgumentException ("Null replacement");
+ if (newReplacement.length () == 0)
+ throw new IllegalArgumentException ("Empty replacement");
+ // XXX: what about maxCharsPerByte?
+
+ this.replacement = newReplacement;
+ implReplaceWith (newReplacement);
+ return this;
+ }
+
+ public final CharsetDecoder reset ()
+ {
+ state = STATE_RESET;
+ implReset ();
+ return this;
+ }
+
+ public CodingErrorAction unmappableCharacterAction ()
+ {
+ return unmappableCharacterAction;
+ }
+}
diff --git a/libjava/java/nio/charset/CharsetEncoder.java b/libjava/java/nio/charset/CharsetEncoder.java
new file mode 100644
index 00000000000..dd434a79752
--- /dev/null
+++ b/libjava/java/nio/charset/CharsetEncoder.java
@@ -0,0 +1,360 @@
+/* CharsetEncoder.java --
+ Copyright (C) 2002 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 java.nio.charset;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+
+/**
+ * @author Jesse Rosenstock
+ * @since 1.4
+ */
+public abstract class CharsetEncoder
+{
+ private static final int STATE_RESET = 0;
+ private static final int STATE_CODING = 1;
+ private static final int STATE_END = 2;
+ private static final int STATE_FLUSHED = 3;
+
+ private static final byte[] DEFAULT_REPLACEMENT = {(byte)'?'};
+
+ private final Charset charset;
+ private final float averageBytesPerChar;
+ private final float maxBytesPerChar;
+ private byte[] replacement;
+
+ private int state = STATE_RESET;
+
+ private CodingErrorAction malformedInputAction
+ = CodingErrorAction.REPORT;
+ private CodingErrorAction unmappableCharacterAction
+ = CodingErrorAction.REPORT;
+
+ protected CharsetEncoder (Charset cs, float averageBytesPerChar,
+ float maxBytesPerChar)
+ {
+ this (cs, averageBytesPerChar, maxBytesPerChar, DEFAULT_REPLACEMENT);
+ }
+
+ protected CharsetEncoder (Charset cs, float averageBytesPerChar,
+ float maxBytesPerChar, byte[] replacement)
+ {
+ if (averageBytesPerChar <= 0.0f)
+ throw new IllegalArgumentException ("Non-positive averageBytesPerChar");
+ if (maxBytesPerChar <= 0.0f)
+ throw new IllegalArgumentException ("Non-positive maxBytesPerChar");
+
+ this.charset = cs;
+ this.averageBytesPerChar
+ = averageBytesPerChar;
+ this.maxBytesPerChar
+ = maxBytesPerChar;
+ this.replacement = replacement;
+ implReplaceWith (replacement);
+ }
+
+ public final float averageBytesPerChar ()
+ {
+ return averageBytesPerChar;
+ }
+
+ public boolean canEncode (char c)
+ {
+ CharBuffer cb = CharBuffer.allocate (1).put (c);
+ cb.flip ();
+ return canEncode (cb);
+ }
+
+ public boolean canEncode (CharSequence cs)
+ {
+ CharBuffer cb;
+ if (cs instanceof CharBuffer)
+ cb = ((CharBuffer) cs).duplicate ();
+ else
+ cb = CharBuffer.wrap (cs);
+ return canEncode (cb);
+ }
+
+ private boolean canEncode (CharBuffer cb)
+ {
+ // It is an error if a coding operation is "in progress"
+ // I take that to mean the state is not reset or flushed.
+ // XXX: check "in progress" everywhere
+ if (state == STATE_FLUSHED)
+ reset ();
+ else if (state != STATE_RESET)
+ throw new IllegalStateException ();
+
+ CodingErrorAction oldMalformedInputAction = malformedInputAction;
+ CodingErrorAction oldUnmappableCharacterAction
+ = unmappableCharacterAction;
+
+ try
+ {
+ if (oldMalformedInputAction != CodingErrorAction.REPORT)
+ onMalformedInput (CodingErrorAction.REPORT);
+ if (oldUnmappableCharacterAction != CodingErrorAction.REPORT)
+ onUnmappableCharacter (CodingErrorAction.REPORT);
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ finally
+ {
+ if (oldMalformedInputAction != CodingErrorAction.REPORT)
+ onMalformedInput (oldMalformedInputAction);
+ if (oldUnmappableCharacterAction != CodingErrorAction.REPORT)
+ onUnmappableCharacter (oldUnmappableCharacterAction);
+ }
+
+ return true;
+ }
+
+ public final Charset charset ()
+ {
+ return charset;
+ }
+
+ public final ByteBuffer encode (CharBuffer in)
+ throws CharacterCodingException
+ {
+ // XXX: Sun's Javadoc seems to contradict itself saying an
+ // IllegalStateException is thrown "if a decoding operation is already
+ // in progress" and also that "it resets this Encoder".
+ // Should we check to see that the state is reset, or should we
+ // call reset()?
+ if (state != STATE_RESET)
+ throw new IllegalStateException ();
+
+ // REVIEW: Using max instead of average may allocate a very large
+ // buffer. Maybe we should do something more efficient?
+ int remaining = in.remaining ();
+ int n = (int) (remaining * maxBytesPerChar ());
+ ByteBuffer out = ByteBuffer.allocate (n);
+
+ if (remaining == 0)
+ {
+ state = STATE_FLUSHED;
+ return out;
+ }
+
+ CoderResult cr = encode (in, out, true);
+ if (cr.isError ())
+ cr.throwException ();
+
+ cr = flush (out);
+ if (cr.isError ())
+ cr.throwException ();
+
+ out.flip ();
+ return out;
+ }
+
+ public final CoderResult encode (CharBuffer in, ByteBuffer out,
+ boolean endOfInput)
+ {
+ int newState = endOfInput ? STATE_END : STATE_CODING;
+ // XXX: Need to check for "previous step was an invocation [not] of
+ // this method with a value of true for the endOfInput parameter but
+ // a return value indicating an incomplete decoding operation"
+ // XXX: We will not check the previous return value, just
+ // that the previous call passed true for endOfInput
+ if (state != STATE_RESET && state != STATE_CODING
+ && !(endOfInput && state == STATE_END))
+ throw new IllegalStateException ();
+ state = newState;
+
+ for (;;)
+ {
+ CoderResult cr;
+ try
+ {
+ cr = encodeLoop (in, out);
+ }
+ catch (RuntimeException e)
+ {
+ throw new CoderMalfunctionError (e);
+ }
+
+ if (cr.isOverflow ())
+ return cr;
+
+ if (cr.isUnderflow ())
+ {
+ if (endOfInput && in.hasRemaining ())
+ cr = CoderResult.malformedForLength (in.remaining ());
+ else
+ return cr;
+ }
+
+ CodingErrorAction action = cr.isMalformed ()
+ ? malformedInputAction
+ : unmappableCharacterAction;
+
+ if (action == CodingErrorAction.REPORT)
+ return cr;
+
+ if (action == CodingErrorAction.REPLACE)
+ {
+ if (out.remaining () < replacement.length)
+ return CoderResult.OVERFLOW;
+ out.put (replacement);
+ }
+
+ in.position (in.position () + cr.length ());
+ }
+ }
+
+ protected abstract CoderResult encodeLoop (CharBuffer in, ByteBuffer out);
+
+ public final CoderResult flush (ByteBuffer out)
+ {
+ // It seems weird that you can flush after reset, but Sun's javadoc
+ // says an IllegalStateException is thrown "If the previous step of the
+ // current decoding operation was an invocation neither of the reset
+ // method nor ... of the three-argument encode method with a value of
+ // true for the endOfInput parameter."
+ // Further note that flush() only requires that there not be
+ // an IllegalStateException if the previous step was a call to
+ // encode with true as the last argument. It does not require
+ // that the call succeeded. encode() does require that it succeeded.
+ // XXX: test this to see if reality matches javadoc
+ if (state != STATE_RESET && state != STATE_END)
+ throw new IllegalStateException ();
+
+ state = STATE_FLUSHED;
+ return implFlush (out);
+ }
+
+ protected CoderResult implFlush (ByteBuffer out)
+ {
+ return CoderResult.UNDERFLOW;
+ }
+
+ protected void implOnMalformedInput (CodingErrorAction newAction)
+ {
+ // default implementation does nothing
+ }
+
+ protected void implOnUnmappableCharacter (CodingErrorAction newAction)
+ {
+ // default implementation does nothing
+ }
+
+ protected void implReplaceWith (byte[] newReplacement)
+ {
+ // default implementation does nothing
+ }
+
+ protected void implReset ()
+ {
+ // default implementation does nothing
+ }
+
+ public boolean isLegalReplacement (byte[] replacement)
+ {
+ // TODO: cache the decoder
+ // error actions will be REPORT after construction
+ CharsetDecoder decoder = charset.newDecoder ();
+ ByteBuffer bb = ByteBuffer.wrap (replacement);
+ CharBuffer cb
+ = CharBuffer.allocate ((int) (replacement.length
+ * decoder.maxCharsPerByte ()));
+ return !decoder.decode (bb, cb, true).isError ();
+ }
+
+ public CodingErrorAction malformedInputAction ()
+ {
+ return malformedInputAction;
+ }
+
+ public final float maxBytesPerChar ()
+ {
+ return maxBytesPerChar;
+ }
+
+ public final CharsetEncoder onMalformedInput (CodingErrorAction newAction)
+ {
+ if (newAction == null)
+ throw new IllegalArgumentException ("Null action");
+
+ malformedInputAction = newAction;
+ implOnMalformedInput (newAction);
+ return this;
+ }
+
+ public final CharsetEncoder onUnmappableCharacter
+ (CodingErrorAction newAction)
+ {
+ if (newAction == null)
+ throw new IllegalArgumentException ("Null action");
+
+ unmappableCharacterAction = newAction;
+ implOnUnmappableCharacter (newAction);
+ return this;
+ }
+
+ public final byte[] replacement ()
+ {
+ return replacement;
+ }
+
+ public final CharsetEncoder replaceWith (byte[] newReplacement)
+ {
+ if (newReplacement == null)
+ throw new IllegalArgumentException ("Null replacement");
+ if (newReplacement.length == 0)
+ throw new IllegalArgumentException ("Empty replacement");
+ // XXX: what about maxBytesPerChar?
+
+ if (!isLegalReplacement (newReplacement))
+ throw new IllegalArgumentException ("Illegal replacement");
+
+ this.replacement = newReplacement;
+ implReplaceWith (newReplacement);
+ return this;
+ }
+
+ public final CharsetEncoder reset ()
+ {
+ state = STATE_RESET;
+ implReset ();
+ return this;
+ }
+}
diff --git a/libjava/java/nio/charset/CoderResult.java b/libjava/java/nio/charset/CoderResult.java
new file mode 100644
index 00000000000..49c66637c79
--- /dev/null
+++ b/libjava/java/nio/charset/CoderResult.java
@@ -0,0 +1,193 @@
+/* CoderResult.java --
+ Copyright (C) 2002 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 java.nio.charset;
+
+import java.lang.ref.WeakReference;
+import java.nio.BufferOverflowException;
+import java.nio.BufferUnderflowException;
+import java.util.HashMap;
+
+/**
+ * @author Jesse Rosenstock
+ * @since 1.4
+ */
+public class CoderResult
+{
+ private static final int TYPE_MALFORMED = 0;
+ private static final int TYPE_OVERFLOW = 1;
+ private static final int TYPE_UNDERFLOW = 2;
+ private static final int TYPE_UNMAPPABLE = 3;
+
+ public static final CoderResult OVERFLOW
+ = new CoderResult (TYPE_OVERFLOW, 0);
+ public static final CoderResult UNDERFLOW
+ = new CoderResult (TYPE_UNDERFLOW, 0);
+
+ private static final String[] names
+ = { "MALFORMED", "OVERFLOW", "UNDERFLOW", "UNMAPPABLE" };
+
+ private static final Cache malformedCache
+ = new Cache ()
+ {
+ protected CoderResult make (int length)
+ {
+ return new CoderResult (TYPE_MALFORMED, length);
+ }
+ };
+
+ private static final Cache unmappableCache
+ = new Cache ()
+ {
+ protected CoderResult make (int length)
+ {
+ return new CoderResult (TYPE_UNMAPPABLE, length);
+ }
+ };
+
+ private final int type;
+ private final int length;
+
+ private CoderResult (int type, int length)
+ {
+ this.type = type;
+ this.length = length;
+ }
+
+ public boolean isError ()
+ {
+ return length > 0;
+ }
+
+ public boolean isMalformed ()
+ {
+ return type == TYPE_MALFORMED;
+ }
+
+ public boolean isOverflow ()
+ {
+ return type == TYPE_OVERFLOW;
+ }
+
+ public boolean isUnderflow ()
+ {
+ return type == TYPE_UNDERFLOW;
+ }
+
+ public boolean isUnmappable ()
+ {
+ return type == TYPE_UNMAPPABLE;
+ }
+
+ public int length ()
+ {
+ if (length <= 0)
+ throw new UnsupportedOperationException ();
+ else
+ return length;
+ }
+
+ public static CoderResult malformedForLength (int length)
+ {
+ return malformedCache.get (length);
+ }
+
+ public void throwException ()
+ throws CharacterCodingException
+ {
+ switch (type)
+ {
+ case TYPE_MALFORMED:
+ throw new MalformedInputException (length);
+ case TYPE_OVERFLOW:
+ throw new BufferOverflowException ();
+ case TYPE_UNDERFLOW:
+ throw new BufferUnderflowException ();
+ case TYPE_UNMAPPABLE:
+ throw new UnmappableCharacterException (length);
+ }
+ }
+
+ public String toString ()
+ {
+ String name = names[type];
+ return (length > 0) ? name + '[' + length + ']' : name;
+ }
+
+ public static CoderResult unmappableForLength (int length)
+ {
+ return unmappableCache.get (length);
+ }
+
+ private abstract static class Cache
+ {
+ private final HashMap cache;
+
+ private Cache ()
+ {
+ // If we didn't synchronize on this, then cache would be initialized
+ // without holding a lock. Undefined behavior would occur if the
+ // first thread to call get(int) was not the same as the one that
+ // called the constructor.
+ synchronized (this)
+ {
+ cache = new HashMap ();
+ }
+ }
+
+ private synchronized CoderResult get (int length)
+ {
+ if (length <= 0)
+ throw new IllegalArgumentException ("Non-positive length");
+
+ Integer len = new Integer (length);
+ CoderResult cr = null;
+ Object o;
+ if ((o = cache.get (len)) != null)
+ cr = (CoderResult) ((WeakReference) o).get ();
+ if (cr == null)
+ {
+ cr = make (length);
+ cache.put (len, new WeakReference (cr));
+ }
+
+ return cr;
+ }
+
+ protected abstract CoderResult make (int length);
+ }
+}
diff --git a/libjava/testsuite/libjava.lang/pr8676.java b/libjava/testsuite/libjava.lang/pr8676.java
new file mode 100644
index 00000000000..e28b15b1ab5
--- /dev/null
+++ b/libjava/testsuite/libjava.lang/pr8676.java
@@ -0,0 +1,11 @@
+public class pr8676 {
+ // The problem here was that this function couldn't be compiled to
+ // bytecode.
+ private void f(long j) {
+ boolean x = (1 << j) != 0;
+ }
+
+ public static void main(String[] args)
+ {
+ }
+}
diff --git a/libjava/testsuite/libjava.lang/pr8676.out b/libjava/testsuite/libjava.lang/pr8676.out
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/libjava/testsuite/libjava.lang/pr8676.out