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

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

问题描述

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

我的问题是:

  • sjavac 工具究竟是什么?
  • 它是为谁准备的?
  • 我如何使用它?

免责声明:自行回答的问题.只是想将这个工具的知识带给 StackOverflow 社区,并为未来的 sjavac 常见问题提供参考.

解决方案

sjavac 工具到底是什么?

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

  • 增量编译 - 只重新编译必要的
  • 并行编译 - 在编译期间使用多个内核
  • 将编译器保留在热 VM 中 - 为连续调用重用 JIT 的 javac 实例

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

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

最后,sjavac 工具分为客户端部分和服务器部分,这使您可以让 sjavac 在后台运行、经过 JIT 处理并准备好在连续调用中使用.

<块引用>

它是为谁准备的?

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

<块引用>

我如何使用它?

该工具尚未随 OpenJDK 一起提供,因此您必须从 OpenJDK jdk9/dev 存储库.此外,还没有启动器,因此您可以使用 java com.sun.tools.sjavac.Main 调用它.

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.

My questions are:

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

Disclaimer: Self answered question. Just wanted to bring the knowledge of this tool to the StackOverflow community and to create a reference to future sjavac FAQ.

解决方案

What exactly is the sjavac tool?

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

  • 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

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 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.

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.

Who is it intended for?

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.)

How do I use it?

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天全站免登陆