pekko icon indicating copy to clipboard operation
pekko copied to clipboard

Build Bug: org.apache.pekko.dispatch.PekkoJdk9ForkJoinPool is not on the classpath

Open He-Pin opened this issue 10 months ago • 11 comments

Even the PekkoJdk9ForkJoinPool is on the final result jar, but it does not on the classpath.

How to reproduce:

  1. using Java 21
  2. sbt console
Welcome to Scala 2.13.16 (Java HotSpot(TM) 64-Bit Server VM, Java 21.0.5).

scala> classOf[org.apache.pekko.dispatch.PekkoJdk9ForkJoinPool]
                                         ^
       error: type PekkoJdk9ForkJoinPool is not a member of package org.apache.pekko.dispatch

scala> 

I think that's maybe caused by of the Jdk9.scala

He-Pin avatar Jan 18 '25 01:01 He-Pin

Existing workaround:

https://github.com/apache/pekko/blob/d30e29d1cb71044acfae761632b82eadef0dc060/actor/src/main/scala/org/apache/pekko/dispatch/ForkJoinExecutorConfigurator.scala#L99-L114

pjfanning avatar Jan 18 '25 10:01 pjfanning

The classpath of which module are you referring to?

If this is about actor-tests, perhaps you could use a similar technique as at https://github.com/apache/pekko/blob/main/build.sbt#L419 at https://github.com/apache/pekko/blob/main/build.sbt#L128

raboof avatar Jan 18 '25 10:01 raboof

  1. Start SBT shell with Java 21/23
  2. type console
  3. classOf[org.apache.pekko.dispatch.PekkoJdk9ForkJoinPool, class not found.

OR: When Run a TestJdk9 / testOnly $someJDK21Test on Java 21, and in $someJDK21Test use Class.forName("org.apache.pekko.dispatch.PekkoJdk9ForkJoinPool") , then a ClassNotFoundException throws.

He-Pin avatar Jan 18 '25 10:01 He-Pin

I see no integration test for org.apache.pekko.dispatch.PekkoJdk9ForkJoinPool, which must been tested manually. as the full classpath has no org.apache.pekko.dispatch.PekkoJdk9ForkJoinPool classes, just the product jar, where is the integration test for it @pjfanning ? shouldn't we expect a test for that lives in the scala-jdk9-only folder?

He-Pin avatar Jan 18 '25 10:01 He-Pin

@pjfanning It's not I don't know how to write the code, but with the current setup, it can't be integrated tested, if you add an integration test for org.apache.pekko.dispatch.PekkoJdk9ForkJoinPool and show it works, I'm very happy to follow.

He-Pin avatar Jan 18 '25 10:01 He-Pin

  1. Start SBT shell with Java 21/23

    1. type console

    2. classOf[org.apache.pekko.dispatch.PekkoJdk9ForkJoinPool, class not found.

classOf is a little weird, but testing with Class.forName("org.apache.pekko.dispatch.PekkoJdk9ForkJoinPool"):

indeed the root project does not depend on the individual modules, so that doesn't have PekkoJdk9ForkJoinPool or any other classes on the path.

actor / CompileJdk9 / console does find it, but indeed actor-tests / Test / console does not.

But with the following change to build.sbt:

 lazy val actorTests = pekkoModule("actor-tests")
   .configs(Jdk9.TestJdk9)
-  .dependsOn(testkit % "compile->compile;test->test", actor)
+  .dependsOn(
+    actor % "compile->CompileJdk9;test->test",
+    testkit % "compile->compile;test->test"
+  )

... it should work like I think you expect.

raboof avatar Jan 19 '25 15:01 raboof

Doesn't work too :(

He-Pin avatar Jan 19 '25 15:01 He-Pin

Interesting! In what way does it not work? How are you testing?

raboof avatar Jan 19 '25 15:01 raboof

with sbt console and java 21

I think it's because the result class is not been added to the class path.

He-Pin avatar Jan 19 '25 15:01 He-Pin

with sbt console and java 21

Hmm, that seems to work for me though.

What if you check out https://github.com/raboof/pekko/pull/new/actor-tests-depend-on-jdk9-classes

and then start sbt like this:

$ sbt
[info] welcome to sbt 1.10.7 (N/A Java 21.0.5)
[info] loading global plugins from /home/aengelen/.sbt/1.0/plugins
[info] loading settings for project cell-build from plugins.sbt...
[info] loading project definition from /cell/project
[info] loading settings for project pekko from build.sbt...
[info] resolving key references (70718 settings) ...
[info] Scala 2 optimizer/inliner enabled, to disable set the pekko.no.inline system property
(...)
pekko > actor-tests / Test / console
(...)
scala> Class.forName("org.apache.pekko.dispatch.PekkoJdk9ForkJoinPool")
val res0: Class[_] = class org.apache.pekko.dispatch.PekkoJdk9ForkJoinPool

do you get a different result?

raboof avatar Jan 19 '25 15:01 raboof

The problem seems to happen when using submodules in this repo. If you use a project with a dependency on a pekko-actor snapshot jar or released jar, the class is there and is used if use Java version 11 up. The code is integration tested by our other modules like pekko-http. It would be nice if it was easier to test.

pjfanning avatar Jan 19 '25 16:01 pjfanning