Akka快速入门:发生了非法的反射访问操作

huangapple go评论92阅读模式
英文:

Akka Quickstart: An illegal reflective access operation has occurred

问题

当在我的 Mac 终端上运行官方的 Akka Quickstart 时,我收到以下错误:

获取 org.scala-sbt sbt 1.2.8 ...
警告:发生了非法的反射访问操作
警告:非法的反射访问来源是 org.apache.ivy.util.url.IvyAuthenticator(文件:/Users/helios/eclipse-workspace/akka-quickstart-java/sbt-dist/bin/sbt-launch.jar),访问了字段 java.net.Authenticator.theAuthenticator
警告:请考虑将此问题报告给 org.apache.ivy.util.url.IvyAuthenticator 的维护者
警告:使用 --illegal-access=warn 以启用进一步的非法反射访问操作警告
警告:在将来的版本中,所有非法访问操作都将被拒绝
reStart

这是否是预期的结果?我应该如何解决这个问题?

英文:

When running the official Akka Quickstart on my Mac terminal, I get this error:

Getting org.scala-sbt sbt 1.2.8 ...
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.ivy.util.url.IvyAuthenticator (file:/Users/helios/eclipse-workspace/akka-quickstart-java/sbt-dist/bin/sbt-launch.jar) to field java.net.Authenticator.theAuthenticator
WARNING: Please consider reporting this to the maintainers of org.apache.ivy.util.url.IvyAuthenticator
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
reStart

Is this the intended result? How can I go about fixing this?

答案1

得分: 4

这是一个警告,而不是错误。

以下是来自Oracle JDK 9迁移指南的引用链接:

> 了解运行时访问警告
>
> 一些工具和库使用反射访问JDK的部分内容,这些内容仅供内部使用。这种非法的反射访问将在JDK的未来版本中被禁用。在JDK 9中,默认情况下是允许的,并且会发出警告。
>
> 例如,以下是启动Jython时发出的警告:
>
> java -jar jython-standalone-2.7.0.jar
> 警告:发生了非法的反射访问操作
> 警告:jnr.posix.JavaLibCHelper(文件:/C:/Jython/jython2.7.0/jython-standalone-2.7.0.jar)对 sun.nio.ch.SelChImpl.getFD() 方法的非法反射访问
> 警告:请考虑向jnr.posix.JavaLibCHelper的维护者报告此问题
> 警告:使用 --illegal-access=warn 以启用进一步的非法反射访问操作警告
> 警告:在未来的版本中,所有的非法访问操作都将被拒绝
> Jython 2.7.0(默认版本:9987c746f838,Apr 29 2015,02:25:11)
>
> 如果您看到这样的警告,请联系工具或库的维护者。 警告的第二行指出了使用反射访问JDK内部部分的确切JAR文件。
>
> 默认情况下,java启动器启动的进程的生命周期内最多会发出一次有关反射访问的警告。警告的确切时机取决于执行反射访问操作的工具和库的行为。警告可能在进程的生命周期早期出现,也可能在启动后很长时间才出现。
>
> 您可以通过使用 --add-opens 命令行标志,按库进行单独禁用警告消息。

英文:

This is a warning, not an error.

Here is a quote from Oracle JDK 9 Migration Guide

https://docs.oracle.com/javase/9/migrate/toc.htm#JSMIG-GUID-7BB28E4D-99B3-4078-BDC4-FC24180CE82B

> Understanding Runtime Access Warnings
>
> Some tools and libraries use reflection to access parts of the JDK that are meant for internal use only. This illegal reflective access will be disabled in a future release of the JDK. In JDK 9, it is permitted by default and a warning is issued.
>
> For example, here is the warning issued when starting Jython:
>
> java -jar jython-standalone-2.7.0.jar
> WARNING: An illegal reflective access operation has occurred
> WARNING: Illegal reflective access by jnr.posix.JavaLibCHelper (file:/C:/Jython/jython2.7.0/jython-standalone-2.7.0.jar) to method sun.nio.ch.SelChImpl.getFD()
> WARNING: Please consider reporting this to the maintainers of jnr.posix.JavaLibCHelper
> 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
> Jython 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11)
>
> If you see a warning like this, contact the maintainers of the tool or library. The second line of the warning names the exact JAR file whose code used reflection to access an internal part of the JDK.
>
> By default, a maximum of one warning about reflective access is issued in the lifetime of the process started by the java launcher. The exact timing of the warning depends on the behavior of tools and libraries performing reflective–access operations. The warning may appear early in the lifetime of the process, or a long time after startup.
>
> You can disable the warning message on a library-by-library basis by using the --add-opens command line flag.

答案2

得分: 0

我也收到了同样的警告,但随后出现了一个空指针异常,指出 "this.text" 为空...很抱歉,我现在没有这个错误了。

我之前使用的是 Java 11,当我切换到 Java 8 后一切正常!

英文:

I had the same warning, but followed with a NullPointerException that "this.text" is null...sorry I do not have the error now

I was on Java 11 and when I switched to Java 8 everything worked!

huangapple
  • 本文由 发表于 2020年9月24日 07:51:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/64037737.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定