什么是sjavac,它是谁,我该如何使用它? [英] What is sjavac, who is it for and how do I use it?

查看:392
本文介绍了什么是sjavac,它是谁,我该如何使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于一个名为的工具的一些嗡嗡声 OpenJDK邮件列表中的 sjavac 。此外,还有两个相关的JEP: JEP 139:增强javac以提高构建速度JEP 199:智能Java编译,第二阶段

There has been some buzz about a tool called sjavac on the OpenJDK mailing lists. Also, there are two related JEPs: JEP 139: Enhance javac to Improve Build Speed and JEP 199: Smart Java Compilation, Phase Two.

我的问题是:


  • sjavac 工具究竟是什么?

  • 谁是谁它打算用于?

  • 如何使用它?

  • What exactly is the sjavac tool?
  • Who is it intended for?
  • How do I use it?

免责声明:自我回答的问题。只是想将此工具的知识带到StackOverflow社区,并创建对未来sjavac FAQ的引用。

推荐答案


什么是sjavac工具?

sjavac 工具是围绕 javac 的(据称是智能)包装器,在Oracle开发并旨在提供以下功能:

The sjavac tool is an (allegedly smart) wrapper around javac, developed at Oracle and intended to provide the following features:


  • 增量编译 - 仅重新编译必要的内容

  • 并行编译 - 在编译期间使用多个核心

  • 将编译器保留在热VM中 - 重用JIT的javac实例进行连续调用

  • incremental compiles - recompile only what's necessary
  • parallel compilation - utilize more than one core during compilation
  • keep compiler in a hot VM - reuse a JIT'ed javac instance for consecutive invocations

重新编译一组源文件时,javac会查看.java的时间戳和.class文件来确定要保留的内容和要重新编译的内容。这非常粗糙,对于大型代码库来说可能是毁灭性的。除了时间戳,sjavac还会检查依赖项的公共API,以判断哪些文件需要重新编译。

When recompiling a set of source files, javac looks at the timestamps of the .java and .class files to determine what to keep and what to recompile. This is incredibly crude and can be devastating for large code bases. In addition to the timestamps sjavac inspects the public API of the dependencies to judge which files need to be recompiled.

Sjavac还尝试将编译拆分为多个javac调用。换句话说,它为构建过程带来了高水平的并行性。

Sjavac also attempts to split up the compilation into multiple invocations of javac. In other words, it brings a high level of parallelism to the build process.

最后,sjavac工具分为客户端部分和服务器部分,允许您让sjavac在后台运行,JIT'并准备连续使用。

Finally, the sjavac tool is split in a client part and a server part which allows you to leave sjavac running in the background, JIT'ed and ready for use in consecutive calls.


它的目的是什么?

我们鼓励那些正在开发大型项目并经常在开发过程中重新编译代码库的人试用 sjavac 。 (请注意,该工具目前正在开发中,但仍存在未解决的问题。)

People who are working on large projects and frequently recompiles the code base during development are encouraged to try out sjavac. (Be aware however that the tool is currently under development and there are still open issues.)


如何使用它?

OpenJDK尚未附带该工具,因此您必须从 OpenJDK jdk9 / dev存储库。此外,还没有启动器,所以你用 java com.sun.tools.sjavac.Main 调用它。

The tool is not yet shipped with the OpenJDK, so you'll have to get it from the OpenJDK jdk9/dev repository. Also, there is no launcher in place yet, so you invoke it with java com.sun.tools.sjavac.Main.

这篇关于什么是sjavac,它是谁,我该如何使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆