rt/emul/compact/src/main/java/java/util/ConcurrentModificationException.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 26 Feb 2013 16:54:16 +0100
changeset 772 d382dacfd73f
parent 557 emul/compact/src/main/java/java/util/ConcurrentModificationException.java@5be31d9fa455
permissions -rw-r--r--
Moving modules around so the runtime is under one master pom and can be built without building other modules that are in the repository
jaroslav@557
     1
/*
jaroslav@557
     2
 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
jaroslav@557
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jaroslav@557
     4
 *
jaroslav@557
     5
 * This code is free software; you can redistribute it and/or modify it
jaroslav@557
     6
 * under the terms of the GNU General Public License version 2 only, as
jaroslav@557
     7
 * published by the Free Software Foundation.  Oracle designates this
jaroslav@557
     8
 * particular file as subject to the "Classpath" exception as provided
jaroslav@557
     9
 * by Oracle in the LICENSE file that accompanied this code.
jaroslav@557
    10
 *
jaroslav@557
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
jaroslav@557
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jaroslav@557
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
jaroslav@557
    14
 * version 2 for more details (a copy is included in the LICENSE file that
jaroslav@557
    15
 * accompanied this code).
jaroslav@557
    16
 *
jaroslav@557
    17
 * You should have received a copy of the GNU General Public License version
jaroslav@557
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
jaroslav@557
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jaroslav@557
    20
 *
jaroslav@557
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jaroslav@557
    22
 * or visit www.oracle.com if you need additional information or have any
jaroslav@557
    23
 * questions.
jaroslav@557
    24
 */
jaroslav@557
    25
jaroslav@557
    26
package java.util;
jaroslav@557
    27
jaroslav@557
    28
/**
jaroslav@557
    29
 * This exception may be thrown by methods that have detected concurrent
jaroslav@557
    30
 * modification of an object when such modification is not permissible.
jaroslav@557
    31
 * <p>
jaroslav@557
    32
 * For example, it is not generally permissible for one thread to modify a Collection
jaroslav@557
    33
 * while another thread is iterating over it.  In general, the results of the
jaroslav@557
    34
 * iteration are undefined under these circumstances.  Some Iterator
jaroslav@557
    35
 * implementations (including those of all the general purpose collection implementations
jaroslav@557
    36
 * provided by the JRE) may choose to throw this exception if this behavior is
jaroslav@557
    37
 * detected.  Iterators that do this are known as <i>fail-fast</i> iterators,
jaroslav@557
    38
 * as they fail quickly and cleanly, rather that risking arbitrary,
jaroslav@557
    39
 * non-deterministic behavior at an undetermined time in the future.
jaroslav@557
    40
 * <p>
jaroslav@557
    41
 * Note that this exception does not always indicate that an object has
jaroslav@557
    42
 * been concurrently modified by a <i>different</i> thread.  If a single
jaroslav@557
    43
 * thread issues a sequence of method invocations that violates the
jaroslav@557
    44
 * contract of an object, the object may throw this exception.  For
jaroslav@557
    45
 * example, if a thread modifies a collection directly while it is
jaroslav@557
    46
 * iterating over the collection with a fail-fast iterator, the iterator
jaroslav@557
    47
 * will throw this exception.
jaroslav@557
    48
 *
jaroslav@557
    49
 * <p>Note that fail-fast behavior cannot be guaranteed as it is, generally
jaroslav@557
    50
 * speaking, impossible to make any hard guarantees in the presence of
jaroslav@557
    51
 * unsynchronized concurrent modification.  Fail-fast operations
jaroslav@557
    52
 * throw {@code ConcurrentModificationException} on a best-effort basis.
jaroslav@557
    53
 * Therefore, it would be wrong to write a program that depended on this
jaroslav@557
    54
 * exception for its correctness: <i>{@code ConcurrentModificationException}
jaroslav@557
    55
 * should be used only to detect bugs.</i>
jaroslav@557
    56
 *
jaroslav@557
    57
 * @author  Josh Bloch
jaroslav@557
    58
 * @see     Collection
jaroslav@557
    59
 * @see     Iterator
jaroslav@557
    60
 * @see     ListIterator
jaroslav@557
    61
 * @see     Vector
jaroslav@557
    62
 * @see     LinkedList
jaroslav@557
    63
 * @see     HashSet
jaroslav@557
    64
 * @see     Hashtable
jaroslav@557
    65
 * @see     TreeMap
jaroslav@557
    66
 * @see     AbstractList
jaroslav@557
    67
 * @since   1.2
jaroslav@557
    68
 */
jaroslav@557
    69
public class ConcurrentModificationException extends RuntimeException {
jaroslav@557
    70
    private static final long serialVersionUID = -3666751008965953603L;
jaroslav@557
    71
jaroslav@557
    72
    /**
jaroslav@557
    73
     * Constructs a ConcurrentModificationException with no
jaroslav@557
    74
     * detail message.
jaroslav@557
    75
     */
jaroslav@557
    76
    public ConcurrentModificationException() {
jaroslav@557
    77
    }
jaroslav@557
    78
jaroslav@557
    79
    /**
jaroslav@557
    80
     * Constructs a {@code ConcurrentModificationException} with the
jaroslav@557
    81
     * specified detail message.
jaroslav@557
    82
     *
jaroslav@557
    83
     * @param message the detail message pertaining to this exception.
jaroslav@557
    84
     */
jaroslav@557
    85
    public ConcurrentModificationException(String message) {
jaroslav@557
    86
        super(message);
jaroslav@557
    87
    }
jaroslav@557
    88
jaroslav@557
    89
    /**
jaroslav@557
    90
     * Constructs a new exception with the specified cause and a detail
jaroslav@557
    91
     * message of {@code (cause==null ? null : cause.toString())} (which
jaroslav@557
    92
     * typically contains the class and detail message of {@code cause}.
jaroslav@557
    93
     *
jaroslav@557
    94
     * @param  cause the cause (which is saved for later retrieval by the
jaroslav@557
    95
     *         {@link Throwable#getCause()} method).  (A {@code null} value is
jaroslav@557
    96
     *         permitted, and indicates that the cause is nonexistent or
jaroslav@557
    97
     *         unknown.)
jaroslav@557
    98
     * @since  1.7
jaroslav@557
    99
     */
jaroslav@557
   100
    public ConcurrentModificationException(Throwable cause) {
jaroslav@557
   101
        super(cause);
jaroslav@557
   102
    }
jaroslav@557
   103
jaroslav@557
   104
    /**
jaroslav@557
   105
     * Constructs a new exception with the specified detail message and
jaroslav@557
   106
     * cause.
jaroslav@557
   107
     *
jaroslav@557
   108
     * <p>Note that the detail message associated with <code>cause</code> is
jaroslav@557
   109
     * <i>not</i> automatically incorporated in this exception's detail
jaroslav@557
   110
     * message.
jaroslav@557
   111
     *
jaroslav@557
   112
     * @param  message the detail message (which is saved for later retrieval
jaroslav@557
   113
     *         by the {@link Throwable#getMessage()} method).
jaroslav@557
   114
     * @param  cause the cause (which is saved for later retrieval by the
jaroslav@557
   115
     *         {@link Throwable#getCause()} method).  (A {@code null} value
jaroslav@557
   116
     *         is permitted, and indicates that the cause is nonexistent or
jaroslav@557
   117
     *         unknown.)
jaroslav@557
   118
     * @since 1.7
jaroslav@557
   119
     */
jaroslav@557
   120
    public ConcurrentModificationException(String message, Throwable cause) {
jaroslav@557
   121
        super(message, cause);
jaroslav@557
   122
    }
jaroslav@557
   123
}