不能使用 Shenandoah GC

Can't use Shenandoah GC

我无法在尝试 运行 Java 应用程序时让 ShenandoahGC 工作。无论我尝试什么,输出如下,当从终端(或 CMD)调用 java 命令时:

Error occurred during initialization of VM

Option -XX:+UseShenandoahGC not supported

运行 在 Ubuntu (WSL) 和 Windows 上打开 JDK 版本 15.0.2,我在两者上都收到相同的消息。

尝试在 -XX:+UseShenandoahGC 旁边应用 -XX:+UnlockExperimentalVMOptions 选项,但据我所知JDK 15.

放弃了实验状态

根据我在这里阅读的内容:What is new in Java 15(第 10 点。JEP 379)Shenandoah GC 未包含在官方 OpenJDK 15 版本中。

简短的回答是 Oracle Java 和官方 OpenJDK 下载站点提供的 OpenJDK Java 构建不包括对 Shenandoah GC 的支持。

但许多其他 Java 12+ 构建的好消息。 AdoptOpenJDK 可以。 RHEL 的 Java 可以。 Ubuntu 的 Java(从包管理器安装)可以。我希望其他人也这样做。


Red Hat 博客上的一篇文章解释了这种情况,摘录如下。

"Not all OpenJDK 12 builds include Shenandoah: Here's why"

日期:2019 年 4 月 19 日

[...]

A little history: Shenandoah, a high-performance low-pause-time garbage collector, is a Red Hat-led project. When we first proposed to contribute Shenandoah to OpenJDK, Oracle made it clear that they didn't want to support it. That's fair enough: OpenJDK is free software, so you don't have to support anything you don't want. We told Oracle that we'd work with them to design a really clean pluggable garbage-collector interface that allows anyone easily to select the garbage collectors to include in their builds. We did that together, and Shenandoah went in to JDK 12.

Evidently Oracle has chosen not to build Shenandoah. They aren't doing anything strictly wrong by excluding it, but something doesn't feel right to me. These builds aren't supported by Oracle—you need their commercial binaries to get support—so why exclude Shenandoah? It might simply be that they used their standard build scripts to build their open source binaries. However, in a rather feature-light OpenJDK release, I find it odd for open source builds to exclude one of the most significant contributions. I really appreciate Oracle providing GPL-licensed OpenJDK builds, but I wish they'd build all of it.

[...]

注意上面的评论不是我的,而是博文作者的评论。