LargeEnumIteratorRemoveResilience.java revision 3758
3758N/A * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved. 3758N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3758N/A * This code is free software; you can redistribute it and/or modify it 3758N/A * under the terms of the GNU General Public License version 2 only, as 3758N/A * published by the Free Software Foundation. 3758N/A * This code is distributed in the hope that it will be useful, but WITHOUT 3758N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3758N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3758N/A * version 2 for more details (a copy is included in the LICENSE file that 3758N/A * You should have received a copy of the GNU General Public License version 3758N/A * 2 along with this work; if not, write to the Free Software Foundation, 3758N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3758N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 3758N/A * or visit www.oracle.com if you need additional information or have any 3758N/A * Portions Copyright (c) 2011 IBM Corporation 3758N/A * @summary EnumSet's iterator.remove() can be resilient to set's modification. 3758N/A * @author Neil Richards <neil.richards@ngmr.net>, <neil_richards@uk.ibm.com> 3758N/A // enum with more than 64 values 3758N/A // The Java API declares that the behaviour here - to call 3758N/A // iterator.remove() after the underlying collection has been 3758N/A // modified - is "unspecified". 3758N/A // However, in the case of iterators for EnumSet, it is easy to 3758N/A // implement their remove() operation such that the set is 3758N/A // unmodified if it is called for an element that has already been 3758N/A // removed from the set - this being the naturally "resilient" 3758N/A throw new Exception(
"Test FAILED: Element returned from iterator unexpectedly still in set after removal.");