This is an automated email from the ASF dual-hosted git repository.

fanningpj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko.git


The following commit(s) were added to refs/heads/main by this push:
     new cee1ec63df use Scala FunctionConverter (#2274)
cee1ec63df is described below

commit cee1ec63df163cf34aa0bf2f9d4265e84ea0c5af
Author: PJ Fanning <[email protected]>
AuthorDate: Fri Sep 26 12:26:27 2025 +0100

    use Scala FunctionConverter (#2274)
---
 CONTRIBUTING.md                                    |  2 +-
 .../apache/pekko/actor/testkit/typed/Effect.scala  |  2 +-
 .../org/apache/pekko/util/ByteStringSpec.scala     | 13 --------
 ...pport.excludes => function-converters.excludes} | 13 ++------
 .../future-converters.excludes                     |  7 ++--
 .../option-converters.excludes                     | 38 ----------------------
 .../remove-scala-2.12-support.excludes             |  2 +-
 .../main/scala/org/apache/pekko/actor/Actor.scala  |  3 +-
 .../org/apache/pekko/util/FunctionConverters.scala | 30 -----------------
 .../persistence/typed/javadsl/CommandHandler.scala |  3 +-
 .../typed/javadsl/CommandHandlerWithReply.scala    |  3 +-
 .../persistence/typed/javadsl/EventHandler.scala   |  2 +-
 .../typed/state/javadsl/CommandHandler.scala       |  3 +-
 .../state/javadsl/CommandHandlerWithReply.scala    |  3 +-
 .../stream/scaladsl/StreamConvertersSpec.scala     |  2 +-
 15 files changed, 20 insertions(+), 106 deletions(-)

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index b13b179b15..1d8740561b 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -533,7 +533,7 @@ Scala has proven the most viable way to do it, as long as 
you keep the following
 
 1. Use `scala.jdk.javaapi.OptionConverters` to translate `Option`s to Java 
`Optional`s (or vice versa).
 
-1. Use `org.apache.pekko.util.FunctionConverters` to translate Scala Functions 
to Java Functions (or vice versa).
+1. Use `scala.jdk.javapi.FunctionConverters` to translate Scala Functions to 
Java Functions (or vice versa).
  
 1. Make sure there are Java tests or sample code touching all parts of the API
 
diff --git 
a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/Effect.scala
 
b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/Effect.scala
index fdf6c7b6ef..342826dde9 100644
--- 
a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/Effect.scala
+++ 
b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/Effect.scala
@@ -16,11 +16,11 @@ package org.apache.pekko.actor.testkit.typed
 import scala.annotation.nowarn
 import scala.concurrent.duration.FiniteDuration
 import scala.jdk.DurationConverters._
+import scala.jdk.FunctionConverters._
 
 import org.apache.pekko
 import pekko.actor.typed.{ ActorRef, Behavior, Props }
 import pekko.annotation.{ DoNotInherit, InternalApi }
-import pekko.util.FunctionConverters._
 
 /**
  * All tracked effects for the 
[[pekko.actor.testkit.typed.scaladsl.BehaviorTestKit]] and
diff --git 
a/actor-tests/src/test/scala/org/apache/pekko/util/ByteStringSpec.scala 
b/actor-tests/src/test/scala/org/apache/pekko/util/ByteStringSpec.scala
index 020547cea5..4a3044f6ba 100644
--- a/actor-tests/src/test/scala/org/apache/pekko/util/ByteStringSpec.scala
+++ b/actor-tests/src/test/scala/org/apache/pekko/util/ByteStringSpec.scala
@@ -1261,19 +1261,6 @@ class ByteStringSpec extends AnyWordSpec with Matchers 
with Checkers {
     }
 
     "serialize correctly" when {
-      // note that this is serialization with Java serialization
-      // real serialization is in pekko-remote
-      if (util.Properties.versionNumberString.startsWith("2.12")) {
-        "parsing regular ByteString1C as compat" in {
-          val oldSerd =
-            
"aced00057372002d6f72672e6170616368652e70656b6b6f2e7574696c2e42797465537472696e672442797465537472696e67314336e9eed0afcfe4a40200015b000562797465737400025b42787200276f72672e6170616368652e70656b6b6f2e7574696c2e436f6d7061637442797465537472696e67c819c2e689ed6cad0200007870757200025b42acf317f8060854e002000078700000000a74657374737472696e67"
-          val bs = ByteString("teststring", "UTF8")
-          val str = hexFromSer(bs)
-
-          str should be(oldSerd)
-        }
-      }
-
       "given all types of ByteString" in {
         check { (bs: ByteString) =>
           testSer(bs)
diff --git 
a/actor/src/main/mima-filters/2.0.x.backwards.excludes/remove-scala-2.12-support.excludes
 
b/actor/src/main/mima-filters/2.0.x.backwards.excludes/function-converters.excludes
similarity index 57%
copy from 
actor/src/main/mima-filters/2.0.x.backwards.excludes/remove-scala-2.12-support.excludes
copy to 
actor/src/main/mima-filters/2.0.x.backwards.excludes/function-converters.excludes
index 65cfc4c25b..993f2e53d7 100644
--- 
a/actor/src/main/mima-filters/2.0.x.backwards.excludes/remove-scala-2.12-support.excludes
+++ 
b/actor/src/main/mima-filters/2.0.x.backwards.excludes/function-converters.excludes
@@ -15,13 +15,6 @@
 # specific language governing permissions and limitations
 # under the License.
 
-# Remove deprecated method in Scheduler
-ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.compat.PartialFunction")
-ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.compat.PartialFunction$")
-ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.util.ccompat.ccompatUsedUntil213")
-ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.compat.Future")
-ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.compat.Future$")
-ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.util.ccompat.package")
-ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.util.ccompat.package$")
-ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.util.ccompat.package$JavaConverters$")
-ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.util.unused")
+# FunctionConverters was removed - you should use the Scala built-in 
FutureConverters
+ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.util.FunctionConverters")
+ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.util.FunctionConverters$")
diff --git 
a/actor/src/main/mima-filters/2.0.x.backwards.excludes/future-converters.excludes
 
b/actor/src/main/mima-filters/2.0.x.backwards.excludes/future-converters.excludes
index b581880259..9085e7ae7b 100644
--- 
a/actor/src/main/mima-filters/2.0.x.backwards.excludes/future-converters.excludes
+++ 
b/actor/src/main/mima-filters/2.0.x.backwards.excludes/future-converters.excludes
@@ -15,11 +15,8 @@
 # specific language governing permissions and limitations
 # under the License.
 
-# Result of adding the Scala 3 inline keyword, these methods are no longer 
visible as ordinary callable methods
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.FutureConverters#CompletionStageOps.asScala$extension")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.FutureConverters#CompletionStageOps.asScala")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.FutureConverters#FutureOps.asJava$extension")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.FutureConverters#FutureOps.asJava")
+# FutureConverters was removed - you should use the Scala built-in 
FutureConverters
+# Pekko Utils for ExecutionContexts were removed - you should use the Scala 
built-in methods instead
 
ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.util.FutureConverters")
 
ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.util.FutureConverters$")
 
ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.util.FutureConverters$CompletionStageOps")
diff --git 
a/actor/src/main/mima-filters/2.0.x.backwards.excludes/option-converters.excludes
 
b/actor/src/main/mima-filters/2.0.x.backwards.excludes/option-converters.excludes
deleted file mode 100644
index 158ab8a5d9..0000000000
--- 
a/actor/src/main/mima-filters/2.0.x.backwards.excludes/option-converters.excludes
+++ /dev/null
@@ -1,38 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Result of adding the Scala 3 inline keyword, these methods are no longer 
visible as ordinary callable methods
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOption.toJava$extension")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOption.toJavaPrimitive$extension")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOption.toJava")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOption.toJavaPrimitive")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptional.toJavaPrimitive$extension")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptional.toScala$extension")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptional.toScala")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptional.toJavaPrimitive")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalDouble.toJavaGeneric$extension")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalDouble.toScala$extension")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalDouble.toScala")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalDouble.toJavaGeneric")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalInt.toJavaGeneric$extension")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalInt.toScala$extension")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalInt.toScala")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalInt.toJavaGeneric")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalLong.toJavaGeneric$extension")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalLong.toScala$extension")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalLong.toScala")
-ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.util.OptionConverters#RichOptionalLong.toJavaGeneric")
diff --git 
a/actor/src/main/mima-filters/2.0.x.backwards.excludes/remove-scala-2.12-support.excludes
 
b/actor/src/main/mima-filters/2.0.x.backwards.excludes/remove-scala-2.12-support.excludes
index 65cfc4c25b..7d398adb3b 100644
--- 
a/actor/src/main/mima-filters/2.0.x.backwards.excludes/remove-scala-2.12-support.excludes
+++ 
b/actor/src/main/mima-filters/2.0.x.backwards.excludes/remove-scala-2.12-support.excludes
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-# Remove deprecated method in Scheduler
+# Removing Scala 2.12 support allowed us to remove some compatibility classes
 
ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.compat.PartialFunction")
 
ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.compat.PartialFunction$")
 
ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.util.ccompat.ccompatUsedUntil213")
diff --git a/actor/src/main/scala/org/apache/pekko/actor/Actor.scala 
b/actor/src/main/scala/org/apache/pekko/actor/Actor.scala
index 98924ab1e5..feaf70c757 100644
--- a/actor/src/main/scala/org/apache/pekko/actor/Actor.scala
+++ b/actor/src/main/scala/org/apache/pekko/actor/Actor.scala
@@ -92,7 +92,8 @@ final case class ActorIdentity(correlationId: Any, ref: 
Option[ActorRef]) {
   if (ref.isDefined && (ref.get eq null)) {
     throw new IllegalArgumentException(
       "ActorIdentity created with ref = Some(null) is not allowed, " +
-      "this could happen when serializing with Scala 2.12 and deserializing 
with Scala 2.11 which is not supported.")
+      "this could happen when serializing with one version of Scala and 
deserializing with another version. " +
+      "This is unexpected and should be reported to Apache Pekko as a bug.")
   }
 
   /**
diff --git 
a/actor/src/main/scala/org/apache/pekko/util/FunctionConverters.scala 
b/actor/src/main/scala/org/apache/pekko/util/FunctionConverters.scala
deleted file mode 100644
index a5ce72ea9c..0000000000
--- a/actor/src/main/scala/org/apache/pekko/util/FunctionConverters.scala
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.pekko.util
-
-import scala.jdk.Priority0FunctionExtensions
-
-import org.apache.pekko.annotation.InternalStableApi
-
-/**
- * INTERNAL API
- *
- * Remove this once Scala 2.12 support is dropped since all methods are in 
Scala 2.13+ stdlib
- */
-@InternalStableApi
-private[pekko] object FunctionConverters extends Priority0FunctionExtensions
diff --git 
a/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/javadsl/CommandHandler.scala
 
b/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/javadsl/CommandHandler.scala
index 22e25897ac..13862d9e4c 100644
--- 
a/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/javadsl/CommandHandler.scala
+++ 
b/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/javadsl/CommandHandler.scala
@@ -19,9 +19,10 @@ import java.util.function.{ BiFunction, Function => 
JFunction, Predicate, Suppli
 import org.apache.pekko
 import pekko.annotation.InternalApi
 import pekko.persistence.typed.internal._
-import pekko.util.FunctionConverters._
 import pekko.util.OptionVal
 
+import scala.jdk.FunctionConverters._
+
 /**
  * FunctionalInterface for reacting on commands
  *
diff --git 
a/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/javadsl/CommandHandlerWithReply.scala
 
b/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/javadsl/CommandHandlerWithReply.scala
index 0c24bcae36..ed48d4de5e 100644
--- 
a/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/javadsl/CommandHandlerWithReply.scala
+++ 
b/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/javadsl/CommandHandlerWithReply.scala
@@ -19,9 +19,10 @@ import java.util.function.{ BiFunction, Function => 
JFunction, Predicate, Suppli
 import org.apache.pekko
 import pekko.annotation.InternalApi
 import pekko.persistence.typed.internal._
-import pekko.util.FunctionConverters._
 import pekko.util.OptionVal
 
+import scala.jdk.FunctionConverters._
+
 /* Note that this is a copy of CommandHandler.scala to support ReplyEffect
  * s/Effect/ReplyEffect/
  * s/CommandHandler/CommandHandlerWithReply/
diff --git 
a/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/javadsl/EventHandler.scala
 
b/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/javadsl/EventHandler.scala
index b2ed2e322b..9b0b328347 100644
--- 
a/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/javadsl/EventHandler.scala
+++ 
b/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/javadsl/EventHandler.scala
@@ -18,7 +18,7 @@ import java.util.function.{ BiFunction, Function => 
JFunction, Predicate, Suppli
 
 import org.apache.pekko
 import pekko.annotation.InternalApi
-import pekko.util.FunctionConverters._
+import scala.jdk.FunctionConverters._
 import pekko.util.OptionVal
 
 /**
diff --git 
a/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/javadsl/CommandHandler.scala
 
b/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/javadsl/CommandHandler.scala
index a8b592ff3c..27d01c7503 100644
--- 
a/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/javadsl/CommandHandler.scala
+++ 
b/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/javadsl/CommandHandler.scala
@@ -22,9 +22,10 @@ import java.util.function.Supplier
 import org.apache.pekko
 import pekko.annotation.InternalApi
 import pekko.persistence.typed.state.internal._
-import pekko.util.FunctionConverters._
 import pekko.util.OptionVal
 
+import scala.jdk.FunctionConverters._
+
 /**
  * FunctionalInterface for reacting on commands
  *
diff --git 
a/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/javadsl/CommandHandlerWithReply.scala
 
b/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/javadsl/CommandHandlerWithReply.scala
index 67d5103f2d..3e44cadbb7 100644
--- 
a/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/javadsl/CommandHandlerWithReply.scala
+++ 
b/persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/state/javadsl/CommandHandlerWithReply.scala
@@ -22,9 +22,10 @@ import java.util.function.Supplier
 import org.apache.pekko
 import pekko.annotation.InternalApi
 import pekko.persistence.typed.state.internal._
-import pekko.util.FunctionConverters._
 import pekko.util.OptionVal
 
+import scala.jdk.FunctionConverters._
+
 /* Note that this is a copy of CommandHandler.scala to support ReplyEffect
  * s/Effect/ReplyEffect/
  * s/CommandHandler/CommandHandlerWithReply/
diff --git 
a/stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/StreamConvertersSpec.scala
 
b/stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/StreamConvertersSpec.scala
index 4556ea9140..5d164e17fc 100644
--- 
a/stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/StreamConvertersSpec.scala
+++ 
b/stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/StreamConvertersSpec.scala
@@ -45,7 +45,7 @@ class StreamConvertersSpec extends StreamSpec with 
DefaultTimeout {
     import java.util.stream.IntStream
     import java.util.stream.Stream
 
-    import pekko.util.FunctionConverters._
+    import scala.jdk.FunctionConverters._
 
     def javaStreamInts =
       IntStream.iterate(1,


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to