apache / fury

A blazingly fast multi-language serialization framework powered by JIT and zero-copy.
https://fury.apache.org/
Apache License 2.0
3.11k stars 248 forks source link

feat(scala): support scala native image build #1922

Closed chaokunyang closed 2 weeks ago

chaokunyang commented 2 weeks ago

What does this PR do?

This PR supports scala native image build and fix quarkus graalvm build for java in https://github.com/quarkiverse/quarkus-fury/issues/7:

Error: Class initialization of org.apache.fury.type.ScalaTypes failed. Use the option 

    '--initialize-at-run-time=org.apache.fury.type.ScalaTypes'

 to explicitly request initialization of this class at run time.
com.oracle.svm.core.util.UserError$UserException: Class initialization of org.apache.fury.type.ScalaTypes failed. Use the option 

    '--initialize-at-run-time=org.apache.fury.type.ScalaTypes'

 to explicitly request initialization of this class at run time.
    at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.UserError.abort(UserError.java:85)
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.ClassInitializationSupport.ensureClassInitialized(ClassInitializationSupport.java:195)
    at ..................
org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.ClassInitializationSupport.ensureClassInitialized(ClassInitializationSupport.java:177)
    ... 43 more
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: scala.collection.Iterable
    at org.apache.fury.reflect.ReflectionUtils.loadClass(ReflectionUtils.java:649)
    at org.apache.fury.type.ScalaTypes.<clinit>(ScalaTypes.java:40)
    ... 46 more
Caused by: java.lang.ClassNotFoundException: scala.collection.Iterable
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageClassLoader.loadClass(NativeImageClassLoader.java:637)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
    at org.apache.fury.reflect.ReflectionUtils.loadClass(ReflectionUtils.java:646)
    ... 47 more

Related issues

Closes https://github.com/quarkiverse/quarkus-fury/issues/7

Does this PR introduce any user-facing change?

Benchmark