views:

44

answers:

3

hello,

[edit: I forgot to mention that it is a JUnit Test Case i am debugging. Is that a problem?]

i have a really strange problem in eclipse. (I am new to debugging in eclipse so post all what is in your mind...)

When i am at a certain line it just stops to go further in the code. It remains in the same line although i am pressing F6 thounsand times. for short ammount of time the line is not marked but then marked again. No exceptions at all...

this line looks like:

while (someIterator.hasNext()) {...}

i do not get this at all. its strange. What the hell is wrong. If Iterator has next it has to go into the while loop but if it is not it has to skip the while loop. I just dont get it...

thanks a lot for your answers. i am in deep shit right now

Eclipse Java EE IDE for Web Developers. Version: Helios Release Build id: 20100617-1415

A: 

See the 'Variables' view to check what's going on after each F6 hit.

卢声远 Shengyuan Lu
i did that before. what was strange there were many objects. i could click next forever but i dont think thats the point. If someIterator.hasNext() then it would go into the while loop. right?
A: 

Put the body of your loop on separate lines so you can see where the issue is. If you put everything on one line, Eclipse may not show what's going on too clearly. If the collection class is standard, then the issue is unlikely to lie with the Iterator unless you've somehow managed to link a linked list into a loop which is very unlikely.

(Expanded from my note below) Also ensure you call next() otherwise the iterator will never advance.

BAD:

while (i.hasNext()) {
  //...
}

GOOD:

while (i.hasNext()) {
  Object o = i.next();
  //...
}

BEST (assuming generics)

for (Foo o : list) {
  //....
}
locka
Its a LinkedList Iterator and it is standard.
then I suggest splitting out the lines. Step over each one at a time to see if the issue is in the iterator, or somewhere else. One thing that occurs as well is you have to call .next() in your while body otherwise your iterator won't advance forward and therefore you will loop for ever.
locka
A: 

maybe you have "skip all breakpoints" enabled!

-> http://www.vogella.de/articles/EclipseDebugging/article.html#advanced_skipbreakpoints

Alex_M
no thats not the answer. Thanks for your suggestion