Package org.pathvisio.libgpml.debug
Class DebugList<E>
java.lang.Object
org.pathvisio.libgpml.debug.DebugList<E>
- Type Parameters:
E
- List element type
- All Implemented Interfaces:
java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.List<E>
public class DebugList<E>
extends java.lang.Object
implements java.util.List<E>
This is a List that helps in the search for ConcurrentModification problems.
Most List's in the collection interface are fail-fast, if you modify a list
while iterating over it, a ConcurrentModificationException might be thrown.
The problem is that this exception is thrown when this is detected, which is
in the iterator.next() method, but it does not tell where the modification
occurred.
DebugList saves a stack trace for each modification made to it. Then, when a
the exceptional situation arises, it also throws a
ConcurrentModificationException but adds the point of the last modification
as the cause, which should help greatly in debugging the problem.
This is intended to debug problems with single-threaded usage of lists, I
don't know how useful it will be for debugging multi-threading problems.
This class wraps around an ordinary ArrayList<E>
- Author:
- unknown
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DebugList.DebugIterator<E>
An iterator to go with the DebugList. -
Field Summary
-
Constructor Summary
Constructors Constructor Description DebugList()
-
Method Summary
Modifier and Type Method Description void
add(int arg0, E arg1)
boolean
add(E arg0)
boolean
addAll(int arg0, java.util.Collection<? extends E> arg1)
boolean
addAll(java.util.Collection<? extends E> arg0)
void
clear()
boolean
contains(java.lang.Object arg0)
boolean
containsAll(java.util.Collection<?> arg0)
E
get(int arg0)
private static void
helper()
int
indexOf(java.lang.Object arg0)
boolean
isEmpty()
java.util.Iterator<E>
iterator()
int
lastIndexOf(java.lang.Object arg0)
java.util.ListIterator<E>
listIterator()
java.util.ListIterator<E>
listIterator(int arg0)
E
remove(int arg0)
boolean
remove(java.lang.Object arg0)
boolean
removeAll(java.util.Collection<?> arg0)
boolean
retainAll(java.util.Collection<?> arg0)
E
set(int arg0, E arg1)
int
size()
java.util.List<E>
subList(int arg0, int arg1)
java.lang.Object[]
toArray()
<T> T[]
toArray(T[] arg0)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.lang.Iterable
forEach
Methods inherited from interface java.util.List
equals, hashCode, replaceAll, sort, spliterator
-
Field Details
-
cause
private java.lang.Throwable cause -
delegate
-
modCount
int modCount
-
-
Constructor Details
-
DebugList
public DebugList()
-
-
Method Details
-
add
-
add
- Specified by:
add
in interfacejava.util.List<E>
-
addAll
-
addAll
- Specified by:
addAll
in interfacejava.util.List<E>
-
clear
public void clear() -
contains
public boolean contains(java.lang.Object arg0) -
containsAll
public boolean containsAll(java.util.Collection<?> arg0) -
get
- Specified by:
get
in interfacejava.util.List<E>
-
indexOf
public int indexOf(java.lang.Object arg0)- Specified by:
indexOf
in interfacejava.util.List<E>
-
isEmpty
public boolean isEmpty() -
iterator
-
lastIndexOf
public int lastIndexOf(java.lang.Object arg0)- Specified by:
lastIndexOf
in interfacejava.util.List<E>
-
listIterator
- Specified by:
listIterator
in interfacejava.util.List<E>
-
listIterator
- Specified by:
listIterator
in interfacejava.util.List<E>
-
remove
public boolean remove(java.lang.Object arg0) -
remove
- Specified by:
remove
in interfacejava.util.List<E>
-
removeAll
public boolean removeAll(java.util.Collection<?> arg0) -
retainAll
public boolean retainAll(java.util.Collection<?> arg0) -
set
- Specified by:
set
in interfacejava.util.List<E>
-
size
public int size() -
subList
- Specified by:
subList
in interfacejava.util.List<E>
-
toArray
public java.lang.Object[] toArray() -
toArray
public <T> T[] toArray(T[] arg0) -
helper
private static void helper()
-