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/06/26 11:10:56 UTC

(pekko) branch feature/java17-toarray-typed created (now 33a226ef41)

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

He-Pin pushed a change to branch feature/java17-toarray-typed
in repository https://gitbox.apache.org/repos/asf/pekko.git


      at 33a226ef41 refactor: migrate .toArray() to .toArray(T[]::new) for type-safe array conversion (Java 11+)

This branch includes the following new commits:

     new 33a226ef41 refactor: migrate .toArray() to .toArray(T[]::new) for type-safe array conversion (Java 11+)

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) 01/01: refactor: migrate .toArray() to .toArray(T[]::new) for type-safe array conversion (Java 11+)

Posted by he...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

He-Pin pushed a commit to branch feature/java17-toarray-typed
in repository https://gitbox.apache.org/repos/asf/pekko.git

commit 33a226ef4164395a51668e0c99fe3229f6ee1990
Author: θ™ŽιΈ£ <he...@alibaba-inc.com>
AuthorDate: Fri Jun 26 19:10:38 2026 +0800

    refactor: migrate .toArray() to .toArray(T[]::new) for type-safe array conversion (Java 11+)
    
    Motivation:
    Java 11 added Collection.toArray(IntFunction<T[]>) which produces a
    type-safe array instead of Object[]. This eliminates unchecked casts
    and improves compile-time type safety.
    
    Modification:
    - List<String>.toArray() β†’ .toArray(String[]::new) (TestKitDocTest, 2 occurrences)
    - List<Boolean>.toArray() β†’ .toArray(Boolean[]::new) (SourceTest)
    
    Result:
    Type-safe array conversions without unchecked casts. 3 occurrences
    migrated across 2 test files.
    
    Tests: sbt validatePullRequest
    References: https://javaalmanac.io/jdk/17/apidiff/8/
---
 docs/src/test/java/jdocs/testkit/TestKitDocTest.java                  | 4 ++--
 .../src/test/java/org/apache/pekko/stream/javadsl/SourceTest.java     | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/docs/src/test/java/jdocs/testkit/TestKitDocTest.java b/docs/src/test/java/jdocs/testkit/TestKitDocTest.java
index 3fdef495f3..7f79c2a664 100644
--- a/docs/src/test/java/jdocs/testkit/TestKitDocTest.java
+++ b/docs/src/test/java/jdocs/testkit/TestKitDocTest.java
@@ -215,7 +215,7 @@ public class TestKitDocTest extends AbstractJavaTest {
                   }
                 });
 
-        assertArrayEquals(new String[] {"42", "43"}, out.toArray());
+        assertArrayEquals(new String[] {"42", "43"}, out.toArray(String[]::new));
         expectMsgEquals("hello");
       }
     };
@@ -295,7 +295,7 @@ public class TestKitDocTest extends AbstractJavaTest {
         assertEquals("hello", any);
         assertEquals(42, i);
         assertEquals(42, j);
-        assertArrayEquals(new String[] {"hello", "world"}, all.toArray());
+        assertArrayEquals(new String[] {"hello", "world"}, all.toArray(String[]::new));
       }
     };
   }
diff --git a/stream-tests/src/test/java/org/apache/pekko/stream/javadsl/SourceTest.java b/stream-tests/src/test/java/org/apache/pekko/stream/javadsl/SourceTest.java
index db3341baea..06da3fbacd 100644
--- a/stream-tests/src/test/java/org/apache/pekko/stream/javadsl/SourceTest.java
+++ b/stream-tests/src/test/java/org/apache/pekko/stream/javadsl/SourceTest.java
@@ -1535,7 +1535,7 @@ public class SourceTest extends StreamTestJupiter {
 
     assertArrayEquals(
         new Boolean[] {false, true, false, true, false, true, false, true, false, true},
-        future.get(1, TimeUnit.SECONDS).toArray());
+        future.get(1, TimeUnit.SECONDS).toArray(Boolean[]::new));
   }
 
   @Test


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