This is an automated email from the ASF dual-hosted git repository. He-Pin pushed a commit to branch refactor/replace-reflection-with-methodhandles in repository https://gitbox.apache.org/repos/asf/pekko-persistence-jdbc.git
commit 30ebc03bfa176430acd29e9190bd6fe11f79477a Author: 虎鸣 <[email protected]> AuthorDate: Mon Jul 6 19:43:52 2026 +0800 refactor: load plugin check class with method handles Motivation: Avoid Class.forName in the JDBC plugin compatibility check. Modification: Use MethodHandles.Lookup.findClass to detect the removed Slick database provider class and keep the existing failure behavior when it is present. Result: The version checker no longer relies on Class.forName for class-presence detection. --- .../apache/pekko/persistence/jdbc/util/PluginVersionChecker.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/main/scala/org/apache/pekko/persistence/jdbc/util/PluginVersionChecker.scala b/core/src/main/scala/org/apache/pekko/persistence/jdbc/util/PluginVersionChecker.scala index f1380956..82271bd3 100644 --- a/core/src/main/scala/org/apache/pekko/persistence/jdbc/util/PluginVersionChecker.scala +++ b/core/src/main/scala/org/apache/pekko/persistence/jdbc/util/PluginVersionChecker.scala @@ -14,17 +14,19 @@ package org.apache.pekko.persistence.jdbc.util +import java.lang.invoke.MethodHandles + import org.apache.pekko.annotation.InternalApi @InternalApi private[jdbc] object PluginVersionChecker { def check(): Unit = try { - Class.forName("org.apache.pekko.persistence.jdbc.util.DefaultSlickDatabaseProvider") + MethodHandles.lookup().findClass("org.apache.pekko.persistence.jdbc.util.DefaultSlickDatabaseProvider") throw new RuntimeException( "Old version of Apache Pekko Persistence JDBC found on the classpath. Remove `com.github.dnvriend:pekko-persistence-jdbc` from the classpath..") } catch { - case _: ClassNotFoundException => + case _: ClassNotFoundException | _: IllegalAccessException => // All good! That's intentional. // It's good if we don't have pekko.persistence.jdbc.util.DefaultSlickDatabaseProvider around } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
