1

在 MacOS Big Sur (11.4)、最新的 OLP (10.0.9) 和最新的 Java (16.0.1) 下,使用“olp 目录列表”在 akka 中遇到错误。如果切换到 Java 8,同样的命令也可以工作,但这不是重点。根据用户指南 Java 16 应该没问题:

OLP CLI 需要 Java 运行时环境 (JRE) 版本 1.8.0_91 或更高版本。

错误:

$ java --version
openjdk 16.0.1 2021-04-20
OpenJDK Runtime Environment (build 16.0.1+9-24)
OpenJDK 64-Bit Server VM (build 16.0.1+9-24, mixed mode, sharing)

$ olp version show
Version: 10.0.9(727ba090)

$ olp api token get
Token: <XXX>
Token Expires at: 2021-07-03T03:01:21.455Z

$ olp catalog list --profile default
Uncaught error from thread [olp-akka.actor.default-dispatcher-3]: class com.typesafe.sslconfig.ssl.DefaultHostnameVerifier (in unnamed module @0x71e7a66b) cannot access class sun.security.util.HostnameChecker (in module java.base) because module java.base does not export sun.security.util to unnamed module @0x71e7a66b, shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[olp]
java.lang.IllegalAccessError: class com.typesafe.sslconfig.ssl.DefaultHostnameVerifier (in unnamed module @0x71e7a66b) cannot access class sun.security.util.HostnameChecker (in module java.base) because module java.base does not export sun.security.util to unnamed module @0x71e7a66b
        at com.typesafe.sslconfig.ssl.DefaultHostnameVerifier.hostnameChecker(DefaultHostnameVerifier.scala:38)
        at com.typesafe.sslconfig.ssl.DefaultHostnameVerifier.matchCertificates(DefaultHostnameVerifier.scala:77)
        at com.typesafe.sslconfig.ssl.DefaultHostnameVerifier.verify(DefaultHostnameVerifier.scala:51)
        at akka.stream.scaladsl.TLS$.$anonfun$apply$3(TLS.scala:116)
        at akka.stream.impl.io.TLSActor.handshakeFinished(TLSActor.scala:436)
        at akka.stream.impl.io.TLSActor.doUnwrap(TLSActor.scala:399)
        at akka.stream.impl.io.TLSActor.doInbound(TLSActor.scala:295)
        at akka.stream.impl.io.TLSActor.$anonfun$bidirectional$1(TLSActor.scala:230)
        at akka.stream.impl.Pump.pump(Transfer.scala:202)
        at akka.stream.impl.Pump.pump$(Transfer.scala:200)
        at akka.stream.impl.io.TLSActor.pump(TLSActor.scala:50)
        at akka.stream.impl.BatchingInputBuffer.enqueueInputElement(ActorProcessor.scala:96)
        at akka.stream.impl.BatchingInputBuffer$$anonfun$upstreamRunning$1.applyOrElse(ActorProcessor.scala:147)
        at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:38)
        at akka.stream.impl.SubReceive.apply(Transfer.scala:18)
        at akka.stream.impl.FanIn$InputBunch$$anonfun$subreceive$1.applyOrElse(FanIn.scala:242)
        at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:38)
        at akka.stream.impl.SubReceive.apply(Transfer.scala:18)
        at akka.stream.impl.SubReceive.apply(Transfer.scala:14)
        at scala.PartialFunction.applyOrElse(PartialFunction.scala:127)
        at scala.PartialFunction.applyOrElse$(PartialFunction.scala:126)
        at akka.stream.impl.SubReceive.applyOrElse(Transfer.scala:14)
        at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:175)
        at akka.actor.Actor.aroundReceive(Actor.scala:539)
        at akka.actor.Actor.aroundReceive$(Actor.scala:537)
        at akka.stream.impl.io.TLSActor.aroundReceive(TLSActor.scala:50)
        at akka.actor.ActorCell.receiveMessage(ActorCell.scala:614)
        at akka.actor.ActorCell.invoke(ActorCell.scala:583)
        at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:268)
        at akka.dispatch.Mailbox.run(Mailbox.scala:229)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
        at java.base/java.lang.Thread.run(Thread.java:831)
4

3 回答 3

5

更新

该问题已得到修复。从 10.0.36 开始的新版本 CLI 可与 JDK 16 一起正常工作。

从这里下载:https ://platform.here.com/sdk/cli

根本原因

一些工具和库使用反射来访问仅供内部使用的 JDK 部分。这称为非法反射访问,默认情况下在 JDK 16 及更高版本中是不允许的。

默认情况下,使用直接访问 JDK 内部 API 的早期 Java 版本编译的代码不起作用。

java 启动器选项--illegal-access控制宽松的强封装。该选项的默认值为--illegal-access=deny,即禁用非法访问操作。

因此,使用 SDK 16 的 CLI 中与目录相关的命令失败的问题在于,sun.security.*自 JDK 16 以来内部 API 不可用。

这是在 JDK 16 中不起作用的内部 API 表: https ://wiki.openjdk.java.net/display/JDK8/Java+Dependency+Analysis+Tool

默认情况下对 JDK 内部进行强封装:https ://openjdk.java.net/jeps/396

OLP 文档指出,当使用 Java 8 以上时,可能会出现这样的错误: https ://developer.here.com/documentation/java-scala-dev/dev_guide/topics/configure-your-environment.html

解决方法

作为一种解决方法,您可以添加环境变量,

 export _JAVA_OPTIONS="--add-opens=java.base/sun.security.util=ALL-UNNAMED"

或者

 export _JAVA_OPTIONS="--illegal-access=permit" (this parameter is deprecated)

然后所有命令都应该正常工作。

于 2021-07-09T09:46:32.750 回答
1

HERE Workspace lib/sdks/CLI 仅支持 Java 8 。请看,在配置环境中。https://developer.here.com/documentation/java-scala-dev/dev_guide/topics/configure-your-environment.html

于 2021-07-02T13:45:41.437 回答
1

OLP 似乎与 Project Jigsaw 的效果不兼容,它封装了自 Java 9 以来 Java 的内部结构

于 2021-07-02T13:24:04.190 回答