aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/java/nio
diff options
context:
space:
mode:
authorTom Tromey <tromey@gcc.gnu.org>2005-09-23 21:31:04 +0000
committerTom Tromey <tromey@gcc.gnu.org>2005-09-23 21:31:04 +0000
commit1ea63ef8be1cc54dd0de9d82c684713a1dcf1e06 (patch)
tree3ca4b2e68dc14c3128b9c781d23f1d0b1f2bee49 /libjava/classpath/java/nio
parent9b044d19517541c95681d35a92dbc81e6e21d94f (diff)
downloadgcc-1ea63ef8be1cc54dd0de9d82c684713a1dcf1e06.zip
gcc-1ea63ef8be1cc54dd0de9d82c684713a1dcf1e06.tar.gz
gcc-1ea63ef8be1cc54dd0de9d82c684713a1dcf1e06.tar.bz2
Imported Classpath 0.18.
* sources.am, Makefile.in: Updated. * Makefile.am (nat_source_files): Removed natProxy.cc. * java/lang/reflect/natProxy.cc: Removed. * gnu/classpath/jdwp/VMFrame.java, gnu/classpath/jdwp/VMIdManager.java, gnu/classpath/jdwp/VMVirtualMachine.java, java/lang/reflect/VMProxy.java: New files. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * scripts/makemake.tcl (verbose): Add gnu/java/awt/peer/qt to BC list. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * gnu/java/net/DefaultContentHandlerFactory.java (getContent): Remove ClasspathToolkit references. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * gnu/awt/xlib/XCanvasPeer.java: Add new peer methods. * gnu/awt/xlib/XFramePeer.java: Likewise. * gnu/awt/xlib/XGraphicsConfiguration.java: Likewise. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * Makefile.am (libgcjawt_la_SOURCES): Remove jawt.c. Add classpath/native/jawt/jawt.c. * Makefile.in: Regenerate. * jawt.c: Remove file. * include/Makefile.am (tool_include__HEADERS): Remove jawt.h and jawt_md.h. Add ../classpath/include/jawt.h and ../classpath/include/jawt_md.h. * include/Makefile.in: Regenerate. * include/jawt.h: Regenerate. * include/jawt_md.h: Regenerate. From-SVN: r104586
Diffstat (limited to 'libjava/classpath/java/nio')
-rw-r--r--libjava/classpath/java/nio/Buffer.java4
-rw-r--r--libjava/classpath/java/nio/DirectByteBufferImpl.java94
-rw-r--r--libjava/classpath/java/nio/MappedByteBufferImpl.java6
-rw-r--r--libjava/classpath/java/nio/channels/FileLock.java8
-rw-r--r--libjava/classpath/java/nio/charset/Charset.java30
5 files changed, 82 insertions, 60 deletions
diff --git a/libjava/classpath/java/nio/Buffer.java b/libjava/classpath/java/nio/Buffer.java
index 47dabf2..2c7e00d 100644
--- a/libjava/classpath/java/nio/Buffer.java
+++ b/libjava/classpath/java/nio/Buffer.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package java.nio;
-import gnu.classpath.RawData;
+import gnu.classpath.Pointer;
/**
* @since 1.4
@@ -49,7 +49,7 @@ public abstract class Buffer
int limit = 0;
int pos = 0;
int mark = -1;
- RawData address;
+ Pointer address;
/**
* Creates a new Buffer.
diff --git a/libjava/classpath/java/nio/DirectByteBufferImpl.java b/libjava/classpath/java/nio/DirectByteBufferImpl.java
index 1667299..53bb668 100644
--- a/libjava/classpath/java/nio/DirectByteBufferImpl.java
+++ b/libjava/classpath/java/nio/DirectByteBufferImpl.java
@@ -1,4 +1,4 @@
-/* DirectByteBufferImpl.java --
+/* DirectByteBufferImpl.java --
Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,7 @@ exception statement from your version. */
package java.nio;
-import gnu.classpath.RawData;
+import gnu.classpath.Pointer;
abstract class DirectByteBufferImpl extends ByteBuffer
{
@@ -59,9 +59,9 @@ abstract class DirectByteBufferImpl extends ByteBuffer
static final class ReadOnly extends DirectByteBufferImpl
{
- ReadOnly(Object owner, RawData address,
- int capacity, int limit,
- int position)
+ ReadOnly(Object owner, Pointer address,
+ int capacity, int limit,
+ int position)
{
super(owner, address, capacity, limit, position);
}
@@ -89,9 +89,9 @@ abstract class DirectByteBufferImpl extends ByteBuffer
super(capacity);
}
- ReadWrite(Object owner, RawData address,
- int capacity, int limit,
- int position)
+ ReadWrite(Object owner, Pointer address,
+ int capacity, int limit,
+ int position)
{
super(owner, address, capacity, limit, position);
}
@@ -109,9 +109,9 @@ abstract class DirectByteBufferImpl extends ByteBuffer
this.address = VMDirectByteBuffer.allocate(capacity);
}
- DirectByteBufferImpl(Object owner, RawData address,
- int capacity, int limit,
- int position)
+ DirectByteBufferImpl(Object owner, Pointer address,
+ int capacity, int limit,
+ int position)
{
super(capacity, limit, position, -1);
this.owner = owner;
@@ -120,7 +120,7 @@ abstract class DirectByteBufferImpl extends ByteBuffer
/**
* Allocates a new direct byte buffer.
- */
+ */
public static ByteBuffer allocate(int capacity)
{
return new DirectByteBufferImpl.ReadWrite(capacity);
@@ -131,7 +131,7 @@ abstract class DirectByteBufferImpl extends ByteBuffer
if (owner == this)
VMDirectByteBuffer.free(address);
}
-
+
public byte get()
{
checkForUnderflow();
@@ -170,7 +170,7 @@ abstract class DirectByteBufferImpl extends ByteBuffer
position(pos + 1);
return this;
}
-
+
public ByteBuffer put(int index, byte value)
{
checkIndex(index);
@@ -178,12 +178,24 @@ abstract class DirectByteBufferImpl extends ByteBuffer
VMDirectByteBuffer.put(address, index, value);
return this;
}
-
+
+ public ByteBuffer put (byte[] src, int offset, int length)
+ {
+ checkArraySize (src.length, offset, length);
+ checkForUnderflow (length);
+
+ int index = position ();
+ VMDirectByteBuffer.put (address, index, src, offset, length);
+ position (index + length);
+
+ return this;
+ }
+
void shiftDown(int dst_offset, int src_offset, int count)
{
VMDirectByteBuffer.shiftDown(address, dst_offset, src_offset, count);
}
-
+
public ByteBuffer compact()
{
checkIfReadOnly();
@@ -191,15 +203,15 @@ abstract class DirectByteBufferImpl extends ByteBuffer
int pos = position();
if (pos > 0)
{
- int count = remaining();
- VMDirectByteBuffer.shiftDown(address, 0, pos, count);
- position(count);
- limit(capacity());
+ int count = remaining();
+ VMDirectByteBuffer.shiftDown(address, 0, pos, count);
+ position(count);
+ limit(capacity());
}
else
{
- position(limit());
- limit(capacity());
+ position(limit());
+ limit(capacity());
}
return this;
}
@@ -233,9 +245,9 @@ abstract class DirectByteBufferImpl extends ByteBuffer
if (mark != pos)
{
- result.position(mark);
- result.mark();
- result.position(pos);
+ result.position(mark);
+ result.mark();
+ result.position(pos);
}
return result;
}
@@ -289,18 +301,18 @@ abstract class DirectByteBufferImpl extends ByteBuffer
{
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());
@@ -311,18 +323,18 @@ abstract class DirectByteBufferImpl extends ByteBuffer
{
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());
@@ -333,18 +345,18 @@ abstract class DirectByteBufferImpl extends ByteBuffer
{
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());
@@ -355,18 +367,18 @@ abstract class DirectByteBufferImpl extends ByteBuffer
{
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());
@@ -377,13 +389,13 @@ abstract class DirectByteBufferImpl extends ByteBuffer
{
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());
@@ -405,12 +417,12 @@ abstract class DirectByteBufferImpl extends ByteBuffer
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());
diff --git a/libjava/classpath/java/nio/MappedByteBufferImpl.java b/libjava/classpath/java/nio/MappedByteBufferImpl.java
index 1b075d8..a53040f 100644
--- a/libjava/classpath/java/nio/MappedByteBufferImpl.java
+++ b/libjava/classpath/java/nio/MappedByteBufferImpl.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package java.nio;
-import gnu.classpath.RawData;
+import gnu.classpath.Pointer;
import java.io.IOException;
@@ -48,12 +48,12 @@ final class MappedByteBufferImpl extends MappedByteBuffer
/** Posix uses this for the pointer returned by mmap;
* Win32 uses it for the pointer returned by MapViewOfFile. */
- public RawData implPtr;
+ public Pointer 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)
+ public MappedByteBufferImpl(Pointer address, int size, boolean readOnly)
throws IOException
{
super(size, size, 0, -1);
diff --git a/libjava/classpath/java/nio/channels/FileLock.java b/libjava/classpath/java/nio/channels/FileLock.java
index 151c23f..c466958 100644
--- a/libjava/classpath/java/nio/channels/FileLock.java
+++ b/libjava/classpath/java/nio/channels/FileLock.java
@@ -45,10 +45,10 @@ import java.io.IOException;
*/
public abstract class FileLock
{
- FileChannel channel;
- long position;
- long size;
- boolean shared;
+ private final FileChannel channel;
+ private final long position;
+ private final long size;
+ private final boolean shared;
/**
* Initializes the file lock.
diff --git a/libjava/classpath/java/nio/charset/Charset.java b/libjava/classpath/java/nio/charset/Charset.java
index 6de2917..0476b0d 100644
--- a/libjava/classpath/java/nio/charset/Charset.java
+++ b/libjava/classpath/java/nio/charset/Charset.java
@@ -68,9 +68,9 @@ public abstract class Charset implements Comparable
{
private CharsetEncoder cachedEncoder;
private CharsetDecoder cachedDecoder;
-
+
/**
- * Charset providers.
+ * Extra Charset providers.
*/
private static CharsetProvider[] providers;
@@ -204,13 +204,19 @@ public abstract class Charset implements Comparable
private static Charset charsetForName(String charsetName)
{
checkName (charsetName);
- Charset cs = null;
- CharsetProvider[] providers = providers2();
- for (int i = 0; i < providers.length; i++)
+ // 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)
{
- cs = providers[i].charsetForName(charsetName);
- if (cs != null)
- break;
+ CharsetProvider[] providers = providers2();
+ for (int i = 0; i < providers.length; i++)
+ {
+ cs = providers[i].charsetForName(charsetName);
+ if (cs != null)
+ break;
+ }
}
return cs;
}
@@ -218,6 +224,11 @@ public abstract class Charset implements Comparable
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++)
@@ -246,7 +257,7 @@ public abstract class Charset implements Comparable
/**
* We need to support multiple providers, reading them from
* java.nio.charset.spi.CharsetProvider in the resource directory
- * META-INF/services.
+ * META-INF/services. This returns the "extra" charset providers.
*/
private static CharsetProvider[] providers2()
{
@@ -257,7 +268,6 @@ public abstract class Charset implements Comparable
Enumeration en = ClassLoader.getSystemResources
("META-INF/services/java.nio.charset.spi.CharsetProvider");
LinkedHashSet set = new LinkedHashSet();
- set.add(provider());
while (en.hasMoreElements())
{
BufferedReader rdr = new BufferedReader(new InputStreamReader