This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libgcj/18187] New: ava.util.WeakHashMap$WeakEntrySet.next() throws NoSuchElementException during GC
- From: "ovidr at users dot sourceforge dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Oct 2004 19:44:34 -0000
- Subject: [Bug libgcj/18187] New: ava.util.WeakHashMap$WeakEntrySet.next() throws NoSuchElementException during GC
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
During garbage collection, the WeakHashMap will throw a NoSuchElementException
when performing the methods:
.keySet().toArray()
.clear();
and maybe more. Sun's java does not.
Here is an example:
gcc version 4.0.0 20041014 (experimental)
gcj -main=WH WH.java
import java.util.*;
public class WH {
public static void main(String[] s) {
Thread t = new Thread() {
public void run() {
while (true) {
System.gc();
try {
Thread.sleep(1000);
} catch (Exception e) {
}
}
}
};
WeakHashMap w = new WeakHashMap();
for (int i = 0; i < 10000; i++)
w.put(new WH(), null);
t.setDaemon(true);
t.start();
try {
w.clear();
} catch (NoSuchElementException n) {
System.out.println("From .clear(): ");
n.printStackTrace();
}
for (int i = 0; i < 10000; i++)
w.put(new WH(), null);
try {
for (int i = 0; i < 1000; i++)
System.out.print("["+w.keySet().toArray().length+"]");
} catch (NoSuchElementException n) {
System.out.println("iFrom .toArray():");
n.printStackTrace();
}
}
}
--
Summary: ava.util.WeakHashMap$WeakEntrySet.next() throws
NoSuchElementException during GC
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: libgcj
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ovidr at users dot sourceforge dot net
CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18187