[英]Intellij debugger: true becomes false, what is going on…?
I have this config class: 我有这个配置类:
public class ShiroConfiguration {
private final boolean enabled = false;
public boolean isEnabled() {
return enabled; // ****
}
Obviously, the mistake is that I made the enabled flag 'final', so it can never be anything but false. 显然,错误是我将启用标志设置为“最终”,因此它只能是假的。
At runtime, I was trying to figure out why my config was not enabled, so ran the code in the debugger (in IntelliJ), with a break-point set on the starred line. 在运行时,我试图弄清为什么未启用配置,因此在调试器(在IntelliJ中)中运行了代码,并在加星号的行上设置了断点。 The debugger showed that enabled had the value 'true', yet this method was definitely returning the value 'false'.
调试器显示启用的值为'true',但此方法肯定返回值'false'。
Why can the debugger see an incorrect version of the object? 调试器为什么会看到该对象的版本不正确?
I cannot comprehend how this is possible. 我不明白这怎么可能。 Is it a bug in IntelliJ, or in the Java debugging interface?
它是IntelliJ中的错误,还是Java调试界面中的错误?
============== ==============
Here is what I see in the debugger at a breakpoint on the line that calls config.isEnabled(): 这是我在调试器中在调用config.isEnabled()的断点处看到的内容:
If you haven't made any mistake in calling the method, ie called a method of different class, this definitely seems to a bug in the debugger. 如果您在调用该方法时没有犯任何错误,即,调用了不同类的方法,那么这肯定是调试器中的错误。 The debugger seems to be neglecting the
final
keyword in the program temporarily. 调试器似乎暂时忽略了程序中的
final
关键字。 Just try removing the final
keyword for a moment, and see if this is the case. 只需尝试删除
final
关键字片刻,然后看看是否是这种情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.