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
When trying to deserialize an XML representation of a Java Bean using java.beans.XMLDecoder, the native image fails with an ArrayIndexOutOfBoundsException.
The same code works well when packaged as a runnable Jar. However, it fails when run as a native image. I have also tried to include the bean class (test.Person) in reflect-config and also serialization-config hints.
Using the latest version of GraalVM can resolve many issues.
Person object is constructed successfully and the below string is printed
Hello from Person{firstName='John', lastName='Doe', age=50}
Actual Behavior
Running the native App results in error as below
java.lang.InstantiationException: com.sun.beans.decoder.JavaElementHandler
Continuing ...
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at java.desktop@21/java.beans.XMLDecoder.readObject(XMLDecoder.java:253)
at test.XmlDecoderTest.decodeTestPerson(XmlDecoderTest.java:13)
at test.XmlDecoderTest.main(XmlDecoderTest.java:8)
at java.base@21/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
java.lang.InstantiationException: com.sun.beans.decoder.JavaElementHandler
Continuing ...
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at java.desktop@21/java.beans.XMLDecoder.readObject(XMLDecoder.java:253)
at test.XmlDecoderTest.decodeTestPerson(XmlDecoderTest.java:13)
at test.XmlDecoderTest.main(XmlDecoderTest.java:8)
at java.base@21/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
The text was updated successfully, but these errors were encountered:
Describe the Issue
When trying to deserialize an XML representation of a Java Bean using
java.beans.XMLDecoder
, the native image fails with anArrayIndexOutOfBoundsException
.The same code works well when packaged as a runnable Jar. However, it fails when run as a native image. I have also tried to include the bean class (
test.Person
) inreflect-config
and alsoserialization-config
hints.Using the latest version of GraalVM can resolve many issues.
GraalVM Version
Oracle GraalVM 21+35.1 (build 21+35-jvmci-23.1-b15)
Operating System and Version
Darwin Kernel Version 23.0.0
Troubleshooting Confirmation
Run Command
./App
Expected Behavior
Person object is constructed successfully and the below string is printed
Actual Behavior
Running the native App results in error as below
Steps to Reproduce
XmlDecoderTest.java
Person.java
** Build **
javac -d build test/XmlDecoderTest.java
jar --create --file App.jar --main-class test.XmlDecoderTest -C build .
native-image -jar App.jar
** Test jar **
java -jar App.jar
** Test native-image **
./App
Additional Context
No response
Run-Time Log Output and Error Messages
java.lang.InstantiationException: com.sun.beans.decoder.JavaElementHandler
Continuing ...
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at java.desktop@21/java.beans.XMLDecoder.readObject(XMLDecoder.java:253)
at test.XmlDecoderTest.decodeTestPerson(XmlDecoderTest.java:13)
at test.XmlDecoderTest.main(XmlDecoderTest.java:8)
at java.base@21/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
The text was updated successfully, but these errors were encountered: