如何在 Java 11 调试期间避免 "Sharing is only supported for boot loader classes because bootstrap classpath has been appended" 警告?

How to avoid "Sharing is only supported for boot loader classes because bootstrap classpath has been appended" warning during debug with Java 11?

最近我切换到 Java 11 并开始调试我的应用程序并看到此消息:

OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended

仅找到 this commit and ticket,但它告诉我的不多。

我需要担心吗?

对我来说,只有当我在 Docker 中 运行 以及当我使用 java 命令行代理(如 DataDog APM 代理)(-javaagent:/dd-java-agent.jar ). 当我 运行 在我的 JDK11 运行时环境中(没有代理)我没有收到警告。

我在安装 Java12 后尝试将调试器与 Intellij Idea 一起使用时遇到了这个问题。我找到的解决方案是进入设置并搜索异步并取消选中 Instrumenting 代理框。

我在安装 jdk-12.0.1_windows-x64_bin.zip 后尝试将调试器与 IntelliJ IDEA 一起使用时也遇到了这个问题。我收到错误消息 (Java HotSpot(TM) 64 位服务器 VM 警告:仅支持引导加载程序 类 共享,因为已附加 bootstrap 类路径)。我也发现,进入设置并搜索异步并取消选中 Instrumenting 代理框。为我工作!

您可以忽略此警告。这只是意味着 class 数据共享对于未被 bootstrap class 加载器加载的 classes 禁用。

来自Improve Launch Times […] With Application Class-Data Sharing

The JVM loads some of the JDK classes with the bootstrap class loader and the rest with the system class loader, but includes all of them in its default archive. When IntelliJ executes your project, it tells the JVM to load some code with the bootstrap class loader by appending to that class path (second part of the message). Now, that means that the portion of the archive that contains classes loaded by the system class loader is potentially invalidated and so the JVM partially deactivates sharing (first part of the message).

您可以完全禁用 class 与 -Xshare:off 的数据共享,但会损失一些性能。

Java 版本必须为 9 或更高。

对于 Intellij IDE -> Settings/Preferences 对话框 ( Ctrl+Alt+S ),转到构建 |执行 |部署 |调试器 |异步 -> 取消选中检测代理

今天我发现了和你一样的问题。 情况:在未设置断点的情况下进行调试 解决方法:在点击调试按钮之前至少设置一个断点!

如果不是很重要,您可以更改 jdk 版本。我已经从 jdk14 更改为 jdk11。希望它对你有用。

1.Open 首选项 选项;

2.Find 构建、执行、部署 选项;

3.Enter 调试器 --> 异步堆栈跟踪 ;

4.Uncheck 检测代理(需要重新启动调试器) ;


请看这个for detailed information

您必须将红点放在要进行调试的代码行的左侧。 如果不是,你会在 IntelliJ

上得到这个按摩

遇到了同样的问题,并尝试按照上面的方法解决它。

但后来我在不更改设置的情况下得到了另一个问题解决方案。

在您设置断点并要调试的文件上按鼠标右键。然后选择“调试你的文件name.method()”。

不要使用工具 window 中的调试按钮。看来问题是Idea无法理解你要调试哪个文件。

这对我有用,无需更改异步设置。

Screenshot

遇到了同样的问题,并尝试按照上面所有方法写的来解决它。

但是,我仍然无法调试我的文件,唯一的原因是在调试您的程序之前,您需要设置调试点,直到我们要调试的点。所以只要点击图中所示的地方,设置调试点,我们的程序就可以轻松调试了。没有做任何其他事情。 enter image description here