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:45:00 UTC

(pekko-persistence-dynamodb) branch refactor/replace-reflection-with-methodhandles created (now 1f7a83c)

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-dynamodb.git


      at 1f7a83c  refactor: load serializer classes with method handles

This branch includes the following new commits:

     new 1f7a83c  refactor: load serializer classes 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-dynamodb) 01/01: refactor: load serializer classes 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-dynamodb.git

commit 1f7a83cffb0dc24b3cc89292d2e4da14e9692755
Author: 虎鸣 <he...@alibaba-inc.com>
AuthorDate: Mon Jul 6 19:43:46 2026 +0800

    refactor: load serializer classes with method handles
    
    Motivation:
    Avoid Class.forName in the DynamoDB test serializer path on modern JVMs.
    
    Modification:
    Use MethodHandles.Lookup.findClass and ensureInitialized before delegating to JavaSerializer deserialization.
    
    Result:
    The serializer test helper preserves class initialization behavior without direct Class.forName usage.
---
 .../pekko/persistence/dynamodb/journal/TestSerializer.scala      | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/test/scala/org/apache/pekko/persistence/dynamodb/journal/TestSerializer.scala b/src/test/scala/org/apache/pekko/persistence/dynamodb/journal/TestSerializer.scala
index 766a836..ff16e6a 100644
--- a/src/test/scala/org/apache/pekko/persistence/dynamodb/journal/TestSerializer.scala
+++ b/src/test/scala/org/apache/pekko/persistence/dynamodb/journal/TestSerializer.scala
@@ -13,6 +13,8 @@
 
 package org.apache.pekko.persistence.dynamodb.journal
 
+import java.lang.invoke.MethodHandles
+
 import org.apache.pekko.actor.ExtendedActorSystem
 import org.apache.pekko.serialization.{ AsyncSerializerWithStringManifest, JavaSerializer }
 
@@ -29,7 +31,12 @@ class TestSerializer(system: ExtendedActorSystem) extends AsyncSerializerWithStr
   val javaSerializer: JavaSerializer = new JavaSerializer(system)
 
   override def fromBinaryAsync(bytes: Array[Byte], manifest: String): Future[AnyRef] =
-    Future.successful(javaSerializer.fromBinary(bytes, Class.forName(manifest)))
+    Future.successful {
+      val lookup = MethodHandles.lookup()
+      val clazz = lookup.findClass(manifest)
+      lookup.ensureInitialized(clazz)
+      javaSerializer.fromBinary(bytes, clazz)
+    }
 
   override def toBinaryAsync(obj: AnyRef): Future[Array[Byte]] =
     Future.successful(javaSerializer.toBinary(obj))


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