10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 6499848
27 * @ignore until 6842353 is resolved
28 * @summary Check that iterators work properly in the presence of
29 * concurrent finalization and removal of elements.
30 */
31
32 import java.util.*;
33 import java.util.concurrent.CountDownLatch;
34
35 public class GCDuringIteration {
36 private static void waitForFinalizersToRun() {
37 for (int i = 0; i < 2; i++)
38 tryWaitForFinalizersToRun();
39 }
40
41 private static void tryWaitForFinalizersToRun() {
42 System.gc();
43 final CountDownLatch fin = new CountDownLatch(1);
44 new Object() { protected void finalize() { fin.countDown(); }};
45 System.gc();
46 try { fin.await(); }
47 catch (InterruptedException ie) { throw new Error(ie); }
48 }
49
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 6499848
27 * @ignore until 6842353 is resolved
28 * @summary Check that iterators work properly in the presence of
29 * concurrent finalization and removal of elements.
30 * @key randomness
31 */
32
33 import java.util.*;
34 import java.util.concurrent.CountDownLatch;
35
36 public class GCDuringIteration {
37 private static void waitForFinalizersToRun() {
38 for (int i = 0; i < 2; i++)
39 tryWaitForFinalizersToRun();
40 }
41
42 private static void tryWaitForFinalizersToRun() {
43 System.gc();
44 final CountDownLatch fin = new CountDownLatch(1);
45 new Object() { protected void finalize() { fin.countDown(); }};
46 System.gc();
47 try { fin.await(); }
48 catch (InterruptedException ie) { throw new Error(ie); }
49 }
50
|