开发者

java eclipse iterator debugger problem

[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. Ver开发者_如何学JAVAsion: Helios Release Build id: 20100617-1415


maybe you have "skip all breakpoints" enabled!

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


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) {
  //....
}


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜