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

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没有包含。苦于找不到源码,下载了一个又报错,代码也不全,这里给大家分享一下亲测可用的...

    rt.jar源码下载 jdk版本jdk7u9

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

    jdk1.7.0_79 中rt.jar

    jdk1.7.0_79 中rt.jar

    java,jdk中rt.jar包

    在JDK中,`rt.jar`是一个至关重要的文件,它包含了Java标准类库的所有核心类。这个压缩包文件列表中的"rt"很可能就是指的`rt.jar`。 `rt.jar`这个名字是"Runtime"的缩写,顾名思义,它包含了Java运行时环境所需的...

    jdk1.6对应的rt.jar

    rt.jar

    jdk1.8 rt.jar 源码

    在 JDK 1.8 版本中,`rt.jar` 是一个非常重要的文件,它包含了Java标准版(Java SE)的运行时类库。这个库包含了Java API的实现,也就是Java程序员经常使用的各种类和接口,如`java.lang`、`java.util`、`java.io`等...

    OpenJDK中rt.jar源码文件

    OpenJDK中的rt.jar文件是Java运行时库的核心组成部分,包含了Java标准类库(Java Standard Library)的大部分源代码。这个源码包对于开发者来说是一个宝贵的资源,它可以帮助我们深入理解Java API的工作原理,进行...

    src.zip(添加了其他rt.jar缺少的源码)

    rt.jar是Java开发工具(JDK)中的一个核心组件,它包含了Java运行时环境的基础类库,如java.lang、java.io和java.util等包。通常,rt.jar中的源码不包括在内,因为它们是Oracle或OpenJDK的封闭源代码部分。然而,这个...

    jce.jar和rt.jar .zip

    在给定的"jce.jar和rt.jar .zip"压缩包中,包含两个重要的JAR(Java Archive)文件:rt.jar和jce.jar。这两个文件在Java生态系统中扮演着至关重要的角色。 rt.jar,全称Runtime Library JAR,是Java运行时库的集合...

    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-...

    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文件。

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

    rt.jar,全称Runtime Library JAR,是Java开发工具包(JDK)的重要组成部分,尤其在Java 1.7.0_79及1.6.0_10-rc2版本中扮演着核心角色。这个资源包包含了Java运行时环境(JRE)所需的基础类库,使得开发者能够编写出...

    jdk8中引入的rt.jar

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

    jdk8-source(JDK8源码包含rt.jar下所有包)

    jdk8目录下的源码没有rt.jar中的一些包,例如sun包。 在https://download.java.net/openjdk/jdk8/目录下有相关的下载,但是下载太慢(已经下载不到) 这个包不全,暂时关闭

    rt.jar包下载

    这个压缩包文件名为"rt.jar",通常位于JDK或JRE的`lib`目录下。在Java程序执行过程中,无论是系统类加载器还是自定义类加载器,都会用到`rt.jar`中的类来完成各种基本功能。 `rt.jar`包含了以下主要的知识点: 1. ...

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

    这个版本的JDK不仅包括了Java编译器、Java虚拟机(JVM)、Java类库,还特别提到了`tools.jar`和`dt.jar`两个关键文件。这两个文件在Java开发中起着至关重要的作用。 首先,我们来了解一下`tools.jar`。这个文件是...

    jdk1.8重新编译rt_debug.jar(亲测可用)

    jdk1.8重新编译rt_debug.jar(亲测可用)https://blog.csdn.net/cherrycheng_/article/details/51004386 打包步骤

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

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

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

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

Global site tag (gtag.js) - Google Analytics