diff --git a/actor/src/main/scala-jdk-9/org/apache/pekko/dispatch/PekkoJdk9ForkJoinPool.scala b/actor/src/main/scala-jdk-9/org/apache/pekko/dispatch/PekkoJdk9ForkJoinPool.scala index 917b3e6adc5..a115a8e063e 100644 --- a/actor/src/main/scala-jdk-9/org/apache/pekko/dispatch/PekkoJdk9ForkJoinPool.scala +++ b/actor/src/main/scala-jdk-9/org/apache/pekko/dispatch/PekkoJdk9ForkJoinPool.scala @@ -36,7 +36,7 @@ private[dispatch] final class PekkoJdk9ForkJoinPool( unhandledExceptionHandler: Thread.UncaughtExceptionHandler, asyncMode: Boolean) extends ForkJoinPool(parallelism, threadFactory, unhandledExceptionHandler, asyncMode, - 0, maximumPoolSize, 1, null, ForkJoinPoolConstants.DefaultKeepAlive, TimeUnit.MILLISECONDS) + 0, maximumPoolSize, 1, null, ForkJoinPoolConstants.DefaultKeepAliveMillis, TimeUnit.MILLISECONDS) with LoadMetrics { override def execute(r: Runnable): Unit = diff --git a/actor/src/main/scala/org/apache/pekko/dispatch/ForkJoinExecutorConfigurator.scala b/actor/src/main/scala/org/apache/pekko/dispatch/ForkJoinExecutorConfigurator.scala index 65e8dff6641..71d2ffc750b 100644 --- a/actor/src/main/scala/org/apache/pekko/dispatch/ForkJoinExecutorConfigurator.scala +++ b/actor/src/main/scala/org/apache/pekko/dispatch/ForkJoinExecutorConfigurator.scala @@ -19,6 +19,8 @@ import java.lang.invoke.{ MethodHandle, MethodHandles, MethodType } import java.util.concurrent.{ ExecutorService, ForkJoinPool, ForkJoinTask, ThreadFactory } import scala.util.Try +import org.apache.pekko.util.JavaVersion + object ForkJoinExecutorConfigurator { /** @@ -98,12 +100,16 @@ class ForkJoinExecutorConfigurator(config: Config, prerequisites: DispatcherPrer Try(Class.forName("org.apache.pekko.dispatch.PekkoJdk9ForkJoinPool")).toOption private lazy val pekkoJdk9ForkJoinPoolHandleOpt: Option[MethodHandle] = { - pekkoJdk9ForkJoinPoolClassOpt.map { clz => - val methodHandleLookup = MethodHandles.lookup() - val mt = MethodType.methodType(classOf[Unit], classOf[Int], - classOf[ForkJoinPool.ForkJoinWorkerThreadFactory], - classOf[Int], classOf[Thread.UncaughtExceptionHandler], classOf[Boolean]) - methodHandleLookup.findConstructor(clz, mt) + if (JavaVersion.majorVersion == 8) { + None + } else { + pekkoJdk9ForkJoinPoolClassOpt.map { clz => + val methodHandleLookup = MethodHandles.lookup() + val mt = MethodType.methodType(classOf[Unit], classOf[Int], + classOf[ForkJoinPool.ForkJoinWorkerThreadFactory], + classOf[Int], classOf[Thread.UncaughtExceptionHandler], classOf[Boolean]) + methodHandleLookup.findConstructor(clz, mt) + } } } diff --git a/actor/src/main/scala/org/apache/pekko/dispatch/ForkJoinPoolConstants.scala b/actor/src/main/scala/org/apache/pekko/dispatch/ForkJoinPoolConstants.scala index 7643c2d2deb..f7235f608d0 100644 --- a/actor/src/main/scala/org/apache/pekko/dispatch/ForkJoinPoolConstants.scala +++ b/actor/src/main/scala/org/apache/pekko/dispatch/ForkJoinPoolConstants.scala @@ -19,5 +19,5 @@ package org.apache.pekko.dispatch private[dispatch] object ForkJoinPoolConstants { final val MaxCap: Int = 0x7FFF // 32767 - final val DefaultKeepAlive: Long = 60000 + final val DefaultKeepAliveMillis: Long = 60000 }