JDK/JRE source code with matching JSSE (SSL) source code and matching runnable JDK / JRE?

后端 未结 8 1058
庸人自扰
庸人自扰 2021-02-05 20:30

I have seen Where to find Java 6 JSSE/JCE Source Code? and asked the question myself How to get JRE/JDK with matching source? but I don\'t either of these was specific enough

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-05 20:46

    You can get the source code of JSSE lib (Open JDK implementation) from its mercurial repository following these steps to create a source zip file for attaching to an IDE for debugging.

    1. Get your java build version (in my case the build is 1.8.0_181-b13)

      java -version
      

      Probably you will get a result like this:

      java version "1.8.0_181"
      Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
      
    2. Now we can find the node for our version in this the repository. In my case my tag will be jdk8u181-b13 because my build is 1.8.0_181-b13 and its node will be 0cb452d66676 remember that the java version is jdk8u. We can download the source package by clicking on the "zip" or "gz" links that you see at the left pane and manually repack it as a zip. Or select only the packages you need.

    3. In this example I will download all the packages under the directory classes. To this end, replace the version jdk8u and node 0cb452d66676 in this script to download the source code, and repack it as a src zip file.

      version=jdk8u
      node=0cb452d66676
      mkdir ~/temp
      cd ~/temp
      wget http://hg.openjdk.java.net/$version/$version/jdk/archive/$node.zip/src/share/classes/
      unzip $node.zip -d $version-$node
      cd jdk-$node/src/share/classes/
      zip -r $version-$node-src.zip .
      
    4. Add the source to your IDE and happy coding.

    Notice: In this repository, the available versions are:

    • jdk6
    • jdk7
    • jdk7u
    • jdk8
    • jdk8u
    • jdk9
    • jdk10

提交回复
热议问题