JDK21 WARNING: A Java agent has been loaded dynamically

这篇具有很好参考价值的文章主要介绍了JDK21 WARNING: A Java agent has been loaded dynamically。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

背景

在做企业微信消息通知的时候,运行项目,出现该警告。

WARNING: A Java agent has been loaded dynamically (D:\maven-repository\net\bytebuddy\byte-buddy-agent\1.14.9\byte-buddy-agent-1.14.9.jar)
WARNING: If a serviceability tool is in use, please run with -XX:+EnableDynamicAgentLoading to hide this warning
WARNING: If a serviceability tool is not in use, please run with -Djdk.instrument.traceUsage for more information
WARNING: Dynamic loading of agents will be disallowed by default in a future release

warning: a java agent has been loaded dynamically,各种各样的问题记录,java,开发语言

解决

warning: a java agent has been loaded dynamically,各种各样的问题记录,java,开发语言

经过

查了一些资料,找到一篇英文的介绍,有想深入的小伙伴可以自己研究下。
这里贴到下面

OpenJDK’s JEP 451: Balancing Serviceability and Integrity in JVM

JEP 451, Prepare to Disallow the Dynamic Loading of Agents( 链接), has been completed from Target status for JDK 21. This JEP has evolved from its original intent to disallow the dynamic loading of agents into a running JVM by default to issue warnings when agents are dynamically loaded into a running JVM. The goals of this JEP include: reassessing the balance between serviceability and integrity; and ensuring that a majority of tools, which do not need to load agents dynamically, are unaffected.
(JEP 451,准备禁止代理的动态加载,已从 JDK 21 的目标状态完成。此 JEP 已从其最初的意图演变而来,即默认不允许将代理动态加载到正在运行的 JVM 中,而是在代理动态加载到正在运行的 JVM 时发出警告。该 JEP 的目标包括:重新评估可维护性和完整性之间的平衡;并确保大多数不需要动态加载代理的工具不受影响。)

The primary goal of this proposal is to prepare for a future release of the JDK that will, by default, disallow the loading of agents into a running JVM. This change is designed to reassess the balance between serviceability, which involves ad-hoc changes to running code, and integrity, which assumes that running code is not arbitrarily changed. It is important to note that the majority of tools, which do not need to load agents dynamically, will remain unaffected by this change.
(该提案的主要目标是为将来的 JDK 版本做准备,默认情况下,该版本将不允许将代理加载到正在运行的 JVM 中。此更改旨在重新评估可维护性(涉及对运行代码的临时更改)和完整性(假定运行代码未被任意更改)之间的平衡。需要注意的是,大多数不需要动态加载代理的工具将不受此更改的影响。)

In JDK 21, the dynamic loading of agents is allowed, but the JVM issues a warning when it occurs. For example:
(在 JDK 21 中,允许动态加载代理,但 JVM 会在发生时发出警告。例如)

WARNING: A Java agent has been loaded dynamically (D:\maven-repository\net\bytebuddy\byte-buddy-agent\1.14.9\byte-buddy-agent-1.14.9.jar)
WARNING: If a serviceability tool is in use, please run with -XX:+EnableDynamicAgentLoading to hide this warning
WARNING: If a serviceability tool is not in use, please run with -Djdk.instrument.traceUsage for more information
WARNING: Dynamic loading of agents will be disallowed by default in a future release

To allow tools to load agents without warnings dynamically, developers must run with the -XX:+EnableDynamicAgentLoading option on the command line.
(要允许工具在没有警告的情况下动态加载代理,开发人员必须在命令行上使用 -XX:+EnableDynamicAgentLoading 选项运行。)

Agents in the Java platform are components that can alter the code of an application while it is running. They were introduced by the Java Platform Profiling Architecture in JDK 5 as a way for tools, notably profilers, to instrument classes. This means altering the code in a class so that it emits events to be consumed by a tool outside the application without otherwise changing the code’s behaviour.
(Java 平台中的代理是可以在应用程序运行时更改其代码的组件。它们是由 JDK 5 中的 Java 平台分析体系结构引入的,作为工具(尤其是分析器)检测类的一种方式。这意味着更改类中的代码,以便它发出事件以供应用程序外部的工具使用,而无需更改代码的行为。)

However, over time, advanced developers found use cases such as Aspect-Oriented Programming that change application behaviour in arbitrary ways. There is also nothing to stop an agent from altering code outside the application, such as code in the JDK itself. To ensure that the owner of an application approved the use of agents, JDK 5 required agents to be specified on the command line with the -javaagent or -agentlib options and loaded the agents immediately at startup. This represented an explicit grant of privileges by the application owner.
(然而,随着时间的流逝,高级开发人员发现了诸如面向方面的编程之类的用例,这些用例会以任意方式改变应用程序行为。也没有什么可以阻止代理更改应用程序外部的代码,例如 JDK 本身中的代码。为了确保应用程序的所有者批准使用代理,JDK 5 要求在命令行上使用 -javaagent 或 -agentlib 选项指定代理,并在启动时立即加载代理。这表示应用程序所有者显式授予特权。)

Serviceability is the ability of a system operator to monitor, observe, debug, and troubleshoot an application while it runs. The Java Platform’s excellent serviceability has long been a source of pride. To support serviceability tools, JDK 6 introduced the Attach API which is not part of the Java Platform but, rather, a JDK API supported for external use. It allows a tool launched with appropriate operating-system privileges to connect to a running JVM, either local or remote, and communicate with that JVM to observe and control its operation.
(可维护性是指系统操作员在应用程序运行时对其进行监视、观察、调试和故障排除的能力。长期以来,Java 平台出色的可维护性一直是我们引以为豪的源泉。为了支持可维护性工具,JDK 6 引入了 Attach API,它不是 Java 平台的一部分,而是支持外部使用的 JDK API。它允许以适当的操作系统权限启动的工具连接到正在运行的 JVM(本地或远程),并与该 JVM 通信以观察和控制其操作。)

However, despite a conceptual separation of concerns between libraries and tools, some libraries provide functionality that relies upon the code-altering superpower afforded to agents. For example, a mocking library might redefine application classes to bypass business-logic invariants, while a white-box testing library might redefine JDK classes so that reflection over private fields is always permitted.
(然而,尽管库和工具之间的关注点在概念上是分开的,但一些库提供的功能依赖于为代理提供的代码更改超级能力。例如,模拟库可能会重新定义应用程序类以绕过业务逻辑不变量,而白盒测试库可能会重新定义 JDK 类,以便始终允许对私有字段进行反射。)

Unfortunately, some libraries misuse dynamically loaded agents, leading to a loss of integrity. They use the Attach API to silently connect to the JVMs in which they run and load agents dynamically, in effect masquerading as serviceability tools. This misuse of dynamically loaded agents by libraries has led to the need for stronger measures to prevent such actions and maintain the integrity of the JVM.
(遗憾的是,某些库滥用了动态加载的代理,导致完整性丧失。它们使用 Attach API 以静默方式连接到运行它们的 JVM,并动态加载代理程序,实际上伪装成可维护性工具。库对动态加载代理的这种滥用导致需要采取更有力的措施来防止此类行为并维护 JVM 的完整性。)

The proposal aims to require the dynamic loading of agents to be approved by the application owner, moving the Java Platform closer to the long-term vision of integrity by default. In practical terms, the application owner will have to choose to allow the dynamic loading of agents via a command-line option.
(该提案旨在要求代理的动态加载必须得到应用程序所有者的批准,从而使 Java 平台更接近默认完整性的长期愿景。实际上,应用程序所有者必须选择允许通过命令行选项动态加载代理。)

The impact of this change will be mitigated by the fact that most modern server applications are designed with redundancy, so individual nodes can be restarted with the command-line option as needed. Special cases, such as a JVM that must never be stopped for maintenance, can typically be identified in advance so that the dynamic loading of agents can be enabled from the start.
(由于大多数现代服务器应用程序都设计有冗余,因此可以根据需要使用命令行选项重新启动单个节点,因此可以减轻此更改的影响。特殊情况,例如永远不能停止维护的 JVM,通常可以提前识别,以便从一开始就启用代理的动态加载。)

This change will allow the Java ecosystem to attain the vision of integrity by default without substantially constraining serviceability. It is a significant step towards ensuring the security and reliability of applications running on the JVM. The proposal is a clear indication of OpenJDK’s commitment to enhancing the integrity of the JVM and ensuring the secure operation of Java applications.
(这一变化将允许 Java 生态系统在默认情况下实现完整性的愿景,而不会严重限制可维护性。这是朝着确保在 JVM 上运行的应用程序的安全性和可靠性迈出的重要一步。该提案清楚地表明了 OpenJDK 致力于增强 JVM 的完整性并确保 Java 应用程序的安全运行。)文章来源地址https://www.toymoban.com/news/detail-766755.html

参考文章

  • https://www.infoq.com/news/2023/07/jep-451-balancing-serviceability/#:~:text=To%20allow%20tools%20to%20load%20agents%20without%20warnings,code%20of%20an%20application%20while%20it%20is%20running.

到了这里,关于JDK21 WARNING: A Java agent has been loaded dynamically的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Unity寻路报错“SetDestination“ can only be called on an active agent that has been placed on a NavMesh.

    这个报错表示NavMeshAgent所在节点未放置在寻路网格上。出现这个错误一般伴有 \\\"Failed to create agent because it is not close enough to the NavMesh\\\"类似警告。 表明寻路代理创建失败,后续设置目的地肯定就会导致失败。 出现此类问题需要检查: 在调用SetDestination的时候,NavMeshAgent是否启用

    2023年04月08日
    浏览(45)
  • QMimeDatabase: Error loading internal MIME data An error has been encountered at line 1 of <internal

    QMimeDatabase: Error loading internal MIME data An error has been encountered at line 1 of : Premature end of document.: Traceback (most recent call last): File “D:anacondalibsite-packageslibscanvas.py”, line 530, in paintEvent p.drawLine(self.prev_point.x(), 0, self.prev_point.x(), self.pixmap.height()) TypeError: arguments did not match any overlo

    2024年02月06日
    浏览(49)
  • java.lang.IllegalStateException: Illegal access: this web application instance has been stopped

    java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already.  Could not load [org.apache.logging.log4j.core.impl.Log4jLogEvent$Builder]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access. 部署web项目出现在这个问题,其

    2024年02月16日
    浏览(39)
  • has been compiled by a more recent version of the Java Runtime

    has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 在导入gradle项目时,需要将jdk调整到对应的版本,参考下面的对应关系:

    2024年01月18日
    浏览(49)
  • JDK21:Java21的新特性

    定于9月推出的Java21计划现在包括一个关键封装机制API和32位Windows端口的弃用。 Java开发工具包(JDK)21将于9月作为Oracle标准Java实现的下一个长期支持版本,现在有13个功能被正式提出,最近几天又增加了两个功能。 最新的提议包括密钥封装机制(KEM)API和32位x86 Windows端口的

    2024年02月07日
    浏览(44)
  • 解决java.lang.IllegalStateException: Cannot call sendError() after the response has been committed异常

    相信大家自己在用spring boot写restful风格的接口时特别是写文件下载或文件导出时会碰到java.lang.IllegalStateException: Cannot call sendError() after the response has been committed这样的bug,很多人可能一脸困惑,就好奇为什么我文件都已经可以正常导出了,为什么在日志中还是会出现这样的报错

    2024年02月16日
    浏览(44)
  • java JDK(21)安装

    地址:https://www.oracle.com/ 打开后往下滑找到: 傻瓜式向下执行安装即可 注意:cmd跳转到java安装路径运行以下指令安装jre 4 测试是否安装成功 cmd内运行

    2024年02月22日
    浏览(43)
  • warning: ignoring JAVA_HOME=D:\JDK; using bundled JDK报错解决

    warning: ignoring JAVA_HOME=D:JDK; using bundled JDK报错原因是因为你JDK版本太低或者你的ElasticSearch版本太高降低版本即可、 我的是JDK1.8我下载的是 elasticsearch-8.7.0 改成 elasticsearch-7.6.1 就可以了 elasticsearch-7.6.1 地址:弹性搜索 7.6.1 |弹性的 (elastic.co) 历史版本:Past Releases of Elastic Stack

    2024年02月11日
    浏览(63)
  • 报错——warning: ignoring JAVA_HOME=/home/jdk/jdk1.8.0_281; using bundled JDK

    我使用了es的8.3.0版本,但es从7.17版本以后不再支持jdk1.8了,需要进行JDK的版本升级,或者降低es的版本。 es和jdk对比版本

    2024年02月07日
    浏览(50)
  • 【java】JDK21 要来了

    不过多久,JDK 21 马上就出来了,看来 Java 这几年真的是长进了。 目前 Java 的最新稳定版是 JDK 20,但这是个过渡版,JDK21就是 LTS 版的了,也快要发布了,在今年9月份(也就是2023年9月)就要正式发布了。 但是,猜都不用猜,你肯定还在用 Java 8 吧! 如果说之前的 JDK17你还觉

    2024年02月10日
    浏览(51)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包