原地址:http://stackoverflow.com/questions/18255474/debug-jdk-source-cant-watch-variable-what-it-is
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_src
and output folderjdk_debug
- From your
JDK_HOME
folder get thesrc.zip
file and unzip it insidejdk7_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\lib
get the filert.jar
and 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.txt
to create a file namedfilelist.txt
with the list of all java files that will be compiled. This will be given as input tojavac
- Execute
javac
using 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>&1
This will compile all the files in thejdk_debug
folder and will generate alog.txt
file in your working folder. Check the log contents. You should get a bunch of warnings but no error. - Go inside the
jdk_debug
folder 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 theendorsed
folder does not exist, create it.
Debug your program in Eclipse. Note how the variables are named normally (no more arg0, arg1 etc). Happy debugging :)