zoukankan      html  css  js  c++  java
  • MacOS 编译 openjdk8 并导入 Clion 调试

    环境准备

    • 安装Xcode11.0,当然也可以是其他版本,尽量超过11.0可以在appstore下载,也可以开发者网址下载:https://developer.apple.com/download/more/

    • 安装xcode-select

      xcode-select install
      
    • 安装mercurial,类似于git可以下载openjdk源码

      brew install mercurial
      
    • 安装freetype,它是一个用C语言实现的一个字体光栅化库。它可以用来将字符栅格化并映射成位图以及提供其他字体相关业务的支持。

      brew install freetype
      

    下载openjdk

    • 下载代码方法一:可以直接在官网下载

       hg clone http://hg.openjdk.java.net/jdk8u/jdk8u60 jdk8u
       cd jdk8u
       sh ./get_source.sh
      
    • 方法二:可以在github上面下载

      git clone https://github.com/dwtfukgv/openjdk-jdk8u jdk8u
      
    • 代码的目录结构如下

      目录 内容
      . 通用配置和生成makefile编译文件,configureMakeFile
      hotspot 用于构建 OpenJDK 虚拟机的源代码和make文件,也就是JVM源码,目录结构后面会介绍。
      langtools JDK提供的开发工具,比如javacjavap等工具,目录结构后面会介绍。
      jdk JDK的源码和用于构建 OpenJDK 运行时库和杂项的make文件,目录结构后面会介绍。
      jaxp JAXP的全称是Java API for XML Processing,是Java定义的一组操作XML文档的API,注意JAXP只是定义了API,并没有提供具体的实现,Java为了保证JAXP能够即装即用,默认带了Apache Xerces 解析器,代码位于jaxp/src/com/sun/org/apache下。目录结构后面会介绍。
      jaxws JAX-WS全称是JavaTM API forXML-Based Web Services, 是一组基于SOAP协议实现的Web Service的API,与之相对的是JAX-RS,全称是JavaTM API for RESTful Webservices,是一组基于RESTful风格的Http服务实现Web Service的API。JAF全称是JavaBeans Activation Framework, JAF的目的在于统一处理不同数据格式的方法(不管数据格式为简单文本还是由图片、声音、视频甚至其它"活动"内容共同组成的复合文档),使得Java对象与编码数据流之间的映射变得非常容易,可以参考JavaMail中JAF的应用。JAX-WS相关代码位于jaxws/src/share/jaxws_classes,目录结构后面会介绍。
      nashorn JDK8内嵌的Nashorn JavaScript 引擎,扩展了JavaJVM上运行动态JavaScript脚本的能力。
      corba CORBA 全称是Common Object Request Broker Architecture,CORBA 1.1 由对象管理组织在 1991 年发布,他定义了接口定义语言(IDL)和应用编程接口(API),从而通过实现对象请求代理(ORB)来激活客户/服务器的交互。CORBA 2.0 于 1994 年的 12 月发布,他定义了如何跨越不同的 ORB 提供者而进行通讯。在功能上基本等同于Web Service。它实现了分布式系统下跨平台,跨语言的数据的传输和远程方法的本地调用。
    • 对环境变量进行设置

      # 设定语言选项,必须设置
      export LANG=C
      # Mac平台,C编译器不再是GCC,而是clang
      export CC=clang
      export CXX=clang++
      export CXXFLAGS=-stdlib=libc++
      # 是否使用clang,如果使用的是GCC编译,该选项应该设置为false
      export USE_CLANG=true
      # 跳过clang的一些严格的语法检查,不然会将N多的警告作为Error
      export COMPILER_WARNINGS_FATAL=false
      # 链接时使用的参数
      export LFLAGS='-Xlinker -lstdc++'
      # 使用64位数据模型
      export LP64=1
      # 告诉编译平台是64位,不然会按照32位来编译
      export ARCH_DATA_MODEL=64
      # 允许自动下载依赖
      export ALLOW_DOWNLOADS=true
      # 并行编译的线程数,编译时长,为了不影响其他工作,可以选择2
      export HOTSPOT_BUILD_JOBS=4
      export PARALLEL_COMPILE_JOBS=4 #ALT_PARALLEL_COMPILE_JOBS=2
      # 是否跳过与先前版本的比较
      export SKIP_COMPARE_IMAGES=true
      # 是否使用预编译头文件,加快编译速度
      export USE_PRECOMPILED_HEADER=true
      # 是否使用增量编译
      export INCREMENTAL_BUILD=true
      # 编译内容
      export BUILD_LANGTOOL=true
      export BUILD_JAXP=true
      export BUILD_JAXWS=true
      export BUILD_CORBA=true
      export BUILD_HOTSPOT=true
      export BUILD_JDK=true
      # 编译版本
      export SKIP_DEBUG_BUILD=true
      export SKIP_FASTDEBUG_BULID=false
      export DEBUG_NAME=debug
      # 避开javaws和浏览器Java插件之类部分的build
      export BUILD_DEPLOY=false
      export BUILD_INSTALL=false
      
      # 最后需要干掉这两个环境变量(如果你配置过),不然会发生诡异的事件
      unset JAVA_HOME
      unset CLASSPATH
      
    • 将环境变量写到一个单独的脚本里,假设是temp.sh,然后使其生效,就在该shell运行编译代码,注意不要使用新的shell窗口

      # 使脚本生效
      source ./temp.sh
      

    编译openjdk

    • 编译命令,当前所在的位置就是所下的openjdk的项目位置,并且要和上一个shell的同一窗口,否则需要重新执行使脚本生效

      bash ./configure --with-debug-level=slowdebug --with-freetype-include=/usr/local/Cellar/freetype/2.10.4/include/freetype2 --with-freetype-lib=/usr/local/Cellar/freetype/2.10.4/lib/ --with-boot-jdk=/Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home --enable-debug-symbols
      
    • 上面代码只需要修改一下--with-freetype-include--with-freetype-lib--with-boot-jdk的位置即可,前两个就是上面所安装的freetype的安装位置,默认应该是我这个位置。

      • --with-boot-jdk是本地jdk的位置,可能版本不太一样,其他的应该是一样的
      • --with-debug-level调试信息的级别,可选值有releasefastdebugslowdebug
    • 其他参数的意思在上面的配置文件里有部分解释,也可以通过sh ./configure --help查看字段意义,也可能看官网的解释:http://hg.openjdk.java.net/jdk8u/jdk8u/raw-file/tip/README-builds.html#configure

    • 出现下面图就成功了。

      ====================================================
      A new configuration has been successfully created in
      /Users/dwtfukgv/ClionProjects/jdk8u/build/macosx-x86_64-normal-server-slowdebug
      using configure arguments '--with-debug-level=slowdebug --with-freetype-include=/usr/local/Cellar/freetype/2.10.4/include/freetype2 --with-freetype-lib=/usr/local/Cellar/freetype/2.10.4/lib/ --with-boot-jdk=/Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home --enable-debug-symbols --with-xcode-path=/Applications/Xcode.app OBJCOPY=gobjcopy'.
      
      Configuration summary:
      * Debug level:    slowdebug
      * JDK variant:    normal
      * JVM variants:   server
      * OpenJDK target: OS: macosx, CPU architecture: x86, address length: 64
      
      Tools summary:
      * Boot JDK:       java version "1.8.0_261" Java(TM) SE Runtime Environment (build 1.8.0_261-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)  (at /Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home)
      * C Compiler:     Apple clang version (clang-1100.0.33.8) version 11.0.0 (clang-1100.0.33.8) (at /usr/bin/clang)
      * C++ Compiler:   Apple clang version (clang-1100.0.33.8) version 11.0.0 (clang-1100.0.33.8) (at /usr/bin/clang++)
      
      Build performance summary:
      * Cores to use:   5
      * Memory limit:   16384 MB
      * ccache status:  not installed (consider installing)
      
      Build performance tip: ccache gives a tremendous speedup for C++ recompilations.
      You do not have ccache installed. Try installing it.
      
    • 进行make操作

      make all
      
    • 成功后会输出下面的信息

      ----- Build times -------
      Start 2021-05-02 22:10:30
      End   2021-05-02 22:11:52
      00:00:00 corba
      00:00:00 demos
      00:00:48 docs
      00:00:12 hotspot
      00:00:18 images
      00:00:00 jaxp
      00:00:00 jaxws
      00:00:02 jdk
      00:00:00 langtools
      00:00:00 nashorn
      00:01:22 TOTAL
      -------------------------
      Finished building OpenJDK for target 'all'
      
    • 最后测试一下java是否已经编译成功

      ./build/macosx-x86_64-normal-server-slowdebug/jdk/bin/java -version
      
    • 输出以下信息就是成功

      openjdk version "1.8.0-internal-debug"
      OpenJDK Runtime Environment (build 1.8.0-internal-debug-dtfukgv_2021_05_02_21_14-b00)
      OpenJDK 64-Bit Server VM (build 25.60-b23-debug, mixed mode)
      

    导入Clion

    • 点击ClionFile | open...找到jdk8u下面的compile_commands.json打开Open as Project,等待Clion建立索引。

      image

    • 建立创建自定义Build Target,点击Clion | Preference... | Build, Execution, Deployment | Custom Build Targets

      image

    • 点击+或者Add target,起个名字,修改BuildClean,添加External Tools

      image

    • BuildClean的参数如下,Working directory是项目的根路径

      image

      image

    • 最终显示画面应该是这样

      image

    • 创建Run/Debug configuration,点击Run | Edit Configurations...,点击+添加一个Custom Build Application如下图

      image

    • 创建Executable,我们可以选择我们编译出来的java,路径应该是./jdk8u/build/macosx-x86_64-normal-server-slowdebug/jdk/bin/java,然后测试一下,给个参数是-version输出java的版本号,如下图

      image

    • 然后点击运行RunClion会重新编译,最后会显示java的版本号,如下图

      image

    • 如果不想每次都重新编译Build可以删除Before launch中的Build操作,Before launch还是在刚才的Run | Edit Configurations...中,可以选择-将其删除,如下图

      image

    • 然后运行Debug可能出现以下错误SIGSEGV (signal SIGSEGV),因为MacOS上面使用lldb,所以需要添加一个配置文件,文件名是.lldbinit,注意该文件是在用户目录下,也就是目录,不要在项目根目录创建。

      image

      # ~/.lldbinit 文件内容
      break set -n main -C "process handle --pass true --stop false SIGSEGV" -C "process handle --pass true --stop false SIGBUS"
      
    • 再次运行Debug就不会出现刚才这个问题了

      !image

    • (可选)如果修改了项目代码,需要重要进行编译,重新生成Compilation Database,如果觉得麻烦可以使用File Watchers进行自动更新,如果需要可以查看文档:https://www.jetbrains.com/help/clion/managing-makefile-projects.html#filewatcher-plugin

    遇到的问题

    • 问题1: 出现Xcode 4 is required to build JDK 8, the version found was 11.0.

      configure: error: Xcode 4 is required to build JDK 8, the version found was 11.0. Use --with-xcode-path to specify the location of Xcode 4 or make Xcode 4 active by using xcode-select.
      configure exiting with result code 1
      

      解决方式:是找到common/autoconf/generated-configure.sh文件,注释以下几行:

      XCODE_VERSION=`$XCODEBUILD -version | grep '^Xcode ' | sed 's/Xcode //'`
          XC_VERSION_PARTS=( ${XCODE_VERSION//./ } )
          if test ! "${XC_VERSION_PARTS[0]}" = "4"; then
            as_fn_error $? "Xcode 4 is required to build JDK 8, the version found was $XCODE_VERSION. Use --with-xcode-path to specify the location of Xcode 4 or make Xcode 4 active by using xcode-select." "$LINENO" 5
          fi
      
    • 问题2: 出现 Unable to find required framework headers, provide a valid path to Xcode 4

      configure: error: Unable to find required framework headers, provide a valid path to Xcode 4 using --with-xcode-path
      configure exiting with result code 1
      

      解决方式:configure时参数添加--with-xcode-path

      --with-xcode-path=/Applications/Xcode.app
      
    • 问题3: 出现Agreeing to the Xcode/iOS license requires admin privileges

      Agreeing to the Xcode/iOS license requires admin privileges, please run “sudo xcodebuild -license” and then retry this command.
      (none, will use system headers and frameworks)
      configure: error: Unable to find required framework headers, provide a valid path to Xcode 4 using --with-xcode-path
      configure exiting with result code 1
      

      解决方式: 执行以下命令

      sudo xcodebuild -license
      # 阅读文档后输入 agree 
      
    • 问题4: 出现GCC compiler is required. Try setting --with-tools-dir.

      configure: The C compiler (located as /usr/bin/clang) does not seem to be the required GCC compiler.
      configure: The result from running with --version was: "Apple clang version 11.0.0 (clang-1100.0.33.8)"
      configure: error: GCC compiler is required. Try setting --with-tools-dir.
      configure exiting with result code 1
      

      解决方式: 是找到common/autoconf/generated-configure.sh文件,注释下面的代码,注意可能里面有多处,同意gcc的版本大于3.81,否则会有问题

      as_fn_error $? "GCC compiler is required. Try setting --with-tools-dir." "$LINENO" 5
      
    • 问题5: 出现Unable to find objcopy, cannot enable debug-symbols

      checking if we should generate debug symbols... configure: error: Unable to find objcopy, cannot enable debug-symbols
      configure exiting with result code 1
      

      解决方式: 需要安装binutils,并且需要在configure时添加参数OBJCOPY

      # 安装 binutils
      brew install binutils
      
      # configure 添加参数
      OBJCOPY=gobjcopy
      
    • 问题6: 出现iostream' file not found

      warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
      warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
      warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
      warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
      Compiling /Users/dwtfukgv/ClionProjects/jdk8u/hotspot/src/share/vm/adlc/dict2.cpp
      In file included from /Users/dwtfukgv/ClionProjects/jdk8u/hotspot/src/share/vm/adlc/arena.c
      pp:25:
      /Users/dwtfukgv/ClionProjects/jdk8u/hotspot/src/share/vm/adlc/adlc.hpp:35:10: fatal error: 'iostream' file not found
      #include <iostream>
      export LANG=C
               ^~~~~~~~~~
      In file included from /Users/dwtfukgv/ClionProjects/jdk8u/hotspot/src/share/vm/adlc/archDesc.cpp:27:
      /Users/dwtfukgv/ClionProjects/jdk8u/hotspot/src/share/vm/adlc/adlc.hpp:35:10: fatal error: 'iostream' file not found
      #include <iostream>
               ^~~~~~~~~~
      In file included from /Users/dwtfukgv/ClionProjects/jdk8u/hotspot/src/share/vm/adlc/dfa.cpp:26:
      /Users/dwtfukgv/ClionProjects/jdk8u/hotspot/src/share/vm/adlc/adlc.hpp:35:10: fatal error: 'iostream' file not found
      #include <iostream>
               ^~~~~~~~~~
      In file included from /Users/dwtfukgv/ClionProjects/jdk8u/hotspot/src/share/vm/adlc/adlparse.cpp:27:
      /Users/dwtfukgv/ClionProjects/jdk8u/hotspot/src/share/vm/adlc/adlc.hpp:35:10: fatal error: 'iostream' file not found
      #include <iostream>
               ^~~~~~~~~~
      warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
      In file included from /Users/dwtfukgv/ClionProjects/jdk8u/hotspot/src/share/vm/adlc/dict2.cpp:27:
      /Users/dwtfukgv/ClionProjects/jdk8u/hotspot/src/share/vm/adlc/adlc.hpp:35:10: fatal error: 'iostream' file not found
      #include <iostream>
               ^~~~~~~~~~
      1 warning and 1 error generated.
      

      解决方式: 下载下面这个依赖并安装

      git clone https://github.com/dwtfukgv/xcode-missing-libstdc-
      cd xcode-missing-libstdc-
      sh ./install.sh
      
    • 问题7: 出现ordered comparison between pointer and zero ('address' (aka 'unsigned char *') and 'int')

      Compiling /Users/dwtfukgv/ClionProjects/jdk8u/hotspot/src/share/vm/opto/live.cpp
      /Users/dwtfukgv/ClionProjects/jdk8u/hotspot/src/share/vm/opto/lcm.cpp:52:35: error: ordered comparison between pointer and zero ('address' (aka 'unsigned char *') and 'int')
        if (Universe::narrow_oop_base() > 0) { // Implies UseCompressedOops.
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
      

      解决方式:if改成下面的代码

      if(Universe::narrow_oop_base() != NULL) {
      
    • 问题8: 出现ordered comparison between pointer and zero ('const TypeInt *' and 'int')

      /Users/dwtfukgv/ClionProjects/jdk8u/hotspot/src/share/vm/opto/loopPredicate.cpp:781:73: error: ordered comparison between pointer and zero ('const TypeInt *' and 'int')
            assert(rng->Opcode() == Op_LoadRange || _igvn.type(rng)->is_int() >= 0, "must be");
                                                    ~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~
      

      解决方式:assert改成下面的代码

       assert(rng->Opcode() == Op_LoadRange || _igvn.type(rng)->is_int() != NULL, "must be");
      
    • 问题9: 出现ordered comparison between pointer and zero ('char *' and 'int')

      Compiling /Users/dwtfukgv/ClionProjects/jdk8u/hotspot/src/share/vm/runtime/vmStructs.cpp
      /Users/dwtfukgv/ClionProjects/jdk8u/hotspot/src/share/vm/runtime/virtualspace.cpp:345:14: error: ordered comparison between pointer and zero ('char *' and 'int')
        if (base() > 0) {
            ~~~~~~ ^ ~
      Compiling /Users/dwtfukgv/ClionProjects/jdk8u/hotspot/src/share/vm/classfile/vmSymbols.cpp
      1 error generated.
      

      解决方式:if改成下面的代码

      if (base() != NULL) {
      
    • 问题10: 出现

      Compiling /Users/dwtfukgv/ClionProjects/jdk8u/hotspot/src/share/vm/utilities/vmError.cpp
      1 error generated.
      gmake[6]: *** [/Users/dwtfukgv/ClionProjects/jdk8u/hotspot/make/bsd/makefiles/rules.make:151: virtualspace.o] Error 1
      gmake[6]: *** Waiting for unfinished jobs....
      4 warnings generated.
      gmake[5]: *** [/Users/dwtfukgv/ClionProjects/jdk8u/hotspot/make/bsd/makefiles/top.make:129: the_vm] Error 2
      gmake[4]: *** [/Users/dwtfukgv/ClionProjects/jdk8u/hotspot/make/bsd/Makefile:290: debug] Error 2
      gmake[3]: *** [Makefile:231: generic_build2] Error 2
      gmake[2]: *** [Makefile:177: debug] Error 2
      gmake[1]: *** [HotspotWrapper.gmk:45: /Users/dwtfukgv/ClionProjects/jdk8u/build/macosx-x86_64-normal-server-slowdebug/hotspot/_hotspot.timestamp] Error 2
      gmake: *** [/Users/dwtfukgv/ClionProjects/jdk8u//make/Main.gmk:109: hotspot-only] Error 2
      

      解决方式:hotspot/make/linux/makefiles/adjust-mflags.sh文件中的内容进行替换,原因是make的版本太高,有些参数有点混用。

      s/ -j([^       ])/ -j -1/
      # 替换为
      s/ -j([^       l])/ -j -1/
      
    • 问题11:

      Undefined symbols for architecture x86_64:
        "_attachCurrentThread", referenced from:
            +[ThreadUtilities getJNIEnv] in ThreadUtilities.o
            +[ThreadUtilities getJNIEnvUncached] in ThreadUtilities.o
      ld: symbol(s) not found for architecture x86_64
      clang: error: linker command failed with exit code 1 (use -v to see invocation)
      gmake[2]: *** [lib/PlatformLibraries.gmk:56: /Users/dwtfukgv/ClionProjects/jdk8u/build/macosx-x86_64-normal-server-slowdebug/jdk/lib/libosxapp.dylib] Error 1
      gmake[2]: *** Waiting for unfinished jobs....
      gmake[1]: *** [BuildJdk.gmk:70: libs-only] Error 2
      make: *** [jdk-only] Error 2
      

      解决方式:./jdk/src/macosx/native/sun/osxapp/ThreadUtilities.m文件中的内容进行修改

      inline void attachCurrentThread(void** env) {
      // 替换为
      static inline void attachCurrentThread(void** env) {
      
    • 问题12: 出现error occurred during error reporting , id 0x4

      openjdk version "1.8.0-internal-debug"
      OpenJDK Runtime Environment (build 1.8.0-internal-debug-dtfukgv_2021_05_02_21_14-b00)
      OpenJDK 64-Bit Server VM (build 25.60-b23-debug, mixed mode)
      #
      # A fatal error has been detected by the Java Runtime Environment:
      #
      #  SIGILL (0x4) at pc=0x0000000110c3ae38, pid=84856, tid=0x0000000000002803
      #
      # JRE version: OpenJDK Runtime Environment (8.0) (build 1.8.0-internal-debug-zhoujunen_2019_11_19_10_28-b00)
      # Java VM: OpenJDK 64-Bit Server VM (25.71-b00-debug mixed mode bsd-amd64 compressed oops)
      # Problematic frame:
      # V  [libjvm.dylib+0xa3ae38]  PerfData::~PerfData()+0x8
      #
      # Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
      #
      # An error report file with more information is saved as:
      # /Users/zhoujunwen/Documents/workspace/jdk8u/hs_err_pid84856.log
      #
      # If you would like to submit a bug report, please visit:
      #   http://bugreport.java.com/bugreport/crash.jsp
      #
      
      [error occurred during error reporting , id 0x4]
      
      [1]    84856 abort      build/macosx-x86_64-normal-server-slowdebug/jdk/bin/java -version
      

      解决方式:hotspot/src/share/vm/runtime/perfData.cpp的内容进行修改,注释掉delete p;这一行,然后重新make all即可。

      void PerfDataManager::destroy() {
      
        if (_all == NULL)
          // destroy already called, or initialization never happened
          return;
      
        for (int index = 0; index < _all->length(); index++) {
          PerfData* p = _all->at(index);
          //delete p;
        }
      
        delete(_all);
        delete(_sampled);
        delete(_constants);
      
        _all = NULL;
        _sampled = NULL;
        _constants = NULL;
      }
      
    • 问题13: 如果编译完成在导入Clion时发现没有compile_commands.json文件

      解决方式: 需要借助一些工具像bear或者compiledb,下面只介绍一种compiledb的方式,推荐使用

      # 安装 compiledb,如果没有 pip 自行安装
      pip install compiledb
      # 构建并使用compiledb工具生成Compilation Database
      compiledb make all COMPILER_WARNINGS_FATAL=false
      # 或者打印详细日志 compiledb make all LOG=debug COMPILER_WARNINGS_FATAL=false
      
    • 问题14: 出现大量的编译警告,如果不想看到可以进行处理,可以通过注释./hotspot/make/bsd/makefiles/gcc.make中的以下代码

      ifneq ($(COMPILER_WARNINGS_FATAL),false)
        WARNINGS_ARE_ERRORS = -Werror
      endif
      
    • 问题15: 出现**clang: error: unknown argument: '-fpch-deps'**,可以通过注释./hotspot/make/bsd/makefiles/gcc.make的以下代码来解决

      ifeq ($(USE_CLANG),)
        ifneq ($(CC_VER_MAJOR), 2)
          DEPFLAGS += -fpch-deps
        endif
      endif
      

    主要目录结构说明

    • jaxp目录结构:

      • jaxpsrcorgw3cdomJAXP支持解析XMLDOM模型代码。
      • jaxpsrcorgxmlsaxJAXP支持解析XMLSAX模型代码。
      • jaxpsrcjavaxxmlstreamJAXP支持解析XMLSTAX模型代码,除了stream目录。
    • jaxws目录结构:

      • jaxwssrcsharejaf_classesJAF的相关代码。
      • jaxwssrcsharejaxws_classescomJDK内部实现使用的类。
      • jaxwssrcsharejaxws_classesjavax是对外暴露的API。
      • jaxwssrcsharejaxws_classescomJDK内部依赖的包。
    • langtools目录结构:

      • src/share/classes/com/sum/javadoc:生成API文档的接口定义,即The Doclet API。
      • src/share/classes/com/sum/source: 解析源码的接口定义。
      • src/share/classes/com/sum/tools/docletsdoclintjavadoc文档生成工具源码。
      • src/share/classes/com/sum/tools/classfile:共用的读取解决classfile的工具源码。
      • src/share/classes/com/sum/tools/javacjavac Java代码编译工具源码。
      • src/share/classes/com/sum/tools/sjavacsjavac Java代码多线程和增量编译工具源码,8中为初版。
      • src/share/classes/com/sum/tools/javahjavah JNI调用中用于生成native接口的头文件的工具源码。
      • src/share/classes/com/sum/tools/javapjavap查看源代码编译后字节码的工具源码。
      • src/share/classes/com/sum/tools/jdepsjdeps查看Java包或者类依赖的工具源码。
      • src/share/classes/javax/lang/model:用于语言建模、语言处理任务和API等。
      • src/share/classes/javax/annotation/process:注解的处理框架 。
    • jdk目录结构:

      ​ 其中aixbsdlinuxmacosxsolariswindows是各平台的特定实现,其中aixbsdlinuxsolaris都是类Unix系统,基本共用solaris的实现。share目录下是平台无关的实现。

      • bin目录是JVM的启动入口。
      • classes目录是JDK源码。
      • native目录是JDK源码中native接口的实现源码。
      • back目录是JDWP(Java Debug Wire Protocol ) Java调试通信协议的实现。
      • transport目录是建立JDWP握手连接相关的实现。
      • instrument目录是javaagent工具即JVMTIAgent的实现。
    • hotspot目录结构:

      hotspot是JVM即JRE Java运行时环境的实现,具体如下:

      ├─agent Serviceability Agent实现,提供HSDB JVM调试工具
      ├─make 编译构建相关代码
      ├─src HotSpot VM的源代码
      │ ├─cpu 不同CPU架构下CPU相关代码(汇编器、模板解释器、ad文件、部分runtime函数在这里实现)
      │ ├─os 不同OS下系统调用相关代码
      │ ├─os_cpu 跟OS和CPU架构相关的系统调用相关的代码,如用户栈操作
      │ └─share 平台无关的共用代码
      │ ├─tools 工具
      │ │ ├─hsdis 反汇编插件,用于查看JIT即时编译器产生的汇编代码
      │ │ ├─IdealGraphVisualizer 将server编译器的中间代码可视化的工具
      │ │ ├─LogCompilation 将-XX:+LogCompilation输出的日志(hotspot.log)整理成更容易阅读的格式的工具
      │ │ └─ProjectCreator 生成Visual Studio的project文件的工具
      │ └─vm HotSpot VM的核心代码
      │ ├─adlc 平台描述文件(上面的cpu或os_cpu里的*.ad文件)的编译器
      │ ├─asm 汇编器接口
      │ ├─c1 client编译器(又称“C1”)
      │ ├─ci 动态编译器
      │ ├─classfile 类文件的处理(包括类加载和系统符号表等)
      │ ├─code 动态生成的代码的管理
      │ ├─compiler 从VM调用动态编译器的接口
      │ ├─gc_implementation GC的实现
      │ │ ├─concurrentMarkSweep Concurrent Mark Sweep GC的实现
      │ │ ├─g1 Garbage-First GC的实现(不使用老的分代式GC框架)
      │ │ ├─parallelScavenge ParallelScavenge GC的实现(server VM默认,不使用老的分代式GC框架)
      │ │ ├─parNew ParNew GC的实现
      │ │ └─shared GC的共通实现
      │ ├─gc_interface GC的接口
      │ ├─interpreter 解释器,包括“模板解释器”(官方版在用)和“C++解释器”(官方版不在用)
      │ ├─libadt 一些抽象数据结构
      │ ├─memory 内存管理相关(老的分代式GC框架也在这里)
      │ ├─oops HotSpot VM的对象系统的实现
      │ ├─opto server编译器(又称“C2”或“Opto”)
      │ ├─prims HotSpot VM的对外接口,包括部分标准库的native部分和JVMTI实现
      │ ├─runtime 运行时支持库(包括线程管理、编译器调度、锁、反射等)
      │ ├─services 主要是用来支持JMX之类的管理功能的接口
      │ ├─shark 基于LLVM的JIT编译器(官方版里没有使用)
      │ └─utilities 一些基本的工具类
      └─test 单元测试

    参考

  • 相关阅读:
    spring mvc valid
    记录一次springmvc 404
    用到的 git 命令
    tomcat java.lang.OutOfMemoryError: PermGen space
    angularjs 表单验证 和 页面初始化闪烁
    在jsp中 EL表达式不生效
    关于jsp中使用jstl的问题
    块级元素,内联元素和定位
    java学习第4天
    STL 常用集合算法
  • 原文地址:https://www.cnblogs.com/dwtfukgv/p/14727290.html
Copyright © 2011-2022 走看看