aboutsummaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authorBryce McKinlay <bryce@albatross.co.nz>2000-11-03 03:58:05 +0000
committerBryce McKinlay <bryce@gcc.gnu.org>2000-11-03 03:58:05 +0000
commit8d218b6742d2cd67c639ad6668431a56ccca0705 (patch)
tree513ddc423b9316dfe96f3d5e79a6ca4749279337 /libjava
parent19944601d69c0777c1aec481792c201a3b58b960 (diff)
downloadgcc-8d218b6742d2cd67c639ad6668431a56ccca0705.zip
gcc-8d218b6742d2cd67c639ad6668431a56ccca0705.tar.gz
gcc-8d218b6742d2cd67c639ad6668431a56ccca0705.tar.bz2
AbstractList.java (SubList): Make it a top-level private class.
2000-11-03 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractList.java (SubList): Make it a top-level private class. * java/util/LinkedList.java (remove): Do update modCount and knownMod. (add): Ditto. * Makefile.am (ordinary_java_source_files): Add LinkedList.java. * Makefile.in: Rebuilt. From-SVN: r37218
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog9
-rw-r--r--libjava/Makefile.am1
-rw-r--r--libjava/Makefile.in65
-rw-r--r--libjava/java/util/AbstractList.java422
-rw-r--r--libjava/java/util/LinkedList.java30
5 files changed, 268 insertions, 259 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 63bf5d1..24e84fa 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,12 @@
+2000-11-03 Bryce McKinlay <bryce@albatross.co.nz>
+
+ * java/util/AbstractList.java (SubList): Make it a top-level private
+ class.
+ * java/util/LinkedList.java (remove): Do update modCount and knownMod.
+ (add): Ditto.
+ * Makefile.am (ordinary_java_source_files): Add LinkedList.java.
+ * Makefile.in: Rebuilt.
+
2000-11-02 Tom Tromey <tromey@cygnus.com>
* Makefile.in: Rebuilt.
diff --git a/libjava/Makefile.am b/libjava/Makefile.am
index fec2f9e..649bd5c 100644
--- a/libjava/Makefile.am
+++ b/libjava/Makefile.am
@@ -935,6 +935,7 @@ java/util/GregorianCalendar.java \
java/util/HashMap.java \
java/util/Hashtable.java \
java/util/Iterator.java \
+java/util/LinkedList.java \
java/util/List.java \
java/util/ListIterator.java \
java/util/ListResourceBundle.java \
diff --git a/libjava/Makefile.in b/libjava/Makefile.in
index 2701b58..34cd42f 100644
--- a/libjava/Makefile.in
+++ b/libjava/Makefile.in
@@ -119,43 +119,29 @@ here = @here@
libgcj_basedir = @libgcj_basedir@
AUTOMAKE_OPTIONS = foreign no-installinfo
-@TESTSUBDIR_TRUE@SUBDIRS = \
-@TESTSUBDIR_TRUE@$(DIRLTDL) testsuite gcj include
-@TESTSUBDIR_FALSE@SUBDIRS = \
-@TESTSUBDIR_FALSE@$(DIRLTDL) gcj include
-@USE_LIBDIR_TRUE@toolexeclibdir = \
-@USE_LIBDIR_TRUE@$(libdir)$(MULTISUBDIR)
-@USE_LIBDIR_FALSE@toolexeclibdir = \
-@USE_LIBDIR_FALSE@$(toolexecdir)/lib$(MULTISUBDIR)
-@USE_LIBDIR_FALSE@toolexecdir = \
-@USE_LIBDIR_FALSE@$(exec_prefix)/$(target_alias)
-@NO_X_TRUE@cond_x_ltlibrary = \
-@NO_X_FALSE@cond_x_ltlibrary = \
-@NO_X_FALSE@libgcjx.la
+@TESTSUBDIR_TRUE@SUBDIRS = @TESTSUBDIR_TRUE@$(DIRLTDL) testsuite gcj include
+@TESTSUBDIR_FALSE@SUBDIRS = @TESTSUBDIR_FALSE@$(DIRLTDL) gcj include
+@USE_LIBDIR_TRUE@toolexeclibdir = @USE_LIBDIR_TRUE@$(libdir)$(MULTISUBDIR)
+@USE_LIBDIR_FALSE@toolexeclibdir = @USE_LIBDIR_FALSE@$(toolexecdir)/lib$(MULTISUBDIR)
+@USE_LIBDIR_FALSE@toolexecdir = @USE_LIBDIR_FALSE@$(exec_prefix)/$(target_alias)
+@NO_X_TRUE@cond_x_ltlibrary =
+@NO_X_FALSE@cond_x_ltlibrary = @NO_X_FALSE@libgcjx.la
toolexeclib_LTLIBRARIES = libgcj.la $(cond_x_ltlibrary)
toolexeclib_DATA = libgcj.spec
data_DATA = libgcj.zip
-@NEEDS_DATA_START_TRUE@toolexeclib_LIBRARIES = \
-@NEEDS_DATA_START_TRUE@libgcjdata.a
-@NEEDS_DATA_START_TRUE@libgcjdata_a_SOURCES = \
-@NEEDS_DATA_START_TRUE@libgcjdata.c
+@NEEDS_DATA_START_TRUE@toolexeclib_LIBRARIES = @NEEDS_DATA_START_TRUE@libgcjdata.a
+@NEEDS_DATA_START_TRUE@libgcjdata_a_SOURCES = @NEEDS_DATA_START_TRUE@libgcjdata.c
-@NATIVE_TRUE@bin_PROGRAMS = \
-@NATIVE_TRUE@jv-convert gij
+@NATIVE_TRUE@bin_PROGRAMS = @NATIVE_TRUE@jv-convert gij
bin_SCRIPTS = addr2name.awk
-@CANADIAN_TRUE@@NULL_TARGET_TRUE@ZIP = \
-@CANADIAN_TRUE@@NULL_TARGET_TRUE@$(MULTIBUILDTOP)../$(COMPPATH)/zip/zip$(EXEEXT)
-@CANADIAN_TRUE@@NULL_TARGET_FALSE@ZIP = \
-@CANADIAN_TRUE@@NULL_TARGET_FALSE@zip
-@CANADIAN_FALSE@ZIP = \
-@CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/zip/zip$(EXEEXT)
-@CANADIAN_TRUE@GCJH = \
-@CANADIAN_TRUE@gcjh
-@CANADIAN_FALSE@GCJH = \
-@CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/gcc/gcjh$(EXEEXT)
+@CANADIAN_TRUE@@NULL_TARGET_TRUE@ZIP = @CANADIAN_TRUE@@NULL_TARGET_TRUE@$(MULTIBUILDTOP)../$(COMPPATH)/zip/zip$(EXEEXT)
+@CANADIAN_TRUE@@NULL_TARGET_FALSE@ZIP = @CANADIAN_TRUE@@NULL_TARGET_FALSE@zip
+@CANADIAN_FALSE@ZIP = @CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/zip/zip$(EXEEXT)
+@CANADIAN_TRUE@GCJH = @CANADIAN_TRUE@gcjh
+@CANADIAN_FALSE@GCJH = @CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/gcc/gcjh$(EXEEXT)
GCJCOMPILE = $(LIBTOOL) --tag=GCJ --mode=compile $(GCJ) -fassume-compiled -fclasspath=$(here) -L$(here) $(JC1FLAGS) -MD -MT $@ -MF $(@:.lo=.d) -c
GCJLINK = $(LIBTOOL) --mode=link $(GCJ) -L$(here) $(JC1FLAGS) $(LDFLAGS) -o $@
@@ -170,10 +156,8 @@ AM_CXXFLAGS = -fno-rtti -fvtable-thunks -fasynchronous-exceptions \
-fdollars-in-identifiers \
@LIBGCJ_CXXFLAGS@ @EXCEPTIONSPEC@ @X_CFLAGS@ $(WARNINGS) -D_GNU_SOURCE
-@USING_GCC_TRUE@AM_CFLAGS = \
-@USING_GCC_TRUE@@LIBGCJ_CFLAGS@ $(WARNINGS)
-@USING_GCC_FALSE@AM_CFLAGS = \
-@USING_GCC_FALSE@@LIBGCJ_CFLAGS@
+@USING_GCC_TRUE@AM_CFLAGS = @USING_GCC_TRUE@@LIBGCJ_CFLAGS@ $(WARNINGS)
+@USING_GCC_FALSE@AM_CFLAGS = @USING_GCC_FALSE@@LIBGCJ_CFLAGS@
JCFLAGS = -g
JC1FLAGS = -g @LIBGCJ_JAVAFLAGS@
@@ -240,8 +224,7 @@ extra_headers = java/lang/Object.h java/lang/Class.h
NM = nm
-@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@noinst_PROGRAMS = \
-@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@gen-from-JIS
+@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@noinst_PROGRAMS = @NATIVE_TRUE@@MAINTAINER_MODE_TRUE@gen-from-JIS
CONVERT_DIR = gnu/gcj/convert
@@ -704,6 +687,7 @@ java/util/GregorianCalendar.java \
java/util/HashMap.java \
java/util/Hashtable.java \
java/util/Iterator.java \
+java/util/LinkedList.java \
java/util/List.java \
java/util/ListIterator.java \
java/util/ListResourceBundle.java \
@@ -1176,7 +1160,7 @@ libgcj-test.spec.in libgcj.spec.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-TAR = tar
+TAR = gtar
GZIP_ENV = --best
DIST_SUBDIRS = @DIRLTDL@ testsuite gcj include @DIRLTDL@ gcj include
DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
@@ -1653,9 +1637,10 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/util/EventListener.P .deps/java/util/EventObject.P \
.deps/java/util/GregorianCalendar.P .deps/java/util/HashMap.P \
.deps/java/util/Hashtable.P .deps/java/util/Iterator.P \
-.deps/java/util/List.P .deps/java/util/ListIterator.P \
-.deps/java/util/ListResourceBundle.P .deps/java/util/Locale.P \
-.deps/java/util/Map.P .deps/java/util/MissingResourceException.P \
+.deps/java/util/LinkedList.P .deps/java/util/List.P \
+.deps/java/util/ListIterator.P .deps/java/util/ListResourceBundle.P \
+.deps/java/util/Locale.P .deps/java/util/Map.P \
+.deps/java/util/MissingResourceException.P \
.deps/java/util/NoSuchElementException.P .deps/java/util/Observable.P \
.deps/java/util/Observer.P .deps/java/util/Properties.P \
.deps/java/util/PropertyPermission.P \
@@ -2062,7 +2047,7 @@ distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
- cp -pr $$/$$file $(distdir)/$$file; \
+ cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
diff --git a/libjava/java/util/AbstractList.java b/libjava/java/util/AbstractList.java
index cec2c29..ba589e3 100644
--- a/libjava/java/util/AbstractList.java
+++ b/libjava/java/util/AbstractList.java
@@ -309,232 +309,230 @@ public abstract class AbstractList extends AbstractCollection implements List
knownMod++;
}
} // AbstractList.Iterator
+}
+
+
+
+class SubList extends AbstractList
+{
+ private AbstractList backingList;
+ private int offset;
+ private int size;
- static class SubList extends AbstractList
+ public SubList(AbstractList backing, int fromIndex, int toIndex)
{
- private AbstractList backingList;
- private int offset;
- private int size;
+ backingList = backing;
+ modCount = backingList.modCount;
+ offset = fromIndex;
+ size = toIndex - fromIndex;
+ }
- public SubList(AbstractList backing, int fromIndex, int toIndex)
- {
- backingList = backing;
- // FIXME: The `this' prefixes in this class are a workaround for a
- // gcj bug. They should be removed later.
- this.modCount = backingList.modCount;
- offset = fromIndex;
- size = toIndex - fromIndex;
- }
+ /**
+ * This method checks the two modCount fields to ensure that there has
+ * not been a concurrent modification. It throws an exception if there
+ * has been, and otherwise returns normally.
+ * Note that since this method is private, it will be inlined.
+ *
+ * @exception ConcurrentModificationException if there has been a
+ * concurrent modification.
+ */
+ private void checkMod()
+ {
+ if (modCount != backingList.modCount)
+ throw new ConcurrentModificationException();
+ }
- /**
- * This method checks the two modCount fields to ensure that there has
- * not been a concurrent modification. It throws an exception if there
- * has been, and otherwise returns normally.
- * Note that since this method is private, it will be inlined.
- *
- * @exception ConcurrentModificationException if there has been a
- * concurrent modification.
- */
- private void checkMod()
- {
- if (this.modCount != backingList.modCount)
- throw new ConcurrentModificationException();
- }
+ /**
+ * This method checks that a value is between 0 and size (inclusive). If
+ * it is not, an exception is thrown.
+ * Note that since this method is private, it will be inlined.
+ *
+ * @exception IndexOutOfBoundsException if the value is out of range.
+ */
+ private void checkBoundsInclusive(int index)
+ {
+ if (index < 0 || index > size)
+ throw new IndexOutOfBoundsException("Index: " + index + ", Size:" +
+ size);
+ }
- /**
- * This method checks that a value is between 0 and size (inclusive). If
- * it is not, an exception is thrown.
- * Note that since this method is private, it will be inlined.
- *
- * @exception IndexOutOfBoundsException if the value is out of range.
- */
- private void checkBoundsInclusive(int index)
- {
- if (index < 0 || index > size)
- throw new IndexOutOfBoundsException("Index: " + index + ", Size:" +
- size);
- }
+ /**
+ * This method checks that a value is between 0 (inclusive) and size
+ * (exclusive). If it is not, an exception is thrown.
+ * Note that since this method is private, it will be inlined.
+ *
+ * @exception IndexOutOfBoundsException if the value is out of range.
+ */
+ private void checkBoundsExclusive(int index)
+ {
+ if (index < 0 || index >= size)
+ throw new IndexOutOfBoundsException("Index: " + index + ", Size:" +
+ size);
+ }
- /**
- * This method checks that a value is between 0 (inclusive) and size
- * (exclusive). If it is not, an exception is thrown.
- * Note that since this method is private, it will be inlined.
- *
- * @exception IndexOutOfBoundsException if the value is out of range.
- */
- private void checkBoundsExclusive(int index)
- {
- if (index < 0 || index >= size)
- throw new IndexOutOfBoundsException("Index: " + index + ", Size:" +
- size);
- }
+ public int size()
+ {
+ checkMod();
+ return size;
+ }
- public int size()
- {
- checkMod();
- return size;
- }
+ public Object set(int index, Object o)
+ {
+ checkMod();
+ checkBoundsExclusive(index);
+ o = backingList.set(index + offset, o);
+ return o;
+ }
- public Object set(int index, Object o)
- {
- checkMod();
- checkBoundsExclusive(index);
- o = backingList.set(index + offset, o);
- return o;
- }
+ public Object get(int index)
+ {
+ checkMod();
+ checkBoundsExclusive(index);
+ return backingList.get(index + offset);
+ }
- public Object get(int index)
- {
- checkMod();
- checkBoundsExclusive(index);
- return backingList.get(index + offset);
- }
+ public void add(int index, Object o)
+ {
+ checkMod();
+ checkBoundsInclusive(index);
+ backingList.add(index + offset, o);
+ this.modCount++;
+ size++;
+ }
- public void add(int index, Object o)
- {
- checkMod();
- checkBoundsInclusive(index);
- backingList.add(index + offset, o);
- this.modCount++;
- size++;
- }
+ public Object remove(int index)
+ {
+ checkMod();
+ checkBoundsExclusive(index);
+ Object o = backingList.remove(index + offset);
+ this.modCount++;
+ size--;
+ return o;
+ }
- public Object remove(int index)
- {
- checkMod();
- checkBoundsExclusive(index);
- Object o = backingList.remove(index + offset);
- this.modCount++;
- size--;
- return o;
- }
+ public void removeRange(int fromIndex, int toIndex)
+ {
+ checkMod();
+ checkBoundsExclusive(fromIndex);
+ checkBoundsInclusive(toIndex);
+
+ // this call will catch the toIndex < fromIndex condition
+ backingList.removeRange(offset + fromIndex, offset + toIndex);
+ this.modCount = backingList.modCount;
+ size -= toIndex - fromIndex;
+ }
- public void removeRange(int fromIndex, int toIndex)
- {
- checkMod();
- checkBoundsExclusive(fromIndex);
- checkBoundsInclusive(toIndex);
+ public boolean addAll(int index, Collection c)
+ {
+ checkMod();
+ checkBoundsInclusive(index);
+ int csize = c.size();
+ boolean result = backingList.addAll(offset + index, c);
+ this.modCount = backingList.modCount;
+ size += csize;
+ return result;
+ }
- // this call will catch the toIndex < fromIndex condition
- backingList.removeRange(offset + fromIndex, offset + toIndex);
- this.modCount = backingList.modCount;
- size -= toIndex - fromIndex;
- }
-
- public boolean addAll(int index, Collection c)
- {
- checkMod();
- checkBoundsInclusive(index);
- int csize = c.size();
- boolean result = backingList.addAll(offset + index, c);
- this.modCount = backingList.modCount;
- size += csize;
- return result;
- }
-
- public Iterator iterator()
+ public Iterator iterator()
+ {
+ return listIterator(0);
+ }
+
+ public ListIterator listIterator(final int index)
+ {
+ checkMod();
+ checkBoundsInclusive(index);
+
+ return new ListIterator()
{
- return listIterator(0);
- }
+ ListIterator i = backingList.listIterator(index + offset);
+ int position = index;
- public ListIterator listIterator(final int index)
- {
- checkMod();
- checkBoundsInclusive(index);
-
- return new ListIterator()
+ public boolean hasNext()
{
- ListIterator i = backingList.listIterator(index + offset);
- int position = index;
-
- public boolean hasNext()
- {
- checkMod();
- return position < size;
- }
-
- public boolean hasPrevious()
- {
- checkMod();
- return position > 0;
- }
-
- public Object next()
- {
- if (position < size)
- {
- Object o = i.next();
- position++;
- return o;
- }
- else
- throw new NoSuchElementException();
- }
-
- public Object previous()
- {
- if (position > 0)
- {
- Object o = i.previous();
- position--;
- return o;
- }
- else
- throw new NoSuchElementException();
- }
-
- public int nextIndex()
- {
- return offset + i.nextIndex();
- }
-
- public int previousIndex()
- {
- return offset + i.previousIndex();
- }
+ checkMod();
+ return position < size;
+ }
- public void remove()
- {
- i.remove();
- // FIXME: Uncomment the following line once the compiler is fixed.
- //SubList.this.modCount++;
- size--;
- position = nextIndex();
- }
-
- public void set(Object o)
- {
- i.set(o);
- }
-
- public void add(Object o)
- {
- i.add(o);
- // FIXME: Uncomment the following line once the compiler is fixed.
- //SubList.this.modCount++;
- size++;
- position++;
- }
-
- // Here is the reason why the various modCount fields are mostly
- // ignored in this wrapper listIterator.
- // IF the backing listIterator is failfast, then the following holds:
- // Using any other method on this list will call a corresponding
- // method on the backing list *after* the backing listIterator
- // is created, which will in turn cause a ConcurrentModException
- // when this listIterator comes to use the backing one. So it is
- // implicitly failfast.
- // If the backing listIterator is NOT failfast, then the whole of
- // this list isn't failfast, because the modCount field of the
- // backing list is not valid. It would still be *possible* to
- // make the iterator failfast wrt modifications of the sublist
- // only, but somewhat pointless when the list can be changed under
- // us.
- // Either way, no explicit handling of modCount is needed.
- // However modCount++ must be executed in add and remove, and size
- // must also be updated in these two methods, since they do not go
- // through the corresponding methods of the subList.
- };
- }
- } // AbstractList.SubList
-}
+ public boolean hasPrevious()
+ {
+ checkMod();
+ return position > 0;
+ }
+
+ public Object next()
+ {
+ if (position < size)
+ {
+ Object o = i.next();
+ position++;
+ return o;
+ }
+ else
+ throw new NoSuchElementException();
+ }
+
+ public Object previous()
+ {
+ if (position > 0)
+ {
+ Object o = i.previous();
+ position--;
+ return o;
+ }
+ else
+ throw new NoSuchElementException();
+ }
+
+ public int nextIndex()
+ {
+ return offset + i.nextIndex();
+ }
+
+ public int previousIndex()
+ {
+ return offset + i.previousIndex();
+ }
+
+ public void remove()
+ {
+ i.remove();
+ modCount++;
+ size--;
+ position = nextIndex();
+ }
+
+ public void set(Object o)
+ {
+ i.set(o);
+ }
+
+ public void add(Object o)
+ {
+ i.add(o);
+ modCount++;
+ size++;
+ position++;
+ }
+
+ // Here is the reason why the various modCount fields are mostly
+ // ignored in this wrapper listIterator.
+ // IF the backing listIterator is failfast, then the following holds:
+ // Using any other method on this list will call a corresponding
+ // method on the backing list *after* the backing listIterator
+ // is created, which will in turn cause a ConcurrentModException
+ // when this listIterator comes to use the backing one. So it is
+ // implicitly failfast.
+ // If the backing listIterator is NOT failfast, then the whole of
+ // this list isn't failfast, because the modCount field of the
+ // backing list is not valid. It would still be *possible* to
+ // make the iterator failfast wrt modifications of the sublist
+ // only, but somewhat pointless when the list can be changed under
+ // us.
+ // Either way, no explicit handling of modCount is needed.
+ // However modCount++ must be executed in add and remove, and size
+ // must also be updated in these two methods, since they do not go
+ // through the corresponding methods of the subList.
+ };
+ }
+} // SubList
diff --git a/libjava/java/util/LinkedList.java b/libjava/java/util/LinkedList.java
index 5854496..2221929 100644
--- a/libjava/java/util/LinkedList.java
+++ b/libjava/java/util/LinkedList.java
@@ -322,7 +322,7 @@ public class LinkedList extends AbstractSequentialList
prev.next = e;
prev = e;
}
- // Fix up the links between the last new entry and the following entry.
+ // Link the new chain of entries into the list.
prev.next = after;
if (after != null)
after.previous = e;
@@ -541,7 +541,7 @@ public class LinkedList extends AbstractSequentialList
* position, in a list of given size.
*/
LinkedListItr(int index)
- {
+ {
if (index == size)
{
next = null;
@@ -621,8 +621,8 @@ public class LinkedList extends AbstractSequentialList
next = lastReturned.next;
previous = lastReturned.previous;
- // Because the list is being manipulated directly, there's no need to
- // touch either modCount or knownMod here.
+ modCount++;
+ knownMod++;
removeEntry(lastReturned);
lastReturned = null;
@@ -631,11 +631,27 @@ public class LinkedList extends AbstractSequentialList
public void add(Object o)
{
checkMod();
- // Because the list is being manipulated directly, there's no need to
- // touch either modCount or knownMod here.
+ modCount++;
+ knownMod++;
Entry e = new Entry(o);
- addEntry(position, e);
+ e.previous = previous;
+ e.next = next;
+
+ if (previous != null)
+ previous.next = e;
+ else
+ first = e;
+
+ if (next != null)
+ {
+ next.previous = e;
+ next = next.next;
+ }
+ else
+ last = e;
+
previous = e;
+ size++;
position++;
lastReturned = null;
}