You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I was looking at #8509 (comment) using native-agent to generate serialization config, it occurred to me that while e.g. both java.lang.Short[] and java.lang.String[][] get generated in the reachability-metadata.json, the java.lang.String[] is not added and has to be added manually. It's not a new thing though, I can see it both with older graalvm-community-jdk21u and with the very latest graalvm-community-java24.
$ native-image --version
native-image 24 2025-03-18
GraalVM Runtime Environment GraalVM CE 24-dev+12.1 (build 24+12-jvmci-b01)
Substrate VM GraalVM CE 24-dev+12.1 (build 24+12, serial gc)
$ java --version
openjdk 24 2025-03-18
OpenJDK Runtime Environment GraalVM CE 24-dev+12.1 (build 24+12-jvmci-b01)
OpenJDK 64-Bit Server VM GraalVM CE 24-dev+12.1 (build 24+12-jvmci-b01, mixed mode, sharing)
$ unzip Main.java.zip
$ javac Main.java
$ java -agentlib:native-image-agent=config-output-dir=AGENT Main
$ native-image -ea --no-fallback --link-at-build-time -H:ConfigurationFileDirectories=./AGENT Main
$ ./main
...
Exception in thread "main" com.oracle.svm.core.jdk.UnsupportedFeatureError: SerializationConstructorAccessor class not found for declaringClass: [Ljava.lang.String; (targetConstructorClass: java.lang.Object). Usually adding [Ljava.lang.String; to serialization-config.json fixes the problem.
at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:121)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.reflect.serialize.SerializationSupport.getSerializationConstructorAccessor(SerializationSupport.java:205)
at java.base@24/jdk.internal.reflect.SerializationConstructorAccessorGenerator.generateSerializationConstructor(SerializationConstructorAccessorGenerator.java:53)
at java.base@24/jdk.internal.reflect.ReflectionFactory.generateConstructor(ReflectionFactory.java:340)
at java.base@24/jdk.internal.reflect.ReflectionFactory.newConstructorForSerialization(ReflectionFactory.java:253)
at jdk.unsupported@24/sun.reflect.ReflectionFactory.newConstructorForSerialization(ReflectionFactory.java:100)
at Main.main(Main.java:83)
at java.base@24/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
When I edit the AGENT/reachability-metadata.json file as suggested by the helpful message:
fernando-valdez
changed the title
native-image-agent omits String[] from "serialization" when using newConstructorForSerialization
[GR-57707] native-image-agent omits String[] from "serialization" when using newConstructorForSerialization
Aug 29, 2024
As I was looking at #8509 (comment) using native-agent to generate serialization config, it occurred to me that while e.g. both
java.lang.Short[]
andjava.lang.String[][]
get generated in thereachability-metadata.json
, thejava.lang.String[]
is not added and has to be added manually. It's not a new thing though, I can see it both with older graalvm-community-jdk21u and with the very latest graalvm-community-java24.How to reproduce
Using this source Main.java.zip
TL;DR:
When I edit the
AGENT/reachability-metadata.json
file as suggested by the helpful message:and run the build again, it works.
Is this expected of the native agent?
(@zakkak FYI)
The text was updated successfully, but these errors were encountered: