rt/emul/compact/src/main/java/java/util/ConcurrentModificationException.java
changeset 772 d382dacfd73f
parent 557 5be31d9fa455
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/rt/emul/compact/src/main/java/java/util/ConcurrentModificationException.java	Tue Feb 26 16:54:16 2013 +0100
     1.3 @@ -0,0 +1,123 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package java.util;
    1.30 +
    1.31 +/**
    1.32 + * This exception may be thrown by methods that have detected concurrent
    1.33 + * modification of an object when such modification is not permissible.
    1.34 + * <p>
    1.35 + * For example, it is not generally permissible for one thread to modify a Collection
    1.36 + * while another thread is iterating over it.  In general, the results of the
    1.37 + * iteration are undefined under these circumstances.  Some Iterator
    1.38 + * implementations (including those of all the general purpose collection implementations
    1.39 + * provided by the JRE) may choose to throw this exception if this behavior is
    1.40 + * detected.  Iterators that do this are known as <i>fail-fast</i> iterators,
    1.41 + * as they fail quickly and cleanly, rather that risking arbitrary,
    1.42 + * non-deterministic behavior at an undetermined time in the future.
    1.43 + * <p>
    1.44 + * Note that this exception does not always indicate that an object has
    1.45 + * been concurrently modified by a <i>different</i> thread.  If a single
    1.46 + * thread issues a sequence of method invocations that violates the
    1.47 + * contract of an object, the object may throw this exception.  For
    1.48 + * example, if a thread modifies a collection directly while it is
    1.49 + * iterating over the collection with a fail-fast iterator, the iterator
    1.50 + * will throw this exception.
    1.51 + *
    1.52 + * <p>Note that fail-fast behavior cannot be guaranteed as it is, generally
    1.53 + * speaking, impossible to make any hard guarantees in the presence of
    1.54 + * unsynchronized concurrent modification.  Fail-fast operations
    1.55 + * throw {@code ConcurrentModificationException} on a best-effort basis.
    1.56 + * Therefore, it would be wrong to write a program that depended on this
    1.57 + * exception for its correctness: <i>{@code ConcurrentModificationException}
    1.58 + * should be used only to detect bugs.</i>
    1.59 + *
    1.60 + * @author  Josh Bloch
    1.61 + * @see     Collection
    1.62 + * @see     Iterator
    1.63 + * @see     ListIterator
    1.64 + * @see     Vector
    1.65 + * @see     LinkedList
    1.66 + * @see     HashSet
    1.67 + * @see     Hashtable
    1.68 + * @see     TreeMap
    1.69 + * @see     AbstractList
    1.70 + * @since   1.2
    1.71 + */
    1.72 +public class ConcurrentModificationException extends RuntimeException {
    1.73 +    private static final long serialVersionUID = -3666751008965953603L;
    1.74 +
    1.75 +    /**
    1.76 +     * Constructs a ConcurrentModificationException with no
    1.77 +     * detail message.
    1.78 +     */
    1.79 +    public ConcurrentModificationException() {
    1.80 +    }
    1.81 +
    1.82 +    /**
    1.83 +     * Constructs a {@code ConcurrentModificationException} with the
    1.84 +     * specified detail message.
    1.85 +     *
    1.86 +     * @param message the detail message pertaining to this exception.
    1.87 +     */
    1.88 +    public ConcurrentModificationException(String message) {
    1.89 +        super(message);
    1.90 +    }
    1.91 +
    1.92 +    /**
    1.93 +     * Constructs a new exception with the specified cause and a detail
    1.94 +     * message of {@code (cause==null ? null : cause.toString())} (which
    1.95 +     * typically contains the class and detail message of {@code cause}.
    1.96 +     *
    1.97 +     * @param  cause the cause (which is saved for later retrieval by the
    1.98 +     *         {@link Throwable#getCause()} method).  (A {@code null} value is
    1.99 +     *         permitted, and indicates that the cause is nonexistent or
   1.100 +     *         unknown.)
   1.101 +     * @since  1.7
   1.102 +     */
   1.103 +    public ConcurrentModificationException(Throwable cause) {
   1.104 +        super(cause);
   1.105 +    }
   1.106 +
   1.107 +    /**
   1.108 +     * Constructs a new exception with the specified detail message and
   1.109 +     * cause.
   1.110 +     *
   1.111 +     * <p>Note that the detail message associated with <code>cause</code> is
   1.112 +     * <i>not</i> automatically incorporated in this exception's detail
   1.113 +     * message.
   1.114 +     *
   1.115 +     * @param  message the detail message (which is saved for later retrieval
   1.116 +     *         by the {@link Throwable#getMessage()} method).
   1.117 +     * @param  cause the cause (which is saved for later retrieval by the
   1.118 +     *         {@link Throwable#getCause()} method).  (A {@code null} value
   1.119 +     *         is permitted, and indicates that the cause is nonexistent or
   1.120 +     *         unknown.)
   1.121 +     * @since 1.7
   1.122 +     */
   1.123 +    public ConcurrentModificationException(String message, Throwable cause) {
   1.124 +        super(message, cause);
   1.125 +    }
   1.126 +}