简体   繁体   English

Intellij调试器:true变为false,这是怎么回事...?

[英]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.

相关问题 Netbeans Java Debugger声称((true && false)== true) - Netbeans Java Debugger claims that ((true && false) == true) mysql jdbc:将真值插入位列变为假 - mysql jdbc: inserting true value to a bit column becomes false 这段代码中对与错的区别是什么? - What is the difference in true and false in this code? Intellij Idea提示:条件总是错误的 - 这可能是真的吗? (JAVA) - Intellij Idea hint: Condition is always false - can that be true here? (Java) IntelliJ显示instanceof的“始终为true”提示,但不显示“始终为false” - IntelliJ show “always true” hint but not “always false” for instanceof 什么样的Java语法是“== null?假:真;” - What kind of Java syntax is “== null? false:true;” onOptionsItemSelected()应返回什么,true或false? - What should be returned, true or false for onOptionsItemSelected() ? 一个“if”条件,结果是假的,但我的程序正在通过这个,如果无论如何??? (对或错) - A “if” condition which result is false but my program is going trough this if anyway ??? (true or false) IntelliJ IDEA调试器的变量面板中的变量描述如何解释? - What is the interpretation of the variable description in the variables panel in the IntelliJ IDEA debugger? 在Intellij中使用Java调试器时“Drop Frame”是什么意思? - When using the Java debugger in Intellij what does “Drop Frame” mean?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM