Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1906006
  • 博文数量: 219
  • 博客积分: 8963
  • 博客等级: 中将
  • 技术积分: 2125
  • 用 户 组: 普通用户
  • 注册时间: 2005-10-19 12:48
个人简介

文章分类

全部博文(219)

文章存档

2021年(1)

2020年(3)

2015年(4)

2014年(5)

2012年(7)

2011年(37)

2010年(40)

2009年(22)

2008年(17)

2007年(48)

2006年(31)

2005年(4)

分类: Java

2010-11-24 15:41:07

今天以前的同事问我这个问题,我也不知道为什么。
问题是:当DEBUG自己程序的时候,调用了第三方的类库——比如JDK自己的类库——我们有这些类库的源码,进入随源码进入类库后,你会发现代码运行的行会在调试下一步步走,但鼠标指向变量时不再显示变量的值,选中->右键->watch也不能看到变量的值,什么原因?
我以前经常遇到这些问题,但从来没想过为什么不行,以为不是自己的类库就不显示,实际情况并非如此。
于是同事查了一下原因,发给了我,我就直接贴在这儿了。
Debug into rt.jar
August 4th, 2007
If you ever use Eclipse trying to debug into Java’s system APIs, such as java.lang.String or java.math.BigInteger, you may find that even you can step over or step in, or have the correct source file open and the correct line of codes highlighted, you still could not see the local variables’ value and method’s parameters are shown in pattern of “arg0″, “arg1″ and so on.
Yes, you are already using JDK instead of JRE. But you still have the above problem. What’s wrong? It’s not a bug of Eclipse. It is all about the rt.jar along with the JDK (1.5 or 1.6). In Sun’s official JDK release, debug symbols are already packed into the rt.jar. But local variables’ debug information is not packed. Sun may consider that it is not OK to includes those local variables’ debugging information. That is the source of problem.
To solve this problem, you may need to upgrade to JDK 1.6. Download DEBUG jar file from

Double click it to install a new JDK. And configure your Eclipse to use the new JDK.
For JDK 1.5, recompiling rt.jar by yourself, or other information, please visit

for a detailed discussion.
 
这段描述只是针对rt.jar的:上面大概的意思是当rt.jar类库发布时,它们把调试标记打在了JAR包中,但局部变量的DEBUG信息并未打包。他们可能是出于“本地变量的调试信息包含在JAR包中并不好”的考虑,所以没有这么做,这就是问题的根源。
如果你想解决类似问题,你需要专门下载安装带这类信息的JDK......就是重装了JDK啦。
我觉得既然人家发布了,按一般的逻辑就认为它不会有BUG,如果你用了第三方类库,就认为你对它内部的运行方式已经了解,所以你不需要查找别人JAR包的BUG。如果真有BUG并且正好被你运行到了,那你就中奖喽。
阅读(4844) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~