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

   ### Search before asking
   
   - [x] I had searched in the [issues](https://github.com/apache/fory/issues) 
and found no similar issues.
   
   
   ### Version
   
   OS: ArchLinux (6.16.7-zen1-1-zen)
   Fory: 'org.apache.fory:fory-core:0.13.0-SNAPSHOT' (Sep 30)
   JDK: GraalVM CE 25+37.1 (build 25+37-jvmci-b01)
   
   ### Component(s)
   
   Java
   
   ### Minimal reproduce step
   
   See 
https://github.com/gudzpoz/fory-native-image-reproducer/blob/private-constructor/app/src/main/java/org/example/App.java
 .
   
   ```console
   $ git clone https://github.com/gudzpoz/fory-native-image-reproducer.git
   $ git checkout private-constructor
   $ ./gradlew run # pass
   $ ./gradlew nativeCompile
   $ app/build/native/nativeCompile/test
   Error: Exception in thread "main" 
org.apache.fory.exception.DeserializationException: Deserialize failed, read 
objects are: [org.example.App@653b6657, java.lang.Object@2a34e425]
        at 
org.apache.fory.util.ExceptionUtils.handleReadFailed(ExceptionUtils.java:63)
        at org.apache.fory.Fory.deserialize(Fory.java:889)
        at org.apache.fory.Fory.deserialize(Fory.java:785)
        at org.example.App.main(App.java:32)
        at 
java.base@25/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
   Caused by: java.lang.ClassCastException: java.lang.Object cannot be cast to 
org.example.App$AbstractClass
        at org.example.AppForyRefCodec_0.read(AppForyRefCodec_0.java:73)
        at org.apache.fory.Fory.readDataInternal(Fory.java:1046)
        at org.apache.fory.Fory.readRef(Fory.java:931)
        at org.apache.fory.Fory.deserialize(Fory.java:885)
        ... 3 more
   ```
   
   ### What did you expect to see?
   
   The test should pass.
   
   ### What did you see instead?
   
   ```console
   $ app/build/native/nativeCompile/test
   Error: Exception in thread "main" 
org.apache.fory.exception.DeserializationException: Deserialize failed, read 
objects are: [org.example.App@653b6657, java.lang.Object@2a34e425]
        at 
org.apache.fory.util.ExceptionUtils.handleReadFailed(ExceptionUtils.java:63)
        at org.apache.fory.Fory.deserialize(Fory.java:889)
        at org.apache.fory.Fory.deserialize(Fory.java:785)
        at org.example.App.main(App.java:32)
        at 
java.base@25/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
   Caused by: java.lang.ClassCastException: java.lang.Object cannot be cast to 
org.example.App$AbstractClass
        at org.example.AppForyRefCodec_0.read(AppForyRefCodec_0.java:73)
        at org.apache.fory.Fory.readDataInternal(Fory.java:1046)
        at org.apache.fory.Fory.readRef(Fory.java:931)
        at org.apache.fory.Fory.deserialize(Fory.java:885)
        ... 3 more
   ```
   
   ### Anything Else?
   
   This seems to be related to the private constructor(s). Changing `private 
ConcreteClass(int i)` to `protected ConcreteClass(int i)` solves the issue. 
Also `ObjectCreator` does not seem to handle parent constructors with arguments 
currently?
   
   ### 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