How to debug code from rt.jar with JDK 1.4.1?
2005-04-15 10:17
495 查看
blocnjbb.oA: If you want to debug code from rt.jar you will get some information like "can't debug - absent line information."
This small howto will tell you how.
Create your own rt.jar (myrt.jar)
— create a directory (newruntime) with a src directory
— unzip the jdk source into the src directory
— create a new java project with the project contents directory newruntime
— let it compile - takes a while
— export as a jar file Create a new JRE configuration
— Prefrences >> Java >> Installed JREs >> Add
— Browse to the usual JRE home directory
— uncheck "use default system libraries"
— add myrt.jar as an external jar above rt.jar Verify
—
While debuging check the command line ("Properties" page of the process
in the debug perspective) to make sure that myrt.jar is on the boot
classpath
— if not add myrt.jar to the bootclasspath on the
commmandline in your run configurations: -Xbootclasspath/p:C:dir omy
ewruntimemyrt.jar .
And another answer:
For the interested here a step-by-step explanation with script:
(1) The bottom line is:
* get the JDK source (i did it with version 1.4.1)
* get the original rt.jar for the same version
* unzip the rt.jar into a directory OriginalRT
* unzip the JDK source into a directory RTSource
(2) Now the fun starts:
* delete all files from RTSource that are NOT contained in OriginalRT
(apparently old classes, they do not compile ...)
* compile the rest of the java files in RTSource with the "generate debug
information" flag (and the RTSource directory, dt.jar, tools.jar and
htmlconverter.jar in the classpath)
* copy all compiled classes that are in OriginalRT but not in RTSource into
the corresponding place in RTSource
* jar RTSource into a file rt_debug.jar
* use rt_debug.jar instead of rt.jar in your classpath -> et voila!
I found a cygwin script on the web doing all the things described in (2),
here it is in case you want to use it (thanks to the original creator of the
script!):
#!/bin/sh
# Change these four paths = as required
# Base dir
J***A_HOME=/cygdrive/c/j2sdk1.4.1
# Where src.zip was extracted
J***A_SOURCE=/cygdrive/c/JavaSourceCompile/RTSource
# Where rt.jar was extracted
RT_CLASSES=/cygdrive/c/JavaSourceCompile/OriginalRT
# Where to put the compiled classes
OUT_DIR=/cygdrive/c/JavaSourceCompile/RTSource
# These are the required options for javac, do not change
OPTIONS="-g -nowarn -sourcepath . -d `cygpath -wp $OUT_DIR` -source
1.4 -target 1.4"
SEP=";"
CLASSPATH=$J***A_HOME/lib/dt.jar$SEP$J***A_HOME/lib/tools.jar$SEP$J***A_HOME/li
b/htmlconverter.jar
J***AC_HOME=$J***A_HOME/bin
# Loop through each java file in the source dir
cd $J***A_SOURCE
#${J***AC_HOME}/javac -classpath `cygpath -wp $CLASSPATH` $OPTIONS
`cygpath -wp ./com/sun/corba/se/ActivationIDL/ActivatorHelper.java`
#/usr/bin/find -name "*.java" | while read J***A;
#do
# echo $J***A
# Is this file part of rt.jar, or is it an obsolete source file
# eg = com/sun/corba/se/internal/Interceptors/ThreadCurrentStack.java
# CLASS=`echo $J***A | sed "s/.java/.class/g"`
# echo ${RT_CLASSES}/${CLASS}
# if [ -e ${RT_CLASSES}/${CLASS} ];
# then
# # Has this file already been compiled
# if [ -e ${OUT_DIR}/${CLASS} ];
# then
# echo Already compiled.
# else
# ${J***AC_HOME}/javac -classpath `cygpath -wp $CLASSPATH` $OPTIONS
`cygpath -wp $J***A`
# fi
# else
# echo Obsolete source file.
# fi
#done
# Now check for any files that are in rt.jar but not src.zip
cd $RT_CLASSES
/usr/bin/find . -type f | while read CLASS;
do
if [ ! -f ${OUT_DIR}/${CLASS} ]; then
echo Not found : $CLASS
# Uncomment this once the script has been run and all classes have
successfully compiled
# cp --parents $CLASS $OUT_DIR
fi
done
That runs for a while, because it's quite some amount of classes - but it
works!
This small howto will tell you how.
Create your own rt.jar (myrt.jar)
— create a directory (newruntime) with a src directory
— unzip the jdk source into the src directory
— create a new java project with the project contents directory newruntime
— let it compile - takes a while
— export as a jar file Create a new JRE configuration
— Prefrences >> Java >> Installed JREs >> Add
— Browse to the usual JRE home directory
— uncheck "use default system libraries"
— add myrt.jar as an external jar above rt.jar Verify
—
While debuging check the command line ("Properties" page of the process
in the debug perspective) to make sure that myrt.jar is on the boot
classpath
— if not add myrt.jar to the bootclasspath on the
commmandline in your run configurations: -Xbootclasspath/p:C:dir omy
ewruntimemyrt.jar .
And another answer:
For the interested here a step-by-step explanation with script:
(1) The bottom line is:
* get the JDK source (i did it with version 1.4.1)
* get the original rt.jar for the same version
* unzip the rt.jar into a directory OriginalRT
* unzip the JDK source into a directory RTSource
(2) Now the fun starts:
* delete all files from RTSource that are NOT contained in OriginalRT
(apparently old classes, they do not compile ...)
* compile the rest of the java files in RTSource with the "generate debug
information" flag (and the RTSource directory, dt.jar, tools.jar and
htmlconverter.jar in the classpath)
* copy all compiled classes that are in OriginalRT but not in RTSource into
the corresponding place in RTSource
* jar RTSource into a file rt_debug.jar
* use rt_debug.jar instead of rt.jar in your classpath -> et voila!
I found a cygwin script on the web doing all the things described in (2),
here it is in case you want to use it (thanks to the original creator of the
script!):
#!/bin/sh
# Change these four paths = as required
# Base dir
J***A_HOME=/cygdrive/c/j2sdk1.4.1
# Where src.zip was extracted
J***A_SOURCE=/cygdrive/c/JavaSourceCompile/RTSource
# Where rt.jar was extracted
RT_CLASSES=/cygdrive/c/JavaSourceCompile/OriginalRT
# Where to put the compiled classes
OUT_DIR=/cygdrive/c/JavaSourceCompile/RTSource
# These are the required options for javac, do not change
OPTIONS="-g -nowarn -sourcepath . -d `cygpath -wp $OUT_DIR` -source
1.4 -target 1.4"
SEP=";"
CLASSPATH=$J***A_HOME/lib/dt.jar$SEP$J***A_HOME/lib/tools.jar$SEP$J***A_HOME/li
b/htmlconverter.jar
J***AC_HOME=$J***A_HOME/bin
# Loop through each java file in the source dir
cd $J***A_SOURCE
#${J***AC_HOME}/javac -classpath `cygpath -wp $CLASSPATH` $OPTIONS
`cygpath -wp ./com/sun/corba/se/ActivationIDL/ActivatorHelper.java`
#/usr/bin/find -name "*.java" | while read J***A;
#do
# echo $J***A
# Is this file part of rt.jar, or is it an obsolete source file
# eg = com/sun/corba/se/internal/Interceptors/ThreadCurrentStack.java
# CLASS=`echo $J***A | sed "s/.java/.class/g"`
# echo ${RT_CLASSES}/${CLASS}
# if [ -e ${RT_CLASSES}/${CLASS} ];
# then
# # Has this file already been compiled
# if [ -e ${OUT_DIR}/${CLASS} ];
# then
# echo Already compiled.
# else
# ${J***AC_HOME}/javac -classpath `cygpath -wp $CLASSPATH` $OPTIONS
`cygpath -wp $J***A`
# fi
# else
# echo Obsolete source file.
# fi
#done
# Now check for any files that are in rt.jar but not src.zip
cd $RT_CLASSES
/usr/bin/find . -type f | while read CLASS;
do
if [ ! -f ${OUT_DIR}/${CLASS} ]; then
echo Not found : $CLASS
# Uncomment this once the script has been run and all classes have
successfully compiled
# cp --parents $CLASS $OUT_DIR
fi
done
That runs for a while, because it's quite some amount of classes - but it
works!
相关文章推荐
- How to debug test code on Windows Mobile Emulator with Visual Studio
- How to debug an Angular 2 application with Chrome and VS Code
- How to Work with the Network from the Linux Terminal
- How to create physical standby database with 11g RMAN DUPLICATE FROM ACTIVE DATABASE [ID 747250.1]
- How to attach JDK source code in Eclipse?
- how to debug smarty with firebug
- How Can One Transfer Xcode 4 Code Snippets from One Machine to Another
- Ten things to do with IIS(From CodeProject website)
- How to download codes from Google Code
- HOW TO REMOTELY DEBUG APPLICATION RUNNING ON TOMCAT FROM WITHIN INTELLIJ IDEA
- How to make a callback to C# from C/C++ code
- How to compile and debug VLC player source code in eclipse IDE on Ubuntu 10.04 (lucid)
- How to make Office VBA code interact with a VSTO application-level add-in
- How to equip Linux with JDK
- How to run debug SQL with in front end(EBS)?
- How to create a DLL with SWIG from Visual Studio 2010
- How To Install LAMP From Source Code
- How To Debug Web Applications With Firefox
- How to debug ASP.NET MVC using source code
- Units Problem: How to read text size as custom attr from xml and set it to TextView in java code