This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libgcj/18187] New: ava.util.WeakHashMap$WeakEntrySet.next() throws NoSuchElementException during GC


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]