跳转到内容
主菜单
主菜单
移至侧栏
隐藏
规范/协议
协议
算法
JVM
多线程/并发
存储
AI
深度学习
工具箱
最近更改
文章分类
全部文章
WHY42
搜索
搜索
外观
登录
个人工具
登录
欢迎来到Riguz的小站!这是一个私人wiki,用来记录一些我的笔记。
查看“︁Debug JDK source code”︁的源代码
页面
讨论
大陆简体
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
页面信息
外观
移至侧栏
隐藏
←
Debug JDK source code
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
最近想要直接调试下JDK的源码却发现有些变量不能显示,像这样: [[File:Intellij-no-debuginfo.png|600px|IntelliJ]] 其原因是因为JDK中的rt.jar在release的时候没有附带调试信息。所以解决这个问题的思路是这样的: * 重新编译你想要调试的类(`javac -g`) * 将带调试信息的类覆盖原来的 * 重新进行调试 实际上,在IntelliJ中操作起来可能比较简单,可以分为以下几步: * 将jdk的源码从JDK中拷贝出来,例如/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home/src.zip * 将源码解压,并将其中`java`,`javax`两个文件夹拷贝到一个空的Java工程中 * 编译源码,IntelliJ默认设置编译是包含了调试信息的。编译完成之后,将其[https://www.jetbrains.com/help/idea/packaging-a-module-into-a-jar-file.html# 导出到jar包]中。 * 将导出的jar包(比如说rt_debug.jar)放入到`$JAVA_HOME/jre/lib/endorsed`文件夹下面即可。如果这个目录不存在,手动创建一下。 * 重新进行调试即可。 [[File:Intellij-with-debuginfo.png|600px|IntelliJ]] 事实上,这里利用了`endorsed-standards override mechanism`这一个JVM特性来重载了Java的类,这个特性已经在Java8中被deprecated了([https://www.java.com/en/download/faq/release_changes.xml release notes for Java 8 Update 40 (8u40) ]),但是Java8中仍然可用。 > The endorsed-standards override mechanism and the extension mechanism are deprecated and may be removed in a future release. There are no runtime changes. Existing applications using the 'endorsed-standards override' or 'extension' mechanisms are recommended to migrate away from using these mechanisms. Reference: * [https://stackoverflow.com/questions/1313922/step-through-jdk-source-code-in-intellij-idea Step through JDK source code in IntelliJ IDEA] * [https://stackoverflow.com/questions/18255474/debug-jdk-source-cant-watch-variable-what-it-is debug jdk source can't watch variable what it is]
返回
Debug JDK source code
。
搜索
搜索
查看“︁Debug JDK source code”︁的源代码
添加话题