[ 
https://issues.apache.org/jira/browse/GROOVY-11993?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18078368#comment-18078368
 ] 

ASF GitHub Bot commented on GROOVY-11993:
-----------------------------------------

testlens-app[bot] commented on PR #2514:
URL: https://github.com/apache/groovy/pull/2514#issuecomment-4377111307

   ## ✅ All tests passed ✅
   
   🏷️ Commit: 751293791c94cc093a0b0159b3d7b73c8cc6d0d5
   ▶️ Tests:  194586 executed
   ⚪️ Checks: 48/48 completed
   
   ---
   _Learn more about TestLens at [testlens.app](https://testlens.app)._
   




> Support serializable method reference
> -------------------------------------
>
>                 Key: GROOVY-11993
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11993
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Daniel Sun
>            Priority: Major
>
> Groovy has supported serializable lambda expression for years, and 
> serializable method reference will be supported in this improvement, e.g.
> {code}
>             import java.io.ByteArrayInputStream
>             import java.io.ByteArrayOutputStream
>             import java.io.Serializable
>             @CompileStatic
>             class C {
>                 interface SerSupplier<T> extends Serializable, Supplier<T> {}
>                 private final String text
>                 C(String text) {
>                     this.text = text
>                 }
>                 SerSupplier<String> create() {
>                     text::trim
>                 }
>                 static byte[] serialize(Serializable value) {
>                     def out = new ByteArrayOutputStream()
>                     out.withObjectOutputStream { it.writeObject(value) }
>                     out.toByteArray()
>                 }
>                 static <T> T deserialize(byte[] bytes) {
>                     new 
> ByteArrayInputStream(bytes).withObjectInputStream(C.classLoader) {
>                         (T) it.readObject()
>                     }
>                 }
>             }
>             C.SerSupplier<String> supplier = C.deserialize(C.serialize(new 
> C('  answer  ').create()))
>             assert supplier instanceof Serializable
>             assert supplier.get() == 'answer'
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to