RuedigerMoeller / fast-serialization

FST: fast java serialization drop in-replacement
Apache License 2.0
1.59k stars 245 forks source link

FST doesn't work with GraalVM native-image #313

Open hamzajg opened 3 years ago

hamzajg commented 3 years ago

Hello everyone.

Try to create a native image using GraalVM version 21.1.0 with Java 11. But when running the native image, the following exception is always thrown:

Exception in thread "main" com.oracle.svm.core.jdk.UnsupportedFeatureError: SerializationConstructorAccessor class not found for declaringClass: [Ljava.lang.Object; (targetConstructorClass: java.lang.Object). Usually adding [Ljava.lang.Object; to serialization-config.json fixes the problem.
    at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:87)
    at com.oracle.svm.reflect.serialize.SerializationSupport.getSerializationConstructorAccessor(SerializationSupport.java:132)
    at jdk.internal.reflect.MethodAccessorGenerator.generateSerializationConstructor(MethodAccessorGenerator.java:48)
    at jdk.internal.reflect.ReflectionFactory.generateConstructor(ReflectionFactory.java:514)
    at jdk.internal.reflect.ReflectionFactory.newConstructorForSerialization(ReflectionFactory.java:427)
    at sun.reflect.ReflectionFactory.newConstructorForSerialization(ReflectionFactory.java:103)
    at org.nustaq.serialization.FSTDefaultClassInstantiator.findConstructorForSerializable(FSTDefaultClassInstantiator.java:110)
    at org.nustaq.serialization.FSTClazzInfo.<init>(FSTClazzInfo.java:137)
    at org.nustaq.serialization.FSTClazzInfoRegistry.getCLInfo(FSTClazzInfoRegistry.java:129)
    at org.nustaq.serialization.FSTClazzNameRegistry.addClassMapping(FSTClazzNameRegistry.java:98)
    at org.nustaq.serialization.FSTClazzNameRegistry.registerClassNoLookup(FSTClazzNameRegistry.java:85)
    at org.nustaq.serialization.FSTClazzNameRegistry.registerClass(FSTClazzNameRegistry.java:81)
    at org.nustaq.serialization.FSTConfiguration.addDefaultClazzes(FSTConfiguration.java:845)
    at org.nustaq.serialization.FSTConfiguration.initDefaultFstConfigurationInternal(FSTConfiguration.java:478)
    at org.nustaq.serialization.FSTConfiguration.createDefaultConfiguration(FSTConfiguration.java:473)
    at org.nustaq.serialization.FSTConfiguration.createDefaultConfiguration(FSTConfiguration.java:465)
    at io.vlingo.xoom.experimental.fst.BootstrapApp.main(BootstrapApp.java:7)

Demo Example here: https://github.com/vlingo/xoom-experimental/tree/fst-graalvm-demo/fst-graalvm-demo

Thanks..

VaughnVernon commented 3 years ago

Hallo, @hamzajg has a workaround for this problem, but it's far from ideal. We disallow serialization of Object[] and byte[]. It would be great to support all Java types and arrays.

We are happy to contribute the GraalVM implementation details so you can support it.

imgoby commented 8 months ago

the same problem in jdk 17


        <groupId>de.ruedigermoeller</groupId>
            <artifactId>fst</artifactId>
<version>3.0.4-jdk17</version
```>