You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fory.apache.org by "gudzpoz (via GitHub)" <gi...@apache.org> on 2025/10/03 13:56:42 UTC
[I] [Java][Native Image] `ObjectCreator` sometimes produces `Object` under GraalVM 25 [fory]
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: commits-unsubscribe@fory.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [I] [Java][Native Image] `ObjectCreator` sometimes produces `Object` under GraalVM 25 [fory]
Posted by "mengnankkkk (via GitHub)" <gi...@apache.org>.
mengnankkkk commented on issue #2697:
URL: https://github.com/apache/fory/issues/2697#issuecomment-3368319226
I want to do it thx !I will commit it!
--
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: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [I] [Java][Native Image] `ObjectCreator` sometimes produces `Object` under GraalVM 25 [fory]
Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang closed issue #2697: [Java][Native Image] `ObjectCreator` sometimes produces `Object` under GraalVM 25
URL: https://github.com/apache/fory/issues/2697
--
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: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org