debug jdk source can't watch variable what it is
2015-12-07 16:24
417 查看
源地址:http://stackoverflow.com/questions/18255474/debug-jdk-source-cant-watch-variable-what-it-is
Generally speaking, to be able to watch the variables while stepping through JDK source code, you need the class files to be compiled with debug information i.e. compile using
So your best bet is to either find an already compiled version with debug information (I couldn't find anything for JDK 7) or you can try compiling the source for yourself.
According to this post (please note that I haven't tried it) you don't need to compile all
sources, only the ones you need. Putting your newly compiled classes in the
the new classes would be used instead the ones in the original
I believe that should get you started.
Update: Actually I have just tried this process and it is not hard at all. Tested on Windows, JDK 1.7.0_11. All the commands are invoked from command line:
Create your working folder. I chose
folder
Inside your working folder create the source folder i.e.
output folder
From your
get the
and unzip it inside
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
the file
put in the work folder (this is only for convenience to not specify too large file names in the command line).
Execute the command:
the list of all java files that will be compiled. This will be given as input to
Execute
the command:
and will generate a
in your working folder. Check the log contents. You should get a bunch of warnings but no error.
Go inside the
and run the command:
Copy that new jar to the folder
If the
does not exist, create it.
Debug your program in Eclipse. Note how the variables are named normally (no more arg0, arg1 etc). Happy debugging :)
Generally speaking, to be able to watch the variables while stepping through JDK source code, you need the class files to be compiled with debug information i.e. compile using
javac -g.
So your best bet is to either find an already compiled version with debug information (I couldn't find anything for JDK 7) or you can try compiling the source for yourself.
According to this post (please note that I haven't tried it) you don't need to compile all
sources, only the ones you need. Putting your newly compiled classes in the
$jdk/jre/lib/ext/
endorseddirectory,
the new classes would be used instead the ones in the original
rt.jar.
I believe that should get you started.
Update: Actually I have just tried this process and it is not hard at all. Tested on Windows, JDK 1.7.0_11. All the commands are invoked from command line:
Create your working folder. I chose
d:\root
folder
Inside your working folder create the source folder i.e.
jdk7_srcand
output folder
jdk_debug
From your
JDK_HOMEfolder
get the
src.zipfile
and unzip it inside
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).
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
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.
Go inside the
jdk_debugfolder
and run the command:
jar cf0 rt_debug.jar *. This will generate your new runtime library with degug information.
Copy that new jar to the folder
JDK_HOME\jre\lib\endorsed.
If the
endorsedfolder
does not exist, create it.
Debug your program in Eclipse. Note how the variables are named normally (no more arg0, arg1 etc). Happy debugging :)
相关文章推荐
- java笔记-构造函数
- java集合
- 第二篇 虚拟机性能监控与故障处理工具(JDK的命令行工具/JDK的可视化工具)
- Java常见异常总结
- java.io.IOException: tmpFile.renameTo(classFile) failed
- Java中 <? super T>,<? extends T>,和<T>的区别
- 【java基础】Java 中的进程与线程
- Java 多线程 竞争造成的异常
- java中的字符串操作
- [转载]如何使用eclipse 生成runnable jar包
- Java中的数组类Array
- java使用Calendar制作万年历
- java常见错误--Access restriction: The type BASE64Encoder
- 第一个struts2项目
- spring 事务属性
- 利用Java实现文件中的关键字查询
- Eclipse中使用SVN
- Java stack test
- java泛型
- Java基础_02_Java编程基础