Skip to content

Improve native-image documentation for Serialization registration #41997

@Sanne

Description

@Sanne

Description

I was having native-image spit out errors:

com.oracle.svm.core.jdk.UnsupportedFeatureError: SerializationConstructorAccessor class not found for declaringClass: java.lang.String (targetConstructorClass: java.lang.Object). Usually adding java.lang.String to serialization-config.json fixes the problem

It turns out the fix is trivial, as apparently one can contribute entries to the serialization-config.json by using

@RegisterForReflection(targets = { String.class }, serialization = true)

Unfortunately the guide at https://quarkus.io/guides/writing-native-applications-tips doesn't mention neither the serialization-config.json and the serialization attribute of @RegisterForReflection.

Implementation ideas

It would be nice to add a section, especially keeping in mind the language used by the GraalVM native-image error: while we don't normally expect people to create files such as serialization-config.json, I suspect they will be searching for related instructions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    To do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions