gudzpoz opened a new issue, #2257:
URL: https://github.com/apache/fury/issues/2257

   ### Search before asking
   
   - [x] I had searched in the [issues](https://github.com/apache/fury/issues) 
and found no similar issues.
   
   
   ### Version
   
   Fury: 'org.apache.fury:fury-core:0.10.2'
   JDK: GraalVM 23.0.2+7.1 (build 23.0.2+7-jvmci-b01)
   
   ### Component(s)
   
   Java
   
   ### Minimal reproduce step
   
   ```java
       @Test
       public void testNumberListRecord() {
           Fury fury = Fury.builder()
                   .withLanguage(Language.JAVA)
                   .withAsyncCompilation(true)
                   .build();
           fury.register(NumberListRecord.class);
           fury.register(IntArrayList.class);
           byte[] bytes = fury.serialize(new NumberListRecord(1L, new 
ArrayList<>()));
           fury.deserialize(bytes); // <-- ClassCastException
       }
   
       record NumberListRecord(Number n, List<Object> list) {
       }
   ```
   
   ### What did you expect to see?
   
   The test above passes.
   
   ### What did you see instead?
   
   ```
   Cannot cast java.util.ArrayList to java.lang.Number
   java.lang.ClassCastException: Cannot cast java.util.ArrayList to 
java.lang.Number
        at java.base/java.lang.Class.cast(Class.java:4139)
        at 
java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:735)
        at 
org.apache.fury.serializer.ObjectSerializer.read(ObjectSerializer.java:241)
        at org.apache.fury.Fury.readDataInternal(Fury.java:990)
        at org.apache.fury.Fury.readRef(Fury.java:874)
        at org.apache.fury.Fury.deserialize(Fury.java:806)
        at org.apache.fury.Fury.deserialize(Fury.java:727)
        at 
party.iroiro.juicemacs.elisp.runtime.pdump.DumpUtilsTest.testNumberListRecord(DumpUtilsTest.java:164)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1597)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1597)
   ```
   
   ### Anything Else?
   
   I have also tested with the following records:
   
   ```java
       record NumberListRecord(Integer n, List<Object> list) {
           // This one passes the test.
       }
       record NumberListRecord(AutoClosable n, List<Object> list) {
           // This one fails.
       }
   ```
   
   Also, setting `withAsyncCompilation(false)` also removes the error. So the 
bug seems to be in the interpreted serializer.
   
   ### Are you willing to submit a PR?
   
   - [ ] I'm willing to submit a PR!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to