How to debug code from rt.jar with JDK 1.4.1?

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 processin the debug perspective) to make sure that myrt.jar is on the bootclasspath
— if not add myrt.jar to the bootclasspath on thecommmandline in your run configurations: -Xbootclasspath/p:C:dir omyewruntimemyrt.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
JAVA_HOME=/cygdrive/c/j2sdk1.4.1

# Where src.zip was extracted
JAVA_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=$JAVA_HOME/lib/dt.jar$SEP$JAVA_HOME/lib/tools.jar$SEP$JAVA_HOME/li
b/htmlconverter.jar
JAVAC_HOME=$JAVA_HOME/bin

# Loop through each java file in the source dir
cd $JAVA_SOURCE

#${JAVAC_HOME}/javac -classpath `cygpath -wp $CLASSPATH` $OPTIONS
`cygpath -wp ./com/sun/corba/se/ActivationIDL/ActivatorHelper.java`

#/usr/bin/find -name "*.java" | while read JAVA;
#do
# echo $JAVA

# 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 $JAVA | 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
# ${JAVAC_HOME}/javac -classpath `cygpath -wp $CLASSPATH` $OPTIONS
`cygpath -wp $JAVA`
# 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!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值