taoensso / nippy

The fastest serialization library for Clojure

Home Page:https://www.taoensso.com/nippy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GraalVM native-image fail when serializing Exception

BrunoBonacci opened this issue · comments

Hi,

I tried to use Nippy with a GraalVM compiled project and I stumbled into an issue.
It seems that Nippy, when compiled via GraalVM, can't serialize Exceptions.
Other data-types seems to work fine.

See the sample project here on how to reproduce the problem.
https://github.com/BrunoBonacci/graalvm-clojure/tree/master/nippy

Do you have any idea why would that be the case?

Hi Bruno, not off hand- sorry!

But based on the error you're seeing:

Exception in thread "main" clojure.lang.ExceptionInfo: Unfreezable type: class clojure.lang.ExceptionInfo {:type clojure.lang.ExceptionInfo, :as-str "#error {\n :cause "ExInfo"\n :data {:data "data"}\n :via\n [{:type clojure.lang.ExceptionInfo\n :message "ExInfo"\n :data {:data "data"}}]\n :trace\n []}"}

Which comes from here, via here - I suspect that this util may be returning falsey.

I'd suggest experimenting a bit with the util to see precisely what the issue seems to be. Could be the util needs to be tweaked.

PRs welcome!

EDIT: As an alternative to figuring out why the Serializable fallback isn't working, you could probably also just add a specific freeze+thaw implementation for Exception or ExceptionInfo.

I see,
The reason it fails is because of this (Class/forName class-name) call here

By default, the native-image will throw a java.lang.ClassNotFoundException because of the close-world assumption.
There are ways to hint that the class is already loaded via a special config (see here)

I will experiment a bit more to see if it can be solved via configuration only.
thx

So, after providing the correct Reflective config I get another error:
com.oracle.svm.core.jdk.UnsupportedFeatureError: ObjectOutputStream.writeObject()

Which is due to the fact that serialization isn't supported yet:
oracle/graal#460

I will close this issue for the moment, as there is no general way to fix this. Thanks for your help.

This is fixed in GraalVM 21.3.0. @ptaoussanis would you like to accept the PR with the necessary configuration to support this?

See here

@FieryCod Would be happy to look at a PR, thanks Karol 👍