在调试java app时,为堆栈框架中的变量显示了哪些信息 [英] While debugging java app what information is shown for a variable in a stack frame

查看:102
本文介绍了在调试java app时,为堆栈框架中的变量显示了哪些信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Intellij Idea中调试java app时,我看到堆栈帧中的所有变量都是这样的:

When I debug java app in Intellij Idea I see all variables in a stack frame like this:

object={java.lang.Object@77}

@后面的数字是什么意思?它与hashCode返回的不同。 hashCode以十六进制表示形式返回数字2a134eca,等于整数表示中的705908426。数字77和705908426是不同的。

What does the number after "@" mean? It is different from what hashCode returns. hashCode returns number 2a134eca in hex representation which equals to 705908426 in integer representation. Numbers 77 and 705908426 are distinct.

推荐答案

@是应用程序启动后的对象计数。所以@ 1012表示自应用程序启动以来创建的第1012个对象。

The @ is the object count number since the app started. So @1012 means the 1012th object created since the app started.

这不是身份哈希码。

以下是一些证明:(我说这是因为我实际上并不知道,但我观察到了它)

Here is some proof: (I say this because I don't actually know, but I observed it)

public static void main(String [] args) throws Throwable {

    Object object = new Object();
    Object object1 = new Object();
    Integer foo = new Integer(5);
    Object object2 = new Object();
    String str = new String("bar");

    System.out.println("code :" + System.identityHashCode(object));

    RuntimeException exception = new RuntimeException();
    exception.printStackTrace(); //put breakpoint here


}

输出:
代码:789451787
代码:java.lang.Object@2f0e140b

Output: code :789451787 code :java.lang.Object@2f0e140b

789451787 = 2f0e140b顺便说一句......

789451787=2f0e140b By the way...

IntelliJ调试器的输出:

Output from IntelliJ Debugger:

static = org.boon.core.MyClass
args = {java.lang.String[0]@**97**}
object = {java.lang.Object@**98**}
object1 = {java.lang.Object@**99**}
foo = {java.lang.Integer@**100**}"5"
object2 = {java.lang.Object@**101**}
str = {java.lang.String@**102**}"bar"
exception = {java.lang.RuntimeException@**103**}"java.lang.RuntimeException"

我根据经验知道,但我不知道实际的实现,但我认为它与这样的问题有关:

I know this empirically, but I don't know the actual implementation, but I think it is related to issues like this:

as3:有意义的物体识别调试时。

这篇关于在调试java app时,为堆栈框架中的变量显示了哪些信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆