gpt4 book ai didi

java - JDK9 : An illegal reflective access operation has occurred. org.python.core.PySystemState

转载 作者:IT老高 更新时间:2023-10-28 20:41:34 25 4
gpt4 key购买 nike

我正在尝试使用 Java9 (JDK9) 运行 DMelt 程序 (http://jwork.org/dmelt/) 程序,它给了我以下错误:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.python.core.PySystemState (file:/dmelt/jehep/lib/jython/jython.jar) to method java.io.Console.encoding()
WARNING: Please consider reporting this to the maintainers of org.python.core.PySystemState
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

我该如何解决?我试图将 –illegal-access=permit 添加到脚本“dmelt.sh”的最后一行(我在 Linux 中使用 bash),但这并没有解决这个问题。我对此感到非常沮丧。我经常使用这个程序,很长一段时间。也许我永远不应该迁移到 JDK9

最佳答案

解决这个问题的理想方法是

reporting this to the maintainers of org.python.core.PySystemState

并要求他们在未来修复此类反射访问。


If the default mode permits illegal reflective access, however, thenit's essential to make that known so that people aren't surprised whenthis is no longer the default mode in a future release.

来自 threads on the mailing list 之一:

--illegal-access=permit

This will be the default mode for JDK 9. It opens every package inevery explicit module to code in all unnamed modules, i.e., code onthe class path, just as --permit-illegal-access does today.

The first illegal reflective-access operation causes a warning to beissued, as with --permit-illegal-access, but no warnings are issuedafter that point. This single warning will describe how to enablefurther warnings.

--illegal-access=deny

This disables all illegal reflective-access operations except forthose enabled by other command-line options, such as --add-opens.This will become the default mode in a future release.

像以前一样,明智地使用 --add-exports 可以避免任何模式下的警告消息。和 --add-opens选项。


因此,当前可用的临时解决方案是使用 --add-exports作为 docs 中提到的 VM 参数:

--add-exports module/package=target-module(,target-module)*

Updates module to export package to target-module, regardless ofmodule declaration. The target-module can be all unnamed to export toall unnamed modules.

这将允许 target-module访问 package 中的所有公共(public)类型.如果您想访问仍将被封装的 JDK 内部类,则必须使用 --add-opens 允许 深度反射论据为:

--add-opens module/package=target-module(,target-module)*

Updates module to open package to target-module, regardless of moduledeclaration.

在您的情况下,当前访问 java.io.Console ,您可以简单地将其添加为 VM 选项 -

--add-opens java.base/java.io=ALL-UNNAMED

另外,请注意上面链接的同一线程

deny成为默认模式,然后我希望 permit至少支持一个版本,以便开发人员可以继续迁移他们的代码。 permit , warn , 和 debug随着时间的推移,模​​式将被删除,--illegal-access 也将被删除。选项本身。

所以最好改变实现并遵循理想的解决方案。

关于java - JDK9 : An illegal reflective access operation has occurred. org.python.core.PySystemState,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46230413/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com