aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.2.1/libjava/java/nio
diff options
context:
space:
mode:
authorJing Yu <jingyu@google.com>2009-11-05 15:11:04 -0800
committerJing Yu <jingyu@google.com>2009-11-05 15:11:04 -0800
commitdf62c1c110e8532b995b23540b7e3695729c0779 (patch)
treedbbd4cbdb50ac38011e058a2533ee4c3168b0205 /gcc-4.2.1/libjava/java/nio
parent8d401cf711539af5a2f78d12447341d774892618 (diff)
downloadtoolchain_gcc-df62c1c110e8532b995b23540b7e3695729c0779.tar.gz
toolchain_gcc-df62c1c110e8532b995b23540b7e3695729c0779.tar.bz2
toolchain_gcc-df62c1c110e8532b995b23540b7e3695729c0779.zip
Check in gcc sources for prebuilt toolchains in Eclair.
Diffstat (limited to 'gcc-4.2.1/libjava/java/nio')
-rw-r--r--gcc-4.2.1/libjava/java/nio/Buffer.java361
-rw-r--r--gcc-4.2.1/libjava/java/nio/DirectByteBufferImpl.java431
-rw-r--r--gcc-4.2.1/libjava/java/nio/MappedByteBuffer.java89
-rw-r--r--gcc-4.2.1/libjava/java/nio/MappedByteBufferImpl.java360
-rw-r--r--gcc-4.2.1/libjava/java/nio/VMDirectByteBuffer.java53
-rw-r--r--gcc-4.2.1/libjava/java/nio/channels/VMChannels.java85
-rw-r--r--gcc-4.2.1/libjava/java/nio/channels/natVMChannels.cc37
-rw-r--r--gcc-4.2.1/libjava/java/nio/charset/Charset.java412
-rw-r--r--gcc-4.2.1/libjava/java/nio/charset/spi/CharsetProvider.java96
-rw-r--r--gcc-4.2.1/libjava/java/nio/natDirectByteBufferImpl.cc72
10 files changed, 1996 insertions, 0 deletions
diff --git a/gcc-4.2.1/libjava/java/nio/Buffer.java b/gcc-4.2.1/libjava/java/nio/Buffer.java
new file mode 100644
index 000000000..f369b9622
--- /dev/null
+++ b/gcc-4.2.1/libjava/java/nio/Buffer.java
@@ -0,0 +1,361 @@
+/* Buffer.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+import gnu.gcj.RawData;
+
+/**
+ * @since 1.4
+ */
+public abstract class Buffer
+{
+ int cap = 0;
+ int limit = 0;
+ int pos = 0;
+ int mark = -1;
+ RawData address;
+
+ /**
+ * Creates a new Buffer.
+ *
+ * Should be package private.
+ */
+ Buffer (int capacity, int limit, int position, int mark)
+ {
+ if (capacity < 0)
+ throw new IllegalArgumentException ();
+
+ cap = capacity;
+ limit (limit);
+ position (position);
+
+ if (mark >= 0)
+ {
+ if (mark > pos)
+ throw new IllegalArgumentException ();
+
+ this.mark = mark;
+ }
+ }
+
+ /**
+ * Retrieves the capacity of the buffer.
+ *
+ * @return the capacity of the buffer
+ */
+ public final int capacity ()
+ {
+ return cap;
+ }
+
+ /**
+ * Clears the buffer.
+ *
+ * @return this buffer
+ */
+ public final Buffer clear ()
+ {
+ limit = cap;
+ pos = 0;
+ mark = -1;
+ return this;
+ }
+
+ /**
+ * Flips the buffer.
+ *
+ * @return this buffer
+ */
+ public final Buffer flip ()
+ {
+ limit = pos;
+ pos = 0;
+ mark = -1;
+ return this;
+ }
+
+ /**
+ * Tells whether the buffer has remaining data to read or not.
+ *
+ * @return true if the buffer contains remaining data to read,
+ * false otherwise
+ */
+ public final boolean hasRemaining ()
+ {
+ return remaining() > 0;
+ }
+
+ /**
+ * Tells whether this buffer is read only or not.
+ *
+ * @return true if the buffer is read only, false otherwise
+ */
+ public abstract boolean isReadOnly ();
+
+ /**
+ * Retrieves the current limit of the buffer.
+ *
+ * @return the limit of the buffer
+ */
+ public final int limit ()
+ {
+ return limit;
+ }
+
+ /**
+ * Sets this buffer's limit.
+ *
+ * @param newLimit The new limit value; must be non-negative and no larger
+ * than this buffer's capacity.
+ *
+ * @return this buffer
+ *
+ * @exception IllegalArgumentException If the preconditions on newLimit
+ * do not hold.
+ */
+ public final Buffer limit (int newLimit)
+ {
+ if ((newLimit < 0) || (newLimit > cap))
+ throw new IllegalArgumentException ();
+
+ if (newLimit < mark)
+ mark = -1;
+
+ if (pos > newLimit)
+ pos = newLimit;
+
+ limit = newLimit;
+ return this;
+ }
+
+ /**
+ * Sets this buffer's mark at its position.
+ *
+ * @return this buffer
+ */
+ public final Buffer mark ()
+ {
+ mark = pos;
+ return this;
+ }
+
+ /**
+ * Retrieves the current position of this buffer.
+ *
+ * @return the current position of this buffer
+ */
+ public final int position ()
+ {
+ return pos;
+ }
+
+ /**
+ * Sets this buffer's position. If the mark is defined and larger than the
+ * new position then it is discarded.
+ *
+ * @param newPosition The new position value; must be non-negative and no
+ * larger than the current limit.
+ *
+ * @return this buffer
+ *
+ * @exception IllegalArgumentException If the preconditions on newPosition
+ * do not hold
+ */
+ public final Buffer position (int newPosition)
+ {
+ if ((newPosition < 0) || (newPosition > limit))
+ throw new IllegalArgumentException ();
+
+ if (newPosition <= mark)
+ mark = -1;
+
+ pos = newPosition;
+ return this;
+ }
+
+ /**
+ * Returns the number of elements between the current position and the limit.
+ *
+ * @return the number of remaining elements
+ */
+ public final int remaining()
+ {
+ return limit - pos;
+ }
+
+ /**
+ * Resets this buffer's position to the previously-marked position.
+ *
+ * @return this buffer
+ *
+ * @exception InvalidMarkException If the mark has not been set.
+ */
+ public final Buffer reset()
+ {
+ if (mark == -1)
+ throw new InvalidMarkException ();
+
+ pos = mark;
+ return this;
+ }
+
+ /**
+ * Rewinds this buffer. The position is set to zero and the mark
+ * is discarded.
+ *
+ * @return this buffer
+ */
+ public final Buffer rewind()
+ {
+ pos = 0;
+ mark = -1;
+ return this;
+ }
+
+ /**
+ * Checks for underflow. This method is used internally to check
+ * whether a buffer has enough elements left to satisfy a read
+ * request.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * elements in this buffer.
+ */
+ final void checkForUnderflow()
+ {
+ if (!hasRemaining())
+ throw new BufferUnderflowException();
+ }
+
+ /**
+ * Checks for underflow. This method is used internally to check
+ * whether a buffer has enough elements left to satisfy a read
+ * request for a given number of elements.
+ *
+ * @param length The length of a sequence of elements.
+ *
+ * @exception BufferUnderflowException If there are not enough
+ * remaining elements in this buffer.
+ */
+ final void checkForUnderflow(int length)
+ {
+ if (remaining() < length)
+ throw new BufferUnderflowException();
+ }
+
+ /**
+ * Checks for overflow. This method is used internally to check
+ * whether a buffer has enough space left to satisfy a write
+ * request.
+ *
+ * @exception BufferOverflowException If there is no remaining
+ * space in this buffer.
+ */
+ final void checkForOverflow()
+ {
+ if (!hasRemaining())
+ throw new BufferOverflowException();
+ }
+
+ /**
+ * Checks for overflow. This method is used internally to check
+ * whether a buffer has enough space left to satisfy a write
+ * request for a given number of elements.
+ *
+ * @param length The length of a sequence of elements.
+ *
+ * @exception BufferUnderflowException If there is not enough
+ * remaining space in this buffer.
+ */
+ final void checkForOverflow(int length)
+ {
+ if (remaining() < length)
+ throw new BufferOverflowException();
+ }
+
+ /**
+ * Checks if index is negative or not smaller than the buffer's
+ * limit. This method is used internally to check whether
+ * an indexed request can be fulfilled.
+ *
+ * @param index The requested position in the buffer.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
+ final void checkIndex(int index)
+ {
+ if (index < 0
+ || index >= limit ())
+ throw new IndexOutOfBoundsException ();
+ }
+
+ /**
+ * Checks if buffer is read-only. This method is used internally to
+ * check if elements can be put into a buffer.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
+ final void checkIfReadOnly()
+ {
+ if (isReadOnly())
+ throw new ReadOnlyBufferException ();
+ }
+
+ /**
+ * Checks whether an array is large enough to hold the given number of
+ * elements at the given offset. This method is used internally to
+ * check if an array is big enough.
+ *
+ * @param arraylength The length of the array.
+ * @param offset The offset within the array of the first byte to be read;
+ * must be non-negative and no larger than arraylength.
+ * @param length The number of bytes to be read from the given array;
+ * must be non-negative and no larger than arraylength - offset.
+ *
+ * @exception IndexOutOfBoundsException If the preconditions on the offset
+ * and length parameters do not hold
+ */
+ static final void checkArraySize(int arraylength, int offset, int length)
+ {
+ if ((offset < 0) ||
+ (length < 0) ||
+ (arraylength < length + offset))
+ throw new IndexOutOfBoundsException ();
+ }
+}
diff --git a/gcc-4.2.1/libjava/java/nio/DirectByteBufferImpl.java b/gcc-4.2.1/libjava/java/nio/DirectByteBufferImpl.java
new file mode 100644
index 000000000..e448ea97c
--- /dev/null
+++ b/gcc-4.2.1/libjava/java/nio/DirectByteBufferImpl.java
@@ -0,0 +1,431 @@
+/* DirectByteBufferImpl.java --
+ Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+import gnu.gcj.RawData;
+
+abstract class DirectByteBufferImpl extends ByteBuffer
+{
+ /**
+ * The owner is used to keep alive the object that actually owns the
+ * memory. There are three possibilities:
+ * 1) owner == this: We allocated the memory and we should free it,
+ * but *only* in finalize (if we've been sliced
+ * other objects will also have access to the
+ * memory).
+ * 2) owner == null: The byte buffer was created thru
+ * JNI.NewDirectByteBuffer. The JNI code is
+ * responsible for freeing the memory.
+ * 3) owner == some other object: The other object allocated the
+ * memory and should free it.
+ */
+ private final Object owner;
+
+ static final class ReadOnly extends DirectByteBufferImpl
+ {
+ ReadOnly(Object owner, RawData address,
+ int capacity, int limit,
+ int position)
+ {
+ super(owner, address, capacity, limit, position);
+ }
+
+ public ByteBuffer put(byte value)
+ {
+ throw new ReadOnlyBufferException ();
+ }
+
+ public ByteBuffer put(int index, byte value)
+ {
+ throw new ReadOnlyBufferException ();
+ }
+
+ public boolean isReadOnly()
+ {
+ return true;
+ }
+ }
+
+ static final class ReadWrite extends DirectByteBufferImpl
+ {
+ ReadWrite(int capacity)
+ {
+ super(capacity);
+ }
+
+ ReadWrite(RawData address, int capacity)
+ {
+ super(address, capacity);
+ }
+
+ ReadWrite(Object owner, RawData address,
+ int capacity, int limit,
+ int position)
+ {
+ super(owner, address, capacity, limit, position);
+ }
+
+ public boolean isReadOnly()
+ {
+ return false;
+ }
+ }
+
+ DirectByteBufferImpl(int capacity)
+ {
+ super(capacity, capacity, 0, -1);
+ this.owner = this;
+ this.address = VMDirectByteBuffer.allocate(capacity);
+ }
+
+ DirectByteBufferImpl(RawData address, int capacity)
+ {
+ super(capacity, capacity, 0, -1);
+ this.owner = null;
+ this.address = address;
+ }
+
+ DirectByteBufferImpl(Object owner, RawData address,
+ int capacity, int limit,
+ int position)
+ {
+ super(capacity, limit, position, -1);
+ this.owner = owner;
+ this.address = address;
+ }
+
+ /**
+ * Allocates a new direct byte buffer.
+ */
+ public static ByteBuffer allocate(int capacity)
+ {
+ return new DirectByteBufferImpl.ReadWrite(capacity);
+ }
+
+ protected void finalize() throws Throwable
+ {
+ if (owner == this)
+ VMDirectByteBuffer.free(address);
+ }
+
+ public byte get()
+ {
+ checkForUnderflow();
+
+ int pos = position();
+ byte result = VMDirectByteBuffer.get(address, pos);
+ position(pos + 1);
+ return result;
+ }
+
+ public byte get(int index)
+ {
+ checkIndex(index);
+
+ return VMDirectByteBuffer.get(address, index);
+ }
+
+ public ByteBuffer get(byte[] dst, int offset, int length)
+ {
+ checkArraySize(dst.length, offset, length);
+ checkForUnderflow(length);
+
+ int index = position();
+ VMDirectByteBuffer.get(address, index, dst, offset, length);
+ position(index+length);
+
+ return this;
+ }
+
+ public ByteBuffer put(byte value)
+ {
+ checkForOverflow();
+
+ int pos = position();
+ VMDirectByteBuffer.put(address, pos, value);
+ position(pos + 1);
+ return this;
+ }
+
+ public ByteBuffer put(int index, byte value)
+ {
+ checkIndex(index);
+
+ VMDirectByteBuffer.put(address, index, value);
+ return this;
+ }
+
+ void shiftDown(int dst_offset, int src_offset, int count)
+ {
+ VMDirectByteBuffer.shiftDown(address, dst_offset, src_offset, count);
+ }
+
+ public ByteBuffer compact()
+ {
+ checkIfReadOnly();
+ mark = -1;
+ int pos = position();
+ if (pos > 0)
+ {
+ int count = remaining();
+ VMDirectByteBuffer.shiftDown(address, 0, pos, count);
+ position(count);
+ limit(capacity());
+ }
+ else
+ {
+ position(limit());
+ limit(capacity());
+ }
+ return this;
+ }
+
+ public ByteBuffer slice()
+ {
+ int rem = remaining();
+ if (isReadOnly())
+ return new DirectByteBufferImpl.ReadOnly
+ (owner, VMDirectByteBuffer.adjustAddress(address, position()),
+ rem, rem, 0);
+ else
+ return new DirectByteBufferImpl.ReadWrite
+ (owner, VMDirectByteBuffer.adjustAddress(address, position()),
+ rem, rem, 0);
+ }
+
+ private ByteBuffer duplicate(boolean readOnly)
+ {
+ int pos = position();
+ reset();
+ int mark = position();
+ position(pos);
+ DirectByteBufferImpl result;
+ if (readOnly)
+ result = new DirectByteBufferImpl.ReadOnly(owner, address, capacity(),
+ limit(), pos);
+ else
+ result = new DirectByteBufferImpl.ReadWrite(owner, address, capacity(),
+ limit(), pos);
+
+ if (mark != pos)
+ {
+ result.position(mark);
+ result.mark();
+ result.position(pos);
+ }
+ return result;
+ }
+
+ public ByteBuffer duplicate()
+ {
+ return duplicate(isReadOnly());
+ }
+
+ public ByteBuffer asReadOnlyBuffer()
+ {
+ return duplicate(true);
+ }
+
+ public boolean isDirect()
+ {
+ return true;
+ }
+
+ public CharBuffer asCharBuffer()
+ {
+ return new CharViewBufferImpl(this, remaining() >> 1);
+ }
+
+ public ShortBuffer asShortBuffer()
+ {
+ return new ShortViewBufferImpl(this, remaining() >> 1);
+ }
+
+ public IntBuffer asIntBuffer()
+ {
+ return new IntViewBufferImpl(this, remaining() >> 2);
+ }
+
+ public LongBuffer asLongBuffer()
+ {
+ return new LongViewBufferImpl(this, remaining() >> 3);
+ }
+
+ public FloatBuffer asFloatBuffer()
+ {
+ return new FloatViewBufferImpl(this, remaining() >> 2);
+ }
+
+ public DoubleBuffer asDoubleBuffer()
+ {
+ return new DoubleViewBufferImpl(this, remaining() >> 3);
+ }
+
+ public char getChar()
+ {
+ return ByteBufferHelper.getChar(this, order());
+ }
+
+ public ByteBuffer putChar(char value)
+ {
+ ByteBufferHelper.putChar(this, value, order());
+ return this;
+ }
+
+ public char getChar(int index)
+ {
+ return ByteBufferHelper.getChar(this, index, order());
+ }
+
+ public ByteBuffer putChar(int index, char value)
+ {
+ ByteBufferHelper.putChar(this, index, value, order());
+ return this;
+ }
+
+ public short getShort()
+ {
+ return ByteBufferHelper.getShort(this, order());
+ }
+
+ public ByteBuffer putShort(short value)
+ {
+ ByteBufferHelper.putShort(this, value, order());
+ return this;
+ }
+
+ public short getShort(int index)
+ {
+ return ByteBufferHelper.getShort(this, index, order());
+ }
+
+ public ByteBuffer putShort(int index, short value)
+ {
+ ByteBufferHelper.putShort(this, index, value, order());
+ return this;
+ }
+
+ public int getInt()
+ {
+ return ByteBufferHelper.getInt(this, order());
+ }
+
+ public ByteBuffer putInt(int value)
+ {
+ ByteBufferHelper.putInt(this, value, order());
+ return this;
+ }
+
+ public int getInt(int index)
+ {
+ return ByteBufferHelper.getInt(this, index, order());
+ }
+
+ public ByteBuffer putInt(int index, int value)
+ {
+ ByteBufferHelper.putInt(this, index, value, order());
+ return this;
+ }
+
+ public long getLong()
+ {
+ return ByteBufferHelper.getLong(this, order());
+ }
+
+ public ByteBuffer putLong(long value)
+ {
+ ByteBufferHelper.putLong(this, value, order());
+ return this;
+ }
+
+ public long getLong(int index)
+ {
+ return ByteBufferHelper.getLong(this, index, order());
+ }
+
+ public ByteBuffer putLong(int index, long value)
+ {
+ ByteBufferHelper.putLong(this, index, value, order());
+ return this;
+ }
+
+ public float getFloat()
+ {
+ return ByteBufferHelper.getFloat(this, order());
+ }
+
+ public ByteBuffer putFloat(float value)
+ {
+ ByteBufferHelper.putFloat(this, value, order());
+ return this;
+ }
+
+ public float getFloat(int index)
+ {
+ return ByteBufferHelper.getFloat(this, index, order());
+ }
+
+ public ByteBuffer putFloat(int index, float value)
+ {
+ ByteBufferHelper.putFloat(this, index, value, order());
+ return this;
+ }
+
+ public double getDouble()
+ {
+ return ByteBufferHelper.getDouble(this, order());
+ }
+
+ public ByteBuffer putDouble(double value)
+ {
+ ByteBufferHelper.putDouble(this, value, order());
+ return this;
+ }
+
+ public double getDouble(int index)
+ {
+ return ByteBufferHelper.getDouble(this, index, order());
+ }
+
+ public ByteBuffer putDouble(int index, double value)
+ {
+ ByteBufferHelper.putDouble(this, index, value, order());
+ return this;
+ }
+}
diff --git a/gcc-4.2.1/libjava/java/nio/MappedByteBuffer.java b/gcc-4.2.1/libjava/java/nio/MappedByteBuffer.java
new file mode 100644
index 000000000..9b6df1715
--- /dev/null
+++ b/gcc-4.2.1/libjava/java/nio/MappedByteBuffer.java
@@ -0,0 +1,89 @@
+/* MappedByteBuffer.java --
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+/**
+ * @author Michael Koch (konqueror@gmx.de)
+ * @since 1.4
+ */
+public abstract class MappedByteBuffer extends ByteBuffer
+{
+ MappedByteBuffer (int capacity, int limit, int position, int mark)
+ {
+ super (capacity, limit, position, mark);
+ }
+
+ void forceImpl()
+ {
+ }
+
+ public final MappedByteBuffer force ()
+ {
+ forceImpl();
+ return this;
+ }
+
+ boolean isLoadedImpl()
+ {
+ load();
+ return true;
+ }
+
+ public final boolean isLoaded ()
+ {
+ return isLoadedImpl();
+ }
+
+ void loadImpl()
+ {
+ }
+
+ public final MappedByteBuffer load ()
+ {
+ loadImpl();
+ return this;
+ }
+
+ void unmapImpl ()
+ {
+ forceImpl();
+ }
+
+ public void finalize () { unmapImpl(); }
+}
diff --git a/gcc-4.2.1/libjava/java/nio/MappedByteBufferImpl.java b/gcc-4.2.1/libjava/java/nio/MappedByteBufferImpl.java
new file mode 100644
index 000000000..444eeea91
--- /dev/null
+++ b/gcc-4.2.1/libjava/java/nio/MappedByteBufferImpl.java
@@ -0,0 +1,360 @@
+/* MappedByteBufferImpl.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+import gnu.gcj.RawData;
+
+import java.io.IOException;
+
+final class MappedByteBufferImpl extends MappedByteBuffer
+{
+ boolean readOnly;
+
+ /** Posix uses this for the pointer returned by mmap;
+ * Win32 uses it for the pointer returned by MapViewOfFile. */
+ public RawData implPtr;
+ /** Posix uses this for the actual length passed to mmap;
+ * Win32 uses it for the pointer returned by CreateFileMapping. */
+ public long implLen;
+
+ public MappedByteBufferImpl(RawData address, int size, boolean readOnly)
+ throws IOException
+ {
+ super(size, size, 0, -1);
+ this.address = address;
+ this.readOnly = readOnly;
+ }
+
+ public boolean isReadOnly()
+ {
+ return readOnly;
+ }
+
+ public byte get()
+ {
+ checkForUnderflow();
+
+ int pos = position();
+ byte result = VMDirectByteBuffer.get(address, pos);
+ position(pos + 1);
+ return result;
+ }
+
+ public ByteBuffer put(byte value)
+ {
+ checkIfReadOnly();
+ checkForOverflow();
+
+ int pos = position();
+ VMDirectByteBuffer.put(address, pos, value);
+ position(pos + 1);
+ return this;
+ }
+
+ public byte get(int index)
+ {
+ checkIndex(index);
+
+ return VMDirectByteBuffer.get(address, index);
+ }
+
+ public ByteBuffer get(byte[] dst, int offset, int length)
+ {
+ checkArraySize(dst.length, offset, length);
+ checkForUnderflow(length);
+
+ int index = position();
+ VMDirectByteBuffer.get(address, index, dst, offset, length);
+ position(index+length);
+
+ return this;
+ }
+
+ public ByteBuffer put(int index, byte value)
+ {
+ checkIfReadOnly();
+ checkIndex(index);
+
+ VMDirectByteBuffer.put(address, index, value);
+ return this;
+ }
+
+ public ByteBuffer compact()
+ {
+ checkIfReadOnly();
+ mark = -1;
+ int pos = position();
+ if (pos > 0)
+ {
+ int count = remaining();
+ // Call shiftDown method optimized for direct buffers.
+ VMDirectByteBuffer.shiftDown(address, 0, pos, count);
+ position(count);
+ limit(capacity());
+ }
+ else
+ {
+ position(limit());
+ limit(capacity());
+ }
+ return this;
+ }
+
+ public boolean isDirect()
+ {
+ return true;
+ }
+
+ public ByteBuffer slice()
+ {
+ int rem = remaining();
+ if (isReadOnly())
+ return new DirectByteBufferImpl.ReadOnly
+ (this, VMDirectByteBuffer.adjustAddress(address, position()),
+ rem, rem, 0);
+ else
+ return new DirectByteBufferImpl.ReadWrite
+ (this, VMDirectByteBuffer.adjustAddress(address, position()),
+ rem, rem, 0);
+ }
+
+ private ByteBuffer duplicate(boolean readOnly)
+ {
+ int pos = position();
+ reset();
+ int mark = position();
+ position(pos);
+ DirectByteBufferImpl result;
+ if (readOnly)
+ result = new DirectByteBufferImpl.ReadOnly(this, address, capacity(),
+ limit(), pos);
+ else
+ result = new DirectByteBufferImpl.ReadWrite(this, address, capacity(),
+ limit(), pos);
+
+ if (mark != pos)
+ {
+ result.position(mark);
+ result.mark();
+ result.position(pos);
+ }
+ return result;
+ }
+
+ public ByteBuffer duplicate()
+ {
+ return duplicate(isReadOnly());
+ }
+
+ public ByteBuffer asReadOnlyBuffer()
+ {
+ return duplicate(true);
+ }
+
+ public CharBuffer asCharBuffer()
+ {
+ return new CharViewBufferImpl(this, remaining() >> 1);
+ }
+
+ public ShortBuffer asShortBuffer()
+ {
+ return new ShortViewBufferImpl(this, remaining() >> 1);
+ }
+
+ public IntBuffer asIntBuffer()
+ {
+ return new IntViewBufferImpl(this, remaining() >> 2);
+ }
+
+ public LongBuffer asLongBuffer()
+ {
+ return new LongViewBufferImpl(this, remaining() >> 3);
+ }
+
+ public FloatBuffer asFloatBuffer()
+ {
+ return new FloatViewBufferImpl(this, remaining() >> 2);
+ }
+
+ public DoubleBuffer asDoubleBuffer()
+ {
+ return new DoubleViewBufferImpl(this, remaining() >> 3);
+ }
+
+ public char getChar()
+ {
+ return ByteBufferHelper.getChar(this, order());
+ }
+
+ public ByteBuffer putChar(char value)
+ {
+ ByteBufferHelper.putChar(this, value, order());
+ return this;
+ }
+
+ public char getChar(int index)
+ {
+ return ByteBufferHelper.getChar(this, index, order());
+ }
+
+ public ByteBuffer putChar(int index, char value)
+ {
+ ByteBufferHelper.putChar(this, index, value, order());
+ return this;
+ }
+
+ public short getShort()
+ {
+ return ByteBufferHelper.getShort(this, order());
+ }
+
+ public ByteBuffer putShort(short value)
+ {
+ ByteBufferHelper.putShort(this, value, order());
+ return this;
+ }
+
+ public short getShort(int index)
+ {
+ return ByteBufferHelper.getShort(this, index, order());
+ }
+
+ public ByteBuffer putShort(int index, short value)
+ {
+ ByteBufferHelper.putShort(this, index, value, order());
+ return this;
+ }
+
+ public int getInt()
+ {
+ return ByteBufferHelper.getInt(this, order());
+ }
+
+ public ByteBuffer putInt(int value)
+ {
+ ByteBufferHelper.putInt(this, value, order());
+ return this;
+ }
+
+ public int getInt(int index)
+ {
+ return ByteBufferHelper.getInt(this, index, order());
+ }
+
+ public ByteBuffer putInt(int index, int value)
+ {
+ ByteBufferHelper.putInt(this, index, value, order());
+ return this;
+ }
+
+ public long getLong()
+ {
+ return ByteBufferHelper.getLong(this, order());
+ }
+
+ public ByteBuffer putLong(long value)
+ {
+ ByteBufferHelper.putLong(this, value, order());
+ return this;
+ }
+
+ public long getLong(int index)
+ {
+ return ByteBufferHelper.getLong(this, index, order());
+ }
+
+ public ByteBuffer putLong(int index, long value)
+ {
+ ByteBufferHelper.putLong(this, index, value, order());
+ return this;
+ }
+
+ public float getFloat()
+ {
+ return ByteBufferHelper.getFloat(this, order());
+ }
+
+ public ByteBuffer putFloat(float value)
+ {
+ ByteBufferHelper.putFloat(this, value, order());
+ return this;
+ }
+
+ public float getFloat(int index)
+ {
+ return ByteBufferHelper.getFloat(this, index, order());
+ }
+
+ public ByteBuffer putFloat(int index, float value)
+ {
+ ByteBufferHelper.putFloat(this, index, value, order());
+ return this;
+ }
+
+ public double getDouble()
+ {
+ return ByteBufferHelper.getDouble(this, order());
+ }
+
+ public ByteBuffer putDouble(double value)
+ {
+ ByteBufferHelper.putDouble(this, value, order());
+ return this;
+ }
+
+ public double getDouble(int index)
+ {
+ return ByteBufferHelper.getDouble(this, index, order());
+ }
+
+ public ByteBuffer putDouble(int index, double value)
+ {
+ ByteBufferHelper.putDouble(this, index, value, order());
+ return this;
+ }
+
+ // NOTE: In libgcj these methods are implemented in natFileChannelXxx.cc,
+ // because they're small, and to put them next to FileChannelImpl::mapImpl.
+ native void unmapImpl();
+ native boolean isLoadedImpl();
+ // FIXME: Try to load all pages into memory.
+ native void loadImpl();
+
+ native void forceImpl();
+}
diff --git a/gcc-4.2.1/libjava/java/nio/VMDirectByteBuffer.java b/gcc-4.2.1/libjava/java/nio/VMDirectByteBuffer.java
new file mode 100644
index 000000000..2aefaeb4b
--- /dev/null
+++ b/gcc-4.2.1/libjava/java/nio/VMDirectByteBuffer.java
@@ -0,0 +1,53 @@
+/* VMDirectByteBuffer.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio;
+
+import gnu.classpath.Configuration;
+import gnu.gcj.RawData;
+
+final class VMDirectByteBuffer
+{
+ static native RawData allocate (int capacity);
+ static native void free(RawData address);
+ static native byte get(RawData address, int index);
+ static native void get(RawData address, int index, byte[] dst, int offset, int length);
+ static native void put(RawData address, int index, byte value);
+ static native RawData adjustAddress(RawData address, int offset);
+ static native void shiftDown(RawData address, int dst_offset, int src_offset, int count);
+}
diff --git a/gcc-4.2.1/libjava/java/nio/channels/VMChannels.java b/gcc-4.2.1/libjava/java/nio/channels/VMChannels.java
new file mode 100644
index 000000000..4f43a42ad
--- /dev/null
+++ b/gcc-4.2.1/libjava/java/nio/channels/VMChannels.java
@@ -0,0 +1,85 @@
+/* VMChannels.java --
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio.channels;
+
+import gnu.java.nio.ChannelInputStream;
+import gnu.java.nio.ChannelOutputStream;
+import gnu.java.nio.channels.FileChannelImpl;
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+final class VMChannels
+{
+ /**
+ * This class isn't intended to be instantiated.
+ */
+ private VMChannels()
+ {
+ // Do nothing here.
+ }
+
+ static native FileInputStream newInputStream(FileChannelImpl ch);
+
+ static native FileOutputStream newOutputStream(FileChannelImpl ch);
+
+ /**
+ * Constructs a stream that reads bytes from the given channel.
+ */
+ static InputStream newInputStream(ReadableByteChannel ch)
+ {
+ if (ch instanceof FileChannelImpl)
+ return newInputStream((FileChannelImpl) ch);
+ return new ChannelInputStream(ch);
+ }
+
+ /**
+ * Constructs a stream that writes bytes to the given channel.
+ */
+ static OutputStream newOutputStream(WritableByteChannel ch)
+ {
+ if (ch instanceof FileChannelImpl)
+ return newOutputStream((FileChannelImpl) ch);
+ return new ChannelOutputStream(ch);
+ }
+}
diff --git a/gcc-4.2.1/libjava/java/nio/channels/natVMChannels.cc b/gcc-4.2.1/libjava/java/nio/channels/natVMChannels.cc
new file mode 100644
index 000000000..d40a51653
--- /dev/null
+++ b/gcc-4.2.1/libjava/java/nio/channels/natVMChannels.cc
@@ -0,0 +1,37 @@
+// natVMChannels.cc - Native part of VMChannels class.
+
+/* Copyright (C) 2004, 2006 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+#include <config.h>
+#include <gcj/cni.h>
+
+#include <java/nio/channels/VMChannels.h>
+#include <java/nio/channels/Channels.h>
+#include <java/io/FileInputStream.h>
+#include <java/io/FileOutputStream.h>
+#include <gnu/java/nio/channels/FileChannelImpl.h>
+
+using java::nio::channels::VMChannels;
+using java::io::FileInputStream;
+using java::io::FileOutputStream;
+using gnu::java::nio::channels::FileChannelImpl;
+
+FileInputStream*
+VMChannels::newInputStream(FileChannelImpl* ch)
+{
+ // Needs to be native to bypass Java access protection.
+ return new FileInputStream (ch);
+}
+
+FileOutputStream*
+VMChannels::newOutputStream(FileChannelImpl* ch)
+{
+ // Needs to be native to bypass Java access protection.
+ return new FileOutputStream (ch);
+}
diff --git a/gcc-4.2.1/libjava/java/nio/charset/Charset.java b/gcc-4.2.1/libjava/java/nio/charset/Charset.java
new file mode 100644
index 000000000..48093bc9d
--- /dev/null
+++ b/gcc-4.2.1/libjava/java/nio/charset/Charset.java
@@ -0,0 +1,412 @@
+/* Charset.java --
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio.charset;
+
+import gnu.classpath.ServiceFactory;
+import gnu.classpath.SystemProperties;
+import gnu.java.nio.charset.Provider;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.spi.CharsetProvider;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Locale;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+/**
+ * @author Jesse Rosenstock
+ * @since 1.4
+ */
+public abstract class Charset implements Comparable
+{
+ private CharsetEncoder cachedEncoder;
+ private CharsetDecoder cachedDecoder;
+
+ /**
+ * Charset providers.
+ */
+ private static CharsetProvider[] providers;
+
+ private final String canonicalName;
+ private final String[] aliases;
+
+ protected Charset (String canonicalName, String[] aliases)
+ {
+ checkName (canonicalName);
+ if (aliases != null)
+ {
+ int n = aliases.length;
+ for (int i = 0; i < n; ++i)
+ checkName (aliases[i]);
+ }
+
+ cachedEncoder = null;
+ cachedDecoder = null;
+ this.canonicalName = canonicalName;
+ this.aliases = aliases;
+ }
+
+ /**
+ * @throws IllegalCharsetNameException if the name is illegal
+ */
+ private static void checkName (String name)
+ {
+ int n = name.length ();
+
+ if (n == 0)
+ throw new IllegalCharsetNameException (name);
+
+ char ch = name.charAt (0);
+ if (!(('A' <= ch && ch <= 'Z')
+ || ('a' <= ch && ch <= 'z')
+ || ('0' <= ch && ch <= '9')))
+ throw new IllegalCharsetNameException (name);
+
+ for (int i = 1; i < n; ++i)
+ {
+ ch = name.charAt (i);
+ if (!(('A' <= ch && ch <= 'Z')
+ || ('a' <= ch && ch <= 'z')
+ || ('0' <= ch && ch <= '9')
+ || ch == '-' || ch == '.' || ch == ':' || ch == '_'))
+ throw new IllegalCharsetNameException (name);
+ }
+ }
+
+ /**
+ * Returns the system default charset.
+ *
+ * This may be set by the user or VM with the file.encoding
+ * property.
+ *
+ * @since 1.5
+ */
+ public static Charset defaultCharset()
+ {
+ String encoding;
+
+ try
+ {
+ encoding = SystemProperties.getProperty("file.encoding");
+ }
+ catch(SecurityException e)
+ {
+ // Use fallback.
+ encoding = "ISO-8859-1";
+ }
+ catch(IllegalArgumentException e)
+ {
+ // Use fallback.
+ encoding = "ISO-8859-1";
+ }
+
+ try
+ {
+ return forName(encoding);
+ }
+ catch(UnsupportedCharsetException e)
+ {
+ // Ignore.
+ }
+ catch(IllegalCharsetNameException e)
+ {
+ // Ignore.
+ }
+ catch(IllegalArgumentException e)
+ {
+ // Ignore.
+ }
+
+ throw new IllegalStateException("Can't get default charset!");
+ }
+
+ public static boolean isSupported (String charsetName)
+ {
+ return charsetForName (charsetName) != null;
+ }
+
+ /**
+ * Returns the Charset instance for the charset of the given name.
+ *
+ * @param charsetName
+ * @return
+ * @throws UnsupportedCharsetException if this VM does not support
+ * the charset of the given name.
+ * @throws IllegalCharsetNameException if the given charset name is
+ * legal.
+ * @throws IllegalArgumentException if <code>charsetName</code> is null.
+ */
+ public static Charset forName (String charsetName)
+ {
+ // Throws IllegalArgumentException as the JDK does.
+ if(charsetName == null)
+ throw new IllegalArgumentException("Charset name must not be null.");
+
+ Charset cs = charsetForName (charsetName);
+ if (cs == null)
+ throw new UnsupportedCharsetException (charsetName);
+ return cs;
+ }
+
+ /**
+ * Retrieves a charset for the given charset name.
+ *
+ * @return A charset object for the charset with the specified name, or
+ * <code>null</code> if no such charset exists.
+ *
+ * @throws IllegalCharsetNameException if the name is illegal
+ */
+ private static Charset charsetForName(String charsetName)
+ {
+ checkName (charsetName);
+ // Try the default provider first
+ // (so we don't need to load external providers unless really necessary)
+ // if it is an exotic charset try loading the external providers.
+ Charset cs = provider().charsetForName(charsetName);
+ if (cs == null)
+ {
+ CharsetProvider[] providers = providers2();
+ for (int i = 0; i < providers.length; i++)
+ {
+ cs = providers[i].charsetForName(charsetName);
+ if (cs != null)
+ break;
+ }
+ }
+ return cs;
+ }
+
+ public static SortedMap availableCharsets()
+ {
+ TreeMap charsets = new TreeMap(String.CASE_INSENSITIVE_ORDER);
+ for (Iterator i = provider().charsets(); i.hasNext(); )
+ {
+ Charset cs = (Charset) i.next();
+ charsets.put(cs.name(), cs);
+ }
+
+ CharsetProvider[] providers = providers2();
+ for (int j = 0; j < providers.length; j++)
+ {
+ for (Iterator i = providers[j].charsets(); i.hasNext(); )
+ {
+ Charset cs = (Charset) i.next();
+ charsets.put(cs.name(), cs);
+ }
+ }
+
+ return Collections.unmodifiableSortedMap(charsets);
+ }
+
+ private static CharsetProvider provider()
+ {
+ try
+ {
+ String s = System.getProperty("charset.provider");
+ if (s != null)
+ {
+ CharsetProvider p =
+ (CharsetProvider) ((Class.forName(s)).newInstance());
+ return p;
+ }
+ }
+ catch (Exception e)
+ {
+ // Ignore.
+ }
+
+ return Provider.provider();
+ }
+
+ /**
+ * We need to support multiple providers, reading them from
+ * java.nio.charset.spi.CharsetProvider in the resource directory
+ * META-INF/services. This returns the "extra" charset providers.
+ */
+ private static CharsetProvider[] providers2()
+ {
+ if (providers == null)
+ {
+ try
+ {
+ Iterator i = ServiceFactory.lookupProviders(CharsetProvider.class);
+ LinkedHashSet set = new LinkedHashSet();
+ while (i.hasNext())
+ set.add(i.next());
+
+ providers = new CharsetProvider[set.size()];
+ set.toArray(providers);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ return providers;
+ }
+
+ public final String name ()
+ {
+ return canonicalName;
+ }
+
+ public final Set aliases ()
+ {
+ if (aliases == null)
+ return Collections.EMPTY_SET;
+
+ // should we cache the aliasSet instead?
+ int n = aliases.length;
+ HashSet aliasSet = new HashSet (n);
+ for (int i = 0; i < n; ++i)
+ aliasSet.add (aliases[i]);
+ return Collections.unmodifiableSet (aliasSet);
+ }
+
+ public String displayName ()
+ {
+ return canonicalName;
+ }
+
+ public String displayName (Locale locale)
+ {
+ return canonicalName;
+ }
+
+ public final boolean isRegistered ()
+ {
+ return (!canonicalName.startsWith ("x-")
+ && !canonicalName.startsWith ("X-"));
+ }
+
+ public abstract boolean contains (Charset cs);
+
+ public abstract CharsetDecoder newDecoder ();
+
+ public abstract CharsetEncoder newEncoder ();
+
+ public boolean canEncode ()
+ {
+ return true;
+ }
+
+ // NB: This implementation serializes different threads calling
+ // Charset.encode(), a potential performance problem. It might
+ // be better to remove the cache, or use ThreadLocal to cache on
+ // a per-thread basis.
+ public final synchronized ByteBuffer encode (CharBuffer cb)
+ {
+ try
+ {
+ if (cachedEncoder == null)
+ {
+ cachedEncoder = newEncoder ()
+ .onMalformedInput (CodingErrorAction.REPLACE)
+ .onUnmappableCharacter (CodingErrorAction.REPLACE);
+ } else
+ cachedEncoder.reset();
+ return cachedEncoder.encode (cb);
+ }
+ catch (CharacterCodingException e)
+ {
+ throw new AssertionError (e);
+ }
+ }
+
+ public final ByteBuffer encode (String str)
+ {
+ return encode (CharBuffer.wrap (str));
+ }
+
+ // NB: This implementation serializes different threads calling
+ // Charset.decode(), a potential performance problem. It might
+ // be better to remove the cache, or use ThreadLocal to cache on
+ // a per-thread basis.
+ public final synchronized CharBuffer decode (ByteBuffer bb)
+ {
+ try
+ {
+ if (cachedDecoder == null)
+ {
+ cachedDecoder = newDecoder ()
+ .onMalformedInput (CodingErrorAction.REPLACE)
+ .onUnmappableCharacter (CodingErrorAction.REPLACE);
+ } else
+ cachedDecoder.reset();
+
+ return cachedDecoder.decode (bb);
+ }
+ catch (CharacterCodingException e)
+ {
+ throw new AssertionError (e);
+ }
+ }
+
+ public final int compareTo (Object ob)
+ {
+ return canonicalName.compareToIgnoreCase (((Charset) ob).canonicalName);
+ }
+
+ public final int hashCode ()
+ {
+ return canonicalName.hashCode ();
+ }
+
+ public final boolean equals (Object ob)
+ {
+ if (ob instanceof Charset)
+ return canonicalName.equalsIgnoreCase (((Charset) ob).canonicalName);
+ else
+ return false;
+ }
+
+ public final String toString ()
+ {
+ return canonicalName;
+ }
+}
diff --git a/gcc-4.2.1/libjava/java/nio/charset/spi/CharsetProvider.java b/gcc-4.2.1/libjava/java/nio/charset/spi/CharsetProvider.java
new file mode 100644
index 000000000..e15153fe9
--- /dev/null
+++ b/gcc-4.2.1/libjava/java/nio/charset/spi/CharsetProvider.java
@@ -0,0 +1,96 @@
+/* CharsetProvider.java -- charset service provider interface
+ Copyright (C) 2002, 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.charset.spi;
+
+import java.nio.charset.Charset;
+import java.util.Iterator;
+
+
+/**
+ * This class allows an implementor to provide additional character sets. The
+ * subclass must have a nullary constructor, and be attached to charset
+ * implementation classes. These extensions are loaded via the context class
+ * loader. To provide the charset extension, all files named
+ * <code>META-INF/services/java.nio.charset.spi.CharsetProvider</code> are
+ * read from the classpath. Each one should be a UTF-8 encoded list of
+ * fully-qualified names of concrete subclasses of this class; whitespace is
+ * ignored, and '#' starts comments. Duplicates are ignored. The
+ * implementations must be accessible to the classloader that requests them.
+ *
+ * @author Eric Blake (ebb9@email.byu.edu)
+ * @see Charset
+ * @since 1.4
+ * @status updated to 1.4
+ */
+public abstract class CharsetProvider
+{
+ /**
+ * Initialize a new charset provider. This performs a security check on
+ * RuntimePermission("charsetProvider").
+ *
+ * @throws SecurityException if building a new set is not allowed
+ */
+ protected CharsetProvider()
+ {
+ // We only do the security check for custom providers, not for the
+ // built in ones.
+ SecurityManager s = System.getSecurityManager();
+ if (s != null &&
+ ! (this instanceof gnu.java.nio.charset.Provider))
+ // GCJ LOCAL - We have the iconv provider in standard.omit
+ // || this instanceof gnu.java.nio.charset.iconv.IconvProvider))
+ s.checkPermission(new RuntimePermission("charsetProvider"));
+ }
+
+ /**
+ * Returns an iterator over the charsets defined by this provider.
+ *
+ * @return the iterator
+ * @see Charset#availableCharsets()
+ */
+ public abstract Iterator charsets();
+
+ /**
+ * Returns the named charset, by canonical name or alias.
+ *
+ * @param name the name of the character
+ *
+ * @return the charset, or null if not supported
+ */
+ public abstract Charset charsetForName(String name);
+} // class CharsetProvider
diff --git a/gcc-4.2.1/libjava/java/nio/natDirectByteBufferImpl.cc b/gcc-4.2.1/libjava/java/nio/natDirectByteBufferImpl.cc
new file mode 100644
index 000000000..3119fdea3
--- /dev/null
+++ b/gcc-4.2.1/libjava/java/nio/natDirectByteBufferImpl.cc
@@ -0,0 +1,72 @@
+// natDirectByteBufferImpl.cc
+
+/* Copyright (C) 2003, 2004 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+#include <config.h>
+
+#include <gcj/cni.h>
+#include <jvm.h>
+
+#include <stdlib.h>
+
+#include <gnu/gcj/RawData.h>
+#include <java/nio/VMDirectByteBuffer.h>
+
+using gnu::gcj::RawData;
+
+RawData*
+java::nio::VMDirectByteBuffer::allocate (jint capacity)
+{
+ return reinterpret_cast<gnu::gcj::RawData*> (::malloc (capacity));
+}
+
+void
+java::nio::VMDirectByteBuffer::free (gnu::gcj::RawData* address)
+{
+ ::free (reinterpret_cast<void*> (address));
+}
+
+jbyte
+java::nio::VMDirectByteBuffer::get (RawData* address, jint index)
+{
+ jbyte* pointer = reinterpret_cast<jbyte*> (address) + index;
+ return *pointer;
+}
+
+void
+java::nio::VMDirectByteBuffer::get (RawData* address, jint index,
+ jbyteArray dst, jint offset, jint length)
+{
+ jbyte* src = reinterpret_cast<jbyte*> (address) + index;
+ memcpy (elements (dst) + offset, src, length);
+}
+
+void
+java::nio::VMDirectByteBuffer::put (gnu::gcj::RawData* address,
+ jint index, jbyte value)
+{
+ jbyte* pointer = reinterpret_cast<jbyte*> (address) + index;
+ *pointer = value;
+}
+
+RawData*
+java::nio::VMDirectByteBuffer::adjustAddress (RawData* address, jint offset)
+{
+ jbyte* start = reinterpret_cast<jbyte*> (address) + offset;
+ return reinterpret_cast<RawData*>(start);
+}
+
+void
+java::nio::VMDirectByteBuffer::shiftDown (RawData* address, jint dst_offset,
+ jint src_offset, jint count)
+{
+ jbyte* dst = reinterpret_cast<jbyte*> (address) + dst_offset;
+ jbyte* src = reinterpret_cast<jbyte*> (address) + src_offset;
+ ::memmove(dst, src, count);
+}