Eclipse调试器不会在条件断点处停止 [英] Eclipse Debugger doesn't stop at conditional breakpoint
问题描述
我在Eclipse中有要调试的Java代码.
这是代码:
公共两次排斥(节点n1,节点n2){双倍= 0.0;rep = Math.pow(K,2)/distEuc(n1,n2);System.out.println(Répulsion:" + rep);listForcesRep.add(rep);返回代表}私人Double distEuc(节点n1,节点n2){双倍d = 0.0;Object [] n1Attributes = n1.getAttribute("xy");Double x1 =(Double)n1Attributes [0];Double y1 =(Double)n1Attributes [1];Object [] n2Attributes = n2.getAttribute("xy");Double x2 =(Double)n2Attributes [0];Double y2 =(Double)n2Attributes [1];d = Math.sqrt((Math.pow(x1-x2,2)+ Math.pow(y1-y2,2)));返回d;}
我在以下行中切换了一个断点: rep = Math.pow(K,2)/distEuc(n1,n2);
,并且我以默认值运行了调试器,并且运行正常./p>
问题是,在某些时候, rep
变量的值是 NaN
,为了理解原因,我需要一个条件断点.
我这样设置条件断点:
但是当我运行调试时,它会跳过断点,并且循环会继续进行.
我做错了什么?我该如何解决?
谢谢!
那是因为 rep
在该行中仍等于0.0: Double rep = 0.0;
>
在计算 rep
值之后,需要在 System.out.println(Répulsion:" + rep);
处放置条件断点,然后在执行停止于该行,则拖放到帧"以再次执行该方法.
您还应该使用 Double.isNaN(rep)
或 rep.isNaN()
,而不是 rep == Double.NaN
.
I have this Java Code in Eclipse that I would like to Debug.
This is the code :
public Double repulsion(Node n1, Node n2) {
Double rep = 0.0;
rep = Math.pow(K, 2) / distEuc(n1, n2);
System.out.println("Répulsion : " + rep);
listForcesRep.add(rep);
return rep;
}
private Double distEuc(Node n1, Node n2) {
Double d = 0.0;
Object[] n1Attributes = n1.getAttribute("xy");
Double x1 = (Double) n1Attributes[0];
Double y1 = (Double) n1Attributes[1];
Object[] n2Attributes = n2.getAttribute("xy");
Double x2 = (Double) n2Attributes[0];
Double y2 = (Double) n2Attributes[1];
d = Math.sqrt((Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2)));
return d;
}
I toggled a breakpoint at line : rep = Math.pow(K, 2) / distEuc(n1, n2);
and I ran the debugger in its default values and it works fine.
The thing is that at some point the rep
variable takes a value NaN
and I need a conditional breakpoint in order to understand why.
I set the conditional breakpoint like this :
But when I run the debug, it skips the breakpoint and the loop keeps on going.
What did I do wrong? And how can I fix it?
Thanks!
That's because rep
is still equals to 0.0 in that line: Double rep = 0.0;
You need to put a conditional breakpoint at System.out.println("Répulsion : " + rep);
, after calculating rep
value, then when execution stops at that line, you "Drop to Frame" to execute again that method.
You should also use Double.isNaN(rep)
or rep.isNaN()
instead of rep == Double.NaN
.
这篇关于Eclipse调试器不会在条件断点处停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!