`
chimae
  • 浏览: 24540 次
最近访客 更多访客>>
社区版块
存档分类
最新评论

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!

分享到:
评论

相关推荐

    rt.jar JDK1.8源码

    JDK动态代理生成字节码,用到了ProxyGenerator.generateProxyClass()方法,这个是rt.jar包中的方法,而安装JDK之后的src.zip没有包含。苦于找不到源码,下载了一个又报错,代码也不全,这里给大家分享一下亲测可用的...

    jdk1.6对应的rt.jar

    rt.jar

    bcprov-jdk15to18-1.69.jar

    bcprov-jdk15to18-1.69.jar bcprov-jdk15to18-1.69.jar bcprov-jdk15to18-1.69.jar bcprov-jdk15to18-1.69.jar bcprov-jdk15to18-1.69.jar bcprov-jdk15to18-1.69.jar bcprov-jdk15to18-1.69.jar bcprov-jdk15to18-...

    rt.jar源码下载 jdk版本jdk7u9

    安装完JDK后,会在%JAVA_HOME% /jdk文件夹下生成一个src.zip,此文件夹对应rt.jar中的java源码,但细心研究后发现rt.jar中sun包下的文件不存在,也就是说sun包下的java源码并没有打包到src.zip中。这个是jdk7u9版本...

    OpenJDK中rt.jar源码文件

    OPENJDK中rt.jar源码,用于个人学习和ECLIPSE查看源码使用

    jdk1.6的rt.jar的源码

    jdk1.6的rt.jar的源码!jdk1.6的rt.jar的源码!

    jdk1.7.0_79 中rt.jar

    jdk1.7.0_79 中rt.jar

    java,jdk中rt.jar包

    支持jdk中的错误解决。在JavaWeb项目中有关错误com.sun.management.OperatingSystemMXBean引入出错时将rt.jar导入到web-inf中就可以了

    jdk1.8 rt.jar 源码

    jdk1.8 rt源码,供查看和学习使用,解压后引入 即可

    jdk11中缺少的几个jar包

    由于jdk版本是11,在配置flutter环境的时候遇到Android license status unknown问题,需要以下这几个jar包。 activation.jar istack-commons-runtime.jar jaxb-api.jar jaxb-core.jar jaxb-impl.jar jaxb-jxc....

    rt.jar源码 完全版

    仅为了方便查看rt.jar包的内容。可自行去下载openjdk的源码也能找到你需要的东西。在openjdk的源码中\openjdk\jdk\src\share\classes目录下即为rt.jar的源码,此文件夹下的源代码是完全的,包括sun包下的java文件。

    jdk8中引入的rt.jar

    jdk8中引入的rt.jar,java.time.、java.util.、java.nio.、java.lang.、java.text.、java.sql.、java.math.*等等都在rt.jar包下

    rt.jar(jdk1.7.0_79+jar1.6.0_10-rc2)

    rt.jar资源包。Java运行环境常用类,里面有很多常用的类。此压缩包含jdk1.7&1.6的rt.jar

    tools.jar(JDK1.6中的tools.jar)

    JDK1.6中的tools.jar //呵呵,今晚JCreator出错无数,检查了好久,才发现原来是我的tools.jar不见了,痛定思痛,决定将其收藏!

    JDK8.0(含tools.jar和dt.jar)

    JDK8.0,含tools.jar和dt.jar,可能直接安装,里面有JRE,只要设置好环境变量,就可以进行开发。

    jdk源码调试重编译rt.jar包

    关于调试jdk源码显示源码变量值的rt.jar重编译包

    新版jdk安装后缺少的tools.jar

    在以前的jdk版本中,只要安装jdk文件就会在本地自动生成jdk和jre两个文件,但是在新的jdk版本中没有自动生成jre文件,也没有tools.jar包。没办法就下载放进去了,不知道有没有其他的办法解决这个问题。

    jdk1.5的rt.jar的源码

    jdk1.5的rt.jar的源码!jdk1.5的rt.jar的源码!jdk1.5的rt.jar的源码!

    JDK tools.jar

    JDK tools.jar

    rt.jar包下载

    Java运行环境常用类

Global site tag (gtag.js) - Google Analytics