diff options
author | Tom Tromey <tromey@gcc.gnu.org> | 2007-01-09 19:58:05 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2007-01-09 19:58:05 +0000 |
commit | 97b8365cafc3a344a22d3980b8ed885f5c6d8357 (patch) | |
tree | 996a5f57d4a68c53473382e45cb22f574cb3e4db /libjava/classpath/java/nio | |
parent | c648dedbde727ca3f883bb5fd773aa4af70d3369 (diff) | |
download | gcc-97b8365cafc3a344a22d3980b8ed885f5c6d8357.zip gcc-97b8365cafc3a344a22d3980b8ed885f5c6d8357.tar.gz gcc-97b8365cafc3a344a22d3980b8ed885f5c6d8357.tar.bz2 |
Merged gcj-eclipse branch to trunk.
From-SVN: r120621
Diffstat (limited to 'libjava/classpath/java/nio')
-rw-r--r-- | libjava/classpath/java/nio/ByteBuffer.java | 10 | ||||
-rw-r--r-- | libjava/classpath/java/nio/CharBuffer.java | 45 | ||||
-rw-r--r-- | libjava/classpath/java/nio/DirectByteBufferImpl.java | 2 | ||||
-rw-r--r-- | libjava/classpath/java/nio/DoubleBuffer.java | 10 | ||||
-rw-r--r-- | libjava/classpath/java/nio/FloatBuffer.java | 10 | ||||
-rw-r--r-- | libjava/classpath/java/nio/IntBuffer.java | 10 | ||||
-rw-r--r-- | libjava/classpath/java/nio/LongBuffer.java | 10 | ||||
-rw-r--r-- | libjava/classpath/java/nio/ShortBuffer.java | 10 | ||||
-rw-r--r-- | libjava/classpath/java/nio/channels/Channel.java | 5 | ||||
-rw-r--r-- | libjava/classpath/java/nio/channels/Selector.java | 4 | ||||
-rw-r--r-- | libjava/classpath/java/nio/channels/spi/AbstractSelectableChannel.java | 15 | ||||
-rw-r--r-- | libjava/classpath/java/nio/channels/spi/AbstractSelector.java | 8 | ||||
-rw-r--r-- | libjava/classpath/java/nio/charset/Charset.java | 23 | ||||
-rw-r--r-- | libjava/classpath/java/nio/charset/spi/CharsetProvider.java | 4 | ||||
-rw-r--r-- | libjava/classpath/java/nio/class-dependencies.conf | 58 |
15 files changed, 157 insertions, 67 deletions
diff --git a/libjava/classpath/java/nio/ByteBuffer.java b/libjava/classpath/java/nio/ByteBuffer.java index 0ccf766..78ad447 100644 --- a/libjava/classpath/java/nio/ByteBuffer.java +++ b/libjava/classpath/java/nio/ByteBuffer.java @@ -1,5 +1,5 @@ /* ByteBuffer.java -- - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -42,7 +42,7 @@ package java.nio; * @since 1.4 */ public abstract class ByteBuffer extends Buffer - implements Comparable + implements Comparable<ByteBuffer> { ByteOrder endian = ByteOrder.BIG_ENDIAN; @@ -290,7 +290,7 @@ public abstract class ByteBuffer extends Buffer { if (obj instanceof ByteBuffer) { - return compareTo (obj) == 0; + return compareTo ((ByteBuffer) obj) == 0; } return false; @@ -302,10 +302,8 @@ public abstract class ByteBuffer extends Buffer * @exception ClassCastException If obj is not an object derived from * <code>ByteBuffer</code>. */ - public int compareTo (Object obj) + public int compareTo (ByteBuffer other) { - ByteBuffer other = (ByteBuffer) obj; - int num = Math.min(remaining(), other.remaining()); int pos_this = position(); int pos_other = other.position(); diff --git a/libjava/classpath/java/nio/CharBuffer.java b/libjava/classpath/java/nio/CharBuffer.java index 356a920..34f429f 100644 --- a/libjava/classpath/java/nio/CharBuffer.java +++ b/libjava/classpath/java/nio/CharBuffer.java @@ -1,5 +1,5 @@ /* CharBuffer.java -- - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,11 +38,13 @@ exception statement from your version. */ package java.nio; +import java.io.IOException; + /** * @since 1.4 */ public abstract class CharBuffer extends Buffer - implements Comparable, CharSequence + implements Comparable<CharBuffer>, CharSequence, Readable, Appendable { int array_offset; char[] backing_buffer; @@ -163,6 +165,18 @@ public abstract class CharBuffer extends Buffer return this; } + /** @since 1.5 */ + public int read(CharBuffer buffer) throws IOException + { + // We want to call put(), so we don't manipulate the CharBuffer + // directly. + int rem = Math.min(buffer.remaining(), remaining()); + char[] buf = new char[rem]; + get(buf); + buffer.put(buf); + return rem; + } + /** * This method transfers <code>char</code>s from this buffer into the given * destination array. @@ -323,7 +337,7 @@ public abstract class CharBuffer extends Buffer { if (obj instanceof CharBuffer) { - return compareTo (obj) == 0; + return compareTo ((CharBuffer) obj) == 0; } return false; @@ -335,10 +349,8 @@ public abstract class CharBuffer extends Buffer * @exception ClassCastException If obj is not an object derived from * <code>CharBuffer</code>. */ - public int compareTo (Object obj) + public int compareTo (CharBuffer other) { - CharBuffer other = (CharBuffer) obj; - int num = Math.min(remaining(), other.remaining()); int pos_this = position(); int pos_other = other.position(); @@ -503,4 +515,25 @@ public abstract class CharBuffer extends Buffer return get (position () + index); } + + /** @since 1.5 */ + public CharBuffer append(char c) + { + put(c); + return this; + } + + /** @since 1.5 */ + public CharBuffer append(CharSequence cs) + { + put(cs == null ? "null" : cs.toString()); + return this; + } + + /** @since 1.5 */ + public CharBuffer append(CharSequence cs, int start, int end) + { + put(cs == null ? "null" : cs.subSequence(start, end).toString()); + return this; + } } diff --git a/libjava/classpath/java/nio/DirectByteBufferImpl.java b/libjava/classpath/java/nio/DirectByteBufferImpl.java index 3a9036f..8c907f5 100644 --- a/libjava/classpath/java/nio/DirectByteBufferImpl.java +++ b/libjava/classpath/java/nio/DirectByteBufferImpl.java @@ -233,7 +233,7 @@ abstract class DirectByteBufferImpl extends ByteBuffer { int pos = position(); if (this.mark != -1) - reset(); + reset(); int mark = position(); position(pos); DirectByteBufferImpl result; diff --git a/libjava/classpath/java/nio/DoubleBuffer.java b/libjava/classpath/java/nio/DoubleBuffer.java index 381bb71..be7861c 100644 --- a/libjava/classpath/java/nio/DoubleBuffer.java +++ b/libjava/classpath/java/nio/DoubleBuffer.java @@ -1,5 +1,5 @@ /* DoubleBuffer.java -- - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -42,7 +42,7 @@ package java.nio; * @since 1.4 */ public abstract class DoubleBuffer extends Buffer - implements Comparable + implements Comparable<DoubleBuffer> { int array_offset; double[] backing_buffer; @@ -273,7 +273,7 @@ public abstract class DoubleBuffer extends Buffer { if (obj instanceof DoubleBuffer) { - return compareTo (obj) == 0; + return compareTo ((DoubleBuffer) obj) == 0; } return false; @@ -285,10 +285,8 @@ public abstract class DoubleBuffer extends Buffer * @exception ClassCastException If obj is not an object derived from * <code>DoubleBuffer</code>. */ - public int compareTo (Object obj) + public int compareTo (DoubleBuffer other) { - DoubleBuffer other = (DoubleBuffer) obj; - int num = Math.min(remaining(), other.remaining()); int pos_this = position(); int pos_other = other.position(); diff --git a/libjava/classpath/java/nio/FloatBuffer.java b/libjava/classpath/java/nio/FloatBuffer.java index 8042333..62e353a 100644 --- a/libjava/classpath/java/nio/FloatBuffer.java +++ b/libjava/classpath/java/nio/FloatBuffer.java @@ -1,5 +1,5 @@ /* FloatBuffer.java -- - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -42,7 +42,7 @@ package java.nio; * @since 1.4 */ public abstract class FloatBuffer extends Buffer - implements Comparable + implements Comparable<FloatBuffer> { int array_offset; float[] backing_buffer; @@ -273,7 +273,7 @@ public abstract class FloatBuffer extends Buffer { if (obj instanceof FloatBuffer) { - return compareTo (obj) == 0; + return compareTo ((FloatBuffer) obj) == 0; } return false; @@ -285,10 +285,8 @@ public abstract class FloatBuffer extends Buffer * @exception ClassCastException If obj is not an object derived from * <code>FloatBuffer</code>. */ - public int compareTo (Object obj) + public int compareTo (FloatBuffer other) { - FloatBuffer other = (FloatBuffer) obj; - int num = Math.min(remaining(), other.remaining()); int pos_this = position(); int pos_other = other.position(); diff --git a/libjava/classpath/java/nio/IntBuffer.java b/libjava/classpath/java/nio/IntBuffer.java index 1e1fe9c..d6fcb51 100644 --- a/libjava/classpath/java/nio/IntBuffer.java +++ b/libjava/classpath/java/nio/IntBuffer.java @@ -1,5 +1,5 @@ /* IntBuffer.java -- - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -42,7 +42,7 @@ package java.nio; * @since 1.4 */ public abstract class IntBuffer extends Buffer - implements Comparable + implements Comparable<IntBuffer> { int array_offset; int[] backing_buffer; @@ -273,7 +273,7 @@ public abstract class IntBuffer extends Buffer { if (obj instanceof IntBuffer) { - return compareTo (obj) == 0; + return compareTo ((IntBuffer) obj) == 0; } return false; @@ -285,10 +285,8 @@ public abstract class IntBuffer extends Buffer * @exception ClassCastException If obj is not an object derived from * <code>IntBuffer</code>. */ - public int compareTo (Object obj) + public int compareTo (IntBuffer other) { - IntBuffer other = (IntBuffer) obj; - int num = Math.min(remaining(), other.remaining()); int pos_this = position(); int pos_other = other.position(); diff --git a/libjava/classpath/java/nio/LongBuffer.java b/libjava/classpath/java/nio/LongBuffer.java index b3d3557..9c3bfa6 100644 --- a/libjava/classpath/java/nio/LongBuffer.java +++ b/libjava/classpath/java/nio/LongBuffer.java @@ -1,5 +1,5 @@ /* LongBuffer.java -- - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -42,7 +42,7 @@ package java.nio; * @since 1.4 */ public abstract class LongBuffer extends Buffer - implements Comparable + implements Comparable<LongBuffer> { int array_offset; long[] backing_buffer; @@ -273,7 +273,7 @@ public abstract class LongBuffer extends Buffer { if (obj instanceof LongBuffer) { - return compareTo (obj) == 0; + return compareTo ((LongBuffer) obj) == 0; } return false; @@ -285,10 +285,8 @@ public abstract class LongBuffer extends Buffer * @exception ClassCastException If obj is not an object derived from * <code>LongBuffer</code>. */ - public int compareTo (Object obj) + public int compareTo (LongBuffer other) { - LongBuffer other = (LongBuffer) obj; - int num = Math.min(remaining(), other.remaining()); int pos_this = position(); int pos_other = other.position(); diff --git a/libjava/classpath/java/nio/ShortBuffer.java b/libjava/classpath/java/nio/ShortBuffer.java index 958fe8c..33e458a 100644 --- a/libjava/classpath/java/nio/ShortBuffer.java +++ b/libjava/classpath/java/nio/ShortBuffer.java @@ -1,5 +1,5 @@ /* ShortBuffer.java -- - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -42,7 +42,7 @@ package java.nio; * @since 1.4 */ public abstract class ShortBuffer extends Buffer - implements Comparable + implements Comparable<ShortBuffer> { int array_offset; short[] backing_buffer; @@ -273,7 +273,7 @@ public abstract class ShortBuffer extends Buffer { if (obj instanceof ShortBuffer) { - return compareTo (obj) == 0; + return compareTo ((ShortBuffer) obj) == 0; } return false; @@ -285,10 +285,8 @@ public abstract class ShortBuffer extends Buffer * @exception ClassCastException If obj is not an object derived from * <code>ShortBuffer</code>. */ - public int compareTo (Object obj) + public int compareTo (ShortBuffer other) { - ShortBuffer other = (ShortBuffer) obj; - int num = Math.min(remaining(), other.remaining()); int pos_this = position(); int pos_other = other.position(); diff --git a/libjava/classpath/java/nio/channels/Channel.java b/libjava/classpath/java/nio/channels/Channel.java index d488bd2..33fcf31 100644 --- a/libjava/classpath/java/nio/channels/Channel.java +++ b/libjava/classpath/java/nio/channels/Channel.java @@ -1,5 +1,5 @@ /* Channel.java -- - Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,8 +39,9 @@ exception statement from your version. */ package java.nio.channels; import java.io.IOException; +import java.io.Closeable; -public interface Channel +public interface Channel extends Closeable { /** * Tells whether this channel is open or not diff --git a/libjava/classpath/java/nio/channels/Selector.java b/libjava/classpath/java/nio/channels/Selector.java index 2c883ef..1c09db7 100644 --- a/libjava/classpath/java/nio/channels/Selector.java +++ b/libjava/classpath/java/nio/channels/Selector.java @@ -82,7 +82,7 @@ public abstract class Selector * * @exception ClosedSelectorException If this selector is closed. */ - public abstract Set keys(); + public abstract Set<SelectionKey> keys(); /** * Returns the SelectorProvider that created the selector. @@ -115,7 +115,7 @@ public abstract class Selector * * @exception ClosedSelectorException If this selector is closed. */ - public abstract Set selectedKeys(); + public abstract Set<SelectionKey> selectedKeys(); /** * Selects a set of keys whose corresponding channels are ready diff --git a/libjava/classpath/java/nio/channels/spi/AbstractSelectableChannel.java b/libjava/classpath/java/nio/channels/spi/AbstractSelectableChannel.java index 847c02c..5d5277b 100644 --- a/libjava/classpath/java/nio/channels/spi/AbstractSelectableChannel.java +++ b/libjava/classpath/java/nio/channels/spi/AbstractSelectableChannel.java @@ -44,6 +44,7 @@ import java.nio.channels.SelectableChannel; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.IllegalBlockingModeException; +import java.util.Iterator; import java.util.LinkedList; import java.util.ListIterator; @@ -106,7 +107,15 @@ public abstract class AbstractSelectableChannel extends SelectableChannel */ protected final void implCloseChannel() throws IOException { - implCloseSelectableChannel(); + try + { + implCloseSelectableChannel(); + } + finally + { + for (Iterator it = keys.iterator(); it.hasNext(); ) + ((SelectionKey) it.next()).cancel(); + } } /** @@ -234,8 +243,8 @@ public abstract class AbstractSelectableChannel extends SelectableChannel if (key != null && key.isValid()) { - if (att != null) - key.attach(att); + key.interestOps(ops); + key.attach(att); } else { diff --git a/libjava/classpath/java/nio/channels/spi/AbstractSelector.java b/libjava/classpath/java/nio/channels/spi/AbstractSelector.java index 7838073..73f5077 100644 --- a/libjava/classpath/java/nio/channels/spi/AbstractSelector.java +++ b/libjava/classpath/java/nio/channels/spi/AbstractSelector.java @@ -1,5 +1,5 @@ /* AbstractSelector.java -- - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -49,7 +49,7 @@ public abstract class AbstractSelector extends Selector { private boolean closed; private SelectorProvider provider; - private HashSet cancelledKeys; + private HashSet<SelectionKey> cancelledKeys; /** * Initializes the slector. @@ -59,7 +59,7 @@ public abstract class AbstractSelector extends Selector protected AbstractSelector(SelectorProvider provider) { this.provider = provider; - this.cancelledKeys = new HashSet(); + this.cancelledKeys = new HashSet<SelectionKey>(); } /** @@ -115,7 +115,7 @@ public abstract class AbstractSelector extends Selector * * @return the cancelled keys set */ - protected final Set cancelledKeys() + protected final Set<SelectionKey> cancelledKeys() { if (! isOpen()) throw new ClosedSelectorException(); diff --git a/libjava/classpath/java/nio/charset/Charset.java b/libjava/classpath/java/nio/charset/Charset.java index 3637703..556e470 100644 --- a/libjava/classpath/java/nio/charset/Charset.java +++ b/libjava/classpath/java/nio/charset/Charset.java @@ -60,7 +60,7 @@ import java.util.TreeMap; * @since 1.4 * @status updated to 1.5 */ -public abstract class Charset implements Comparable +public abstract class Charset implements Comparable<Charset> { private CharsetEncoder cachedEncoder; private CharsetDecoder cachedDecoder; @@ -219,19 +219,20 @@ public abstract class Charset implements Comparable return cs; } - public static SortedMap availableCharsets() + public static SortedMap<String, Charset> availableCharsets() { - TreeMap charsets = new TreeMap(String.CASE_INSENSITIVE_ORDER); - for (Iterator i = provider().charsets(); i.hasNext(); ) + TreeMap<String, Charset> charsets + = new TreeMap(String.CASE_INSENSITIVE_ORDER); + for (Iterator<Charset> i = provider().charsets(); i.hasNext(); ) { - Charset cs = (Charset) i.next(); + Charset cs = 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(); ) + for (Iterator<Charset> i = providers[j].charsets(); i.hasNext(); ) { Charset cs = (Charset) i.next(); charsets.put(cs.name(), cs); @@ -284,14 +285,14 @@ public abstract class Charset implements Comparable return canonicalName; } - public final Set aliases () + public final Set<String> aliases () { if (aliases == null) - return Collections.EMPTY_SET; + return Collections.<String>emptySet(); // should we cache the aliasSet instead? int n = aliases.length; - HashSet aliasSet = new HashSet (n); + HashSet<String> aliasSet = new HashSet<String> (n); for (int i = 0; i < n; ++i) aliasSet.add (aliases[i]); return Collections.unmodifiableSet (aliasSet); @@ -376,9 +377,9 @@ public abstract class Charset implements Comparable } } - public final int compareTo (Object ob) + public final int compareTo (Charset other) { - return canonicalName.compareToIgnoreCase (((Charset) ob).canonicalName); + return canonicalName.compareToIgnoreCase (other.canonicalName); } public final int hashCode () diff --git a/libjava/classpath/java/nio/charset/spi/CharsetProvider.java b/libjava/classpath/java/nio/charset/spi/CharsetProvider.java index 496ccf9..03653f8 100644 --- a/libjava/classpath/java/nio/charset/spi/CharsetProvider.java +++ b/libjava/classpath/java/nio/charset/spi/CharsetProvider.java @@ -1,5 +1,5 @@ /* CharsetProvider.java -- charset service provider interface - Copyright (C) 2002, 2006 Free Software Foundation + Copyright (C) 2002, 2005, 2006 Free Software Foundation This file is part of GNU Classpath. @@ -82,7 +82,7 @@ public abstract class CharsetProvider * @return the iterator * @see Charset#availableCharsets() */ - public abstract Iterator charsets(); + public abstract Iterator<Charset> charsets(); /** * Returns the named charset, by canonical name or alias. diff --git a/libjava/classpath/java/nio/class-dependencies.conf b/libjava/classpath/java/nio/class-dependencies.conf new file mode 100644 index 0000000..4fbf75e --- /dev/null +++ b/libjava/classpath/java/nio/class-dependencies.conf @@ -0,0 +1,58 @@ +# This property file contains dependencies of classes, methods, and +# field on other methods or classes. +# +# Syntax: +# +# <used>: <needed 1> [... <needed N>] +# +# means that when <used> is included, <needed 1> (... <needed N>) must +# be included as well. +# +# <needed X> and <used> are of the form +# +# <class.methodOrField(signature)> +# +# or just +# +# <class> +# +# Within dependencies, variables can be used. A variable is defined as +# follows: +# +# {variable}: value1 value2 ... value<n> +# +# variables can be used on the right side of dependencies as follows: +# +# <used>: com.bla.blu.{variable}.Class.m()V +# +# The use of the variable will expand to <n> dependencies of the form +# +# <used>: com.bla.blu.value1.Class.m()V +# <used>: com.bla.blu.value2.Class.m()V +# ... +# <used>: com.bla.blu.value<n>.Class.m()V +# +# Variables can be redefined when building a system to select the +# required support for features like encodings, protocols, etc. +# +# Hints: +# +# - For methods and fields, the signature is mandatory. For +# specification, please see the Java Virtual Machine Specification by +# SUN. Unlike in the spec, field signatures (types) are in brackets. +# +# - Package names must be separated by '/' (and not '.'). E.g., +# java/lang/Class (this is necessary, because the '.' is used to +# separate method or field names from classes) +# +# - In case <needed> refers to a class, only the class itself will be +# included in the resulting binary, NOT necessarily all its methods +# and fields. If you want to refer to all methods and fields, you can +# write class.* as an abbreviation. +# +# - Abbreviations for packages are also possible: my/package/* means all +# methods and fields of all classes in my/package. +# +# - A line with a trailing '\' continues in the next line. + +# end of file |