在eclipse中调试jdk源码
2014-06-30 18:33
330 查看
1、在eclipse中调试源代码
提示错误:今天想要调试下jdk的源码,结果提示Unable to install breakpoint in javax.xml.parsers.XXX due to missing line number attributes.Modify compiler options to generate line number attributes. Reason:Absent Line Number Information
解决办法:修改eclipse中使用的jre
window-->preferences-->Installed JREs
![](http://img.blog.csdn.net/20140630173959875?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvamluaHVhMTMxNA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
这里使用的jre,要想调试jdk源码,需要修改下Installed JREs为jdk
![](http://img.blog.csdn.net/20140630183038565?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvamluaHVhMTMxNA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
点击OK,然后选中项目,build path,先移除原有jre,然后重新添加jre,默认都会自动选择刚修改的jdk,然后就OK了
参考文章:http://blog.csdn.net/xuefeng0707/article/details/8738869
2、虽然现在可以调试源码了,但是debug时,却发现无法查看变量的值
原因:因为在jdk中,sun对rt.jar中的类编译时,去除了调试信息,这样在eclipse中就不能看到局部变量的值。这样的话,如果在debug的时候查看局部变量,就必须自己编译相应的源码使之拥有调试信息。要达到这个目的,一是找网上人家已经编译好的版本,剩下的只能自己去编译。下面是自己编译的方法:
Create your working folder. I chose
Inside your working folder create the source folder i.e.
From your
Select what you will compile and delete the rest. For all of them you might need additional steps. I have chosen the folders:(选择你将要编译的文件夹,并且删掉其他几个文件夹。因为如果全选的话,你可能需要额外的步骤,这里我选择以下文件夹)
From your
Execute the command:
Execute
Go inside the
Copy that new jar to the folder
如果你是在eclipse中debug的。点击Window->Installed JRES,选择相应的JDK,点击Edit,r然后选择点击Add External jars,选择我们步骤9中目中的rt_debug.jar,就可以了。现在完成了所有的步骤了,赶快尝试debug一下,如果可以查看局部变量了,那么恭喜你成功了。如果还不行,请讲刚刚加入的rt_debug.jar包在上一步中up到最上面,默认Add External jars是加到最后面的
参考文章:http://blog.csdn.net/appleprince88/article/details/21873807
http://stackoverflow.com/questions/18255474/debug-jdk-source-cant-watch-variable-what-it-is
提示错误:今天想要调试下jdk的源码,结果提示Unable to install breakpoint in javax.xml.parsers.XXX due to missing line number attributes.Modify compiler options to generate line number attributes. Reason:Absent Line Number Information
解决办法:修改eclipse中使用的jre
window-->preferences-->Installed JREs
这里使用的jre,要想调试jdk源码,需要修改下Installed JREs为jdk
点击OK,然后选中项目,build path,先移除原有jre,然后重新添加jre,默认都会自动选择刚修改的jdk,然后就OK了
参考文章:http://blog.csdn.net/xuefeng0707/article/details/8738869
2、虽然现在可以调试源码了,但是debug时,却发现无法查看变量的值
原因:因为在jdk中,sun对rt.jar中的类编译时,去除了调试信息,这样在eclipse中就不能看到局部变量的值。这样的话,如果在debug的时候查看局部变量,就必须自己编译相应的源码使之拥有调试信息。要达到这个目的,一是找网上人家已经编译好的版本,剩下的只能自己去编译。下面是自己编译的方法:
Create your working folder. I chose
d:\root folder (创建一个工作目录,比如d:\root)
Inside your working folder create the source folder i.e.
jdk7_srcand output folder
jdk_debug(在工作目录下,创建2个文件夹,比如jdk7_src和jdk_debug)
From your
JDK_HOMEfolder get the
src.zipfile and unzip it inside
jdk7_src(从你的jdk_home目录下将src.zip拷贝并解压到jdk7_src目录)
Select what you will compile and delete the rest. For all of them you might need additional steps. I have chosen the folders:(选择你将要编译的文件夹,并且删掉其他几个文件夹。因为如果全选的话,你可能需要额外的步骤,这里我选择以下文件夹)
java
javax
org
From your
JDK_HOME\jre\libget the file
rt.jarand put in the work folder (this is only for convenience to not specify too large file names in the command line).(从你的
JDK_HOME\jre\lib目录下找到rt.jar,并且将他放在工作目录下,即d:\root目录下(这步只是为了在dos下执行命令时,不用指定太多的文件名,更方便些))
Execute the command:
dir /B /S /X jdk7_src\*.java > filelist.txtto create a file named
filelist.txtwith the list of all java files that will be compiled. This will be given as input to
javac(执行dir /B /S /X jdk7_src\*.java > filelist.txt,该命令会创建一个名为filelist.txt的文件,该文件列出了将要编译的所有java文件,作为执行javac命令的输入参数)
Execute
javacusing the command:
javac -J-Xms16m -J-Xmx1024m -sourcepath d:\jdk7_src -cp d:\rt.jar -d d:\jdk_debug -g @filelist.txt >> log.txt 2>&1This will compile all the files in the
jdk_debugfolder and will generate a
log.txtfile in your working folder. Check the log contents. You should get a bunch of warnings but no error.(用javac执行如下命令:javac -J-Xms...log.txt 2>&1;执行之后,会将所有编译后的文件生成在jdk_debug目录下,同时会在工作目录下生成一个log.txt文件。检视文件的内容,你应该会看到很多警告,但是不会有错误)
Go inside the
jdk_debugfolder and run the command:
jar cf0 rt_debug.jar *. This will generate your new runtime library with degug information.(到jdk_debug目录中去,并且执行
jar cf0 rt_debug.jar *,它将会生成一个新的带有调试信息的运行时lib文件,命名为rt_debug.jar包)
Copy that new jar to the folder
JDK_HOME\jre\lib\endorsed. If the
endorsedfolder does not exist, create it.(拷贝这个新的jar包到
JDK_HOME\jre\lib\endorsed这个目录,如果endorsed无目录不存在,那么自己创建)
如果你是在eclipse中debug的。点击Window->Installed JRES,选择相应的JDK,点击Edit,r然后选择点击Add External jars,选择我们步骤9中目中的rt_debug.jar,就可以了。现在完成了所有的步骤了,赶快尝试debug一下,如果可以查看局部变量了,那么恭喜你成功了。如果还不行,请讲刚刚加入的rt_debug.jar包在上一步中up到最上面,默认Add External jars是加到最后面的
参考文章:http://blog.csdn.net/appleprince88/article/details/21873807
http://stackoverflow.com/questions/18255474/debug-jdk-source-cant-watch-variable-what-it-is
相关文章推荐
- Eclipse调试进入JDK源码
- eclipse如何debug调试jdk源码
- Eclipse在JDK源码中设置断点进行调试报错Unable to install breakpoint的解决方法
- 解决eclipse无法断点调试JDK源码的问题
- 解决Eclipse调试JDK源码无法查看变量值
- eclipse中jdk源码调试步骤
- Eclipse调试进入JDK源码
- Eclipse调试进入JDK源码
- eclipse如何debug调试jdk源码
- Eclipse调试JDK源码看不到变量
- Eclipse调试进入JDK源码
- java -- eclipse如何debug调试jdk源码
- eclipse如何debug调试jdk源码
- 设置Eclipse可以Debug模式调试JDK源码,并显示局部变量的值
- Eclipse调试进入JDK源码
- JDK源码重新编译——支持eclipse调试JDK源码--转载
- eclipse如何debug调试jdk源码
- 如何在eclipse中debug调试进入JDK源码及显示调试过程中的局部变量的值
- eclipse调试jdk源码
- eclipse如何debug调试jdk源码