1 Reply Latest reply on Apr 15, 2008 6:56 AM by 666705

    java.util.NoSuchElementException with LinkedList on JRockit R27.4

    666705
      java.util.NoSuchElementException
      at java.util.LinkedList.remove(LinkedList.java:644)
      at java.util.LinkedList.removeFirst(LinkedList.java:134)
      at java.util.LinkedList.poll(LinkedList.java:475)

      Hitting this seems to depend on a combination of Queue.offer/poll with a return in between.

      I have a reproducer, where, if you call the following test() method in a main loop, after about 175 iterations, it throws the NoSuchElementException consistently. (I don't think I can add attachments to these posts, so sorry for the formatting)

      public void test()
      {
      Queue<Long> q = new LinkedList<Long>();

      q.offer(1L);

      int num = 0;
      while(!q.isEmpty()) {
      long x = q.poll();

      if (num >= 100000) {
      return;
      }

      if ((num % 1000) == 0) {
      q.offer(1L);
      q.offer(2L);
      } else {
      q.offer(3L);
      }

      num++;
      }
      }

      Thanks
        • 1. Re: java.util.NoSuchElementException with LinkedList on JRockit R27.4
          666705
          Hi,

          You seem to have found a bug in our optimizing compiler. If you disable optimizations (either completely with -Xnoopt or for just that method using the optfile described here: http://e-docs.bea.com/jrockit/geninfo/diagnos/crash.html#wp1010427) you should be able to run without problems.

          We will take a look at the problem and fix it in an upcoming version of Jrockit.

          Thanks a lot for letting us know!
          /Staffan