【问题标题】:Java's built-in libraries implementationJava的内置库实现
【发布时间】:2012-04-25 12:12:48
【问题描述】:

如果可能的话,有谁知道我可以在哪里查看 java 内置库的代码?

我已经尝试Ctrl + Shift + B(这是 Netbeans 的 Eclipse 的 Ctrl + Shift T 等价物)“转到源代码”,但我只能看到方法头,而正文始终是:

//compiled code
throw new RuntimeException("Compiled Code");

例如,如果我尝试查看 String.charAt(int),我会看到以下内容

public char charAt(int i)
{
    //compiled code
    throw new RuntimeException("Compiled Code");
}

【问题讨论】:

标签: java shared-libraries built-in


【解决方案1】:

jdk 提供了内置库源代码。例如,在 windows 盒子上,jdk 文件夹将包含 src.zip,其中包含内置库的源代码

希望这会有所帮助。

【讨论】:

    【解决方案2】:

    当然,JDK 是随源码一起分发的,您可以在 IDE 中方便地打开它们。寻找“src.jar”。

    它可能已经设置好了。在 Eclipse 中,只需尝试按 Ctrl-Shift-T 类似“java.lang.String”。

    网络搜索也会出现链接良好且格式正确的页面。

    【讨论】:

    • 我试过Ctrl + Shift + B,这是Netbeans的Ctrl + Shift + T等价物,但我只能看到方法头,其中body是//compiled codethrow new RuntimeException("Compiled Code");
    【解决方案3】:

    谷歌“java反编译器”并下载它。您可以在库中查看任何类文件的源代码。

    【讨论】:

      【解决方案4】:

      你也可以使用jad反编译任何.class文件

      【讨论】:

        猜你喜欢
        • 2021-04-10
        • 2014-01-18
        • 2011-05-25
        • 1970-01-01
        • 1970-01-01
        • 2011-06-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多