You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pekko.apache.org by he...@apache.org on 2026/07/06 11:44:59 UTC

(pekko-persistence-jdbc) branch refactor/replace-reflection-with-methodhandles created (now 30ebc03b)

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

He-Pin pushed a change to branch refactor/replace-reflection-with-methodhandles
in repository https://gitbox.apache.org/repos/asf/pekko-persistence-jdbc.git


      at 30ebc03b refactor: load plugin check class with method handles

This branch includes the following new commits:

     new 30ebc03b refactor: load plugin check class with method handles

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org


(pekko-persistence-jdbc) 01/01: refactor: load plugin check class with method handles

Posted by he...@apache.org.
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: 虎鸣 <he...@alibaba-inc.com>
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: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org