无法检查本地声明的变量 [英] Locally declared variables can not be inspected

查看:28
本文介绍了无法检查本地声明的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,当我在 Eclipse 中调试代码时,虽然我可以毫无困难地查看和检查类成员变量,但我无法检查在函数中本地声明的变量的值.顺便说一句,当前函数的任何参数都失去了它们的真实"名称,而是在变量"窗口中看到它们的值列为 arg0、arg1、arg2 等,但至少这些值是可见的.

Sometimes when I am debugging code in Eclipse it happens that although I can see and inspect class member variables without any difficulty I am unable to inspect the values of variables declared locally within functions. As an aside, any parameters to the current function lose their 'real' names and instead one sees their values listed in the Variables window as arg0, arg1, arg2, etc but at least the values are visible.

这与核心 JDK 中定义的类有关.我已经验证安装的和当前的 JRE 是一个 JDK.

This is occurring at present in relation to classes defined within the core JDK. I have verified that the installed and current JRE is a JDK.

有人能解释一下这种行为吗?

Is anybody able to shed some light on this behaviour?

推荐答案

显然,答案 是:

JDK 附带的 rt.jar(核心 Java 类所在的位置)没有使用 .class 文件中包含的完整调试信息进行编译,因此调试器没有局部变量信息.

the rt.jar that ships with the JDK (where the core Java classes live) is not compiled with full debug information included in the .class files, so the debugger does not have local variable info.

不幸的是,这不是 Eclipse 可以做的任何事情 - 所有调试器都会遇到与 JDK 核心类相同的问题.

Unfortunately, this is not something that Eclipse can do anything about - all debuggers will have the same problem with JDK core classes.

Eclipse 3.4 的发行说明 指出:

缺少调试属性
如果要能够显示行号和局部变量,调试器需要使用调试属性编译类文件.很多时候,类库(例如,rt.jar")在编译时没有完整的调试属性,因此这些类的局部变量和方法参数在调试器中不可见.

Missing debug attributes
The debugger requires that class files be compiled with debug attributes if it is to be able to display line numbers and local variables. Quite often, class libraries (for example, "rt.jar") are compiled without complete debug attributes, and thus local variables and method arguments for those classes are not visible in the debugger.

这篇关于无法检查本地声明的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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