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

    Fields
    Modifier and Type Field Description
    private java.lang.Throwable cause  
    private java.util.List<E> delegate  
    (package private) int modCount  
  • 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

      private java.util.List<E> delegate
    • modCount

      int modCount
  • Constructor Details

    • DebugList

      public DebugList()
  • Method Details

    • add

      public boolean add​(E arg0)
      Specified by:
      add in interface java.util.Collection<E>
      Specified by:
      add in interface java.util.List<E>
    • add

      public void add​(int arg0, E arg1)
      Specified by:
      add in interface java.util.List<E>
    • addAll

      public boolean addAll​(java.util.Collection<? extends E> arg0)
      Specified by:
      addAll in interface java.util.Collection<E>
      Specified by:
      addAll in interface java.util.List<E>
    • addAll

      public boolean addAll​(int arg0, java.util.Collection<? extends E> arg1)
      Specified by:
      addAll in interface java.util.List<E>
    • clear

      public void clear()
      Specified by:
      clear in interface java.util.Collection<E>
      Specified by:
      clear in interface java.util.List<E>
    • contains

      public boolean contains​(java.lang.Object arg0)
      Specified by:
      contains in interface java.util.Collection<E>
      Specified by:
      contains in interface java.util.List<E>
    • containsAll

      public boolean containsAll​(java.util.Collection<?> arg0)
      Specified by:
      containsAll in interface java.util.Collection<E>
      Specified by:
      containsAll in interface java.util.List<E>
    • get

      public E get​(int arg0)
      Specified by:
      get in interface java.util.List<E>
    • indexOf

      public int indexOf​(java.lang.Object arg0)
      Specified by:
      indexOf in interface java.util.List<E>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface java.util.Collection<E>
      Specified by:
      isEmpty in interface java.util.List<E>
    • iterator

      public java.util.Iterator<E> iterator()
      Specified by:
      iterator in interface java.util.Collection<E>
      Specified by:
      iterator in interface java.lang.Iterable<E>
      Specified by:
      iterator in interface java.util.List<E>
    • lastIndexOf

      public int lastIndexOf​(java.lang.Object arg0)
      Specified by:
      lastIndexOf in interface java.util.List<E>
    • listIterator

      public java.util.ListIterator<E> listIterator()
      Specified by:
      listIterator in interface java.util.List<E>
    • listIterator

      public java.util.ListIterator<E> listIterator​(int arg0)
      Specified by:
      listIterator in interface java.util.List<E>
    • remove

      public boolean remove​(java.lang.Object arg0)
      Specified by:
      remove in interface java.util.Collection<E>
      Specified by:
      remove in interface java.util.List<E>
    • remove

      public E remove​(int arg0)
      Specified by:
      remove in interface java.util.List<E>
    • removeAll

      public boolean removeAll​(java.util.Collection<?> arg0)
      Specified by:
      removeAll in interface java.util.Collection<E>
      Specified by:
      removeAll in interface java.util.List<E>
    • retainAll

      public boolean retainAll​(java.util.Collection<?> arg0)
      Specified by:
      retainAll in interface java.util.Collection<E>
      Specified by:
      retainAll in interface java.util.List<E>
    • set

      public E set​(int arg0, E arg1)
      Specified by:
      set in interface java.util.List<E>
    • size

      public int size()
      Specified by:
      size in interface java.util.Collection<E>
      Specified by:
      size in interface java.util.List<E>
    • subList

      public java.util.List<E> subList​(int arg0, int arg1)
      Specified by:
      subList in interface java.util.List<E>
    • toArray

      public java.lang.Object[] toArray()
      Specified by:
      toArray in interface java.util.Collection<E>
      Specified by:
      toArray in interface java.util.List<E>
    • toArray

      public <T> T[] toArray​(T[] arg0)
      Specified by:
      toArray in interface java.util.Collection<E>
      Specified by:
      toArray in interface java.util.List<E>
    • helper

      private static void helper()