I am compiling a Java library from Matlab code using the Matlab Library Compiler.
Using Matlab 2020a, the compiler also generates an Java example code to call the library.
Executing this example, I get the following error:
Caught "std::exception" Exception message is:
Unknown exception
...
com.mathworks.toolbox.javabuilder.MWException: Unknown exception
at com.mathworks.toolbox.javabuilder.internal.MWMCR.mclFeval(Native Method)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.access$600(MWMCR.java:33)
at com.mathworks.toolbox.javabuilder.internal.MWMCR$6.mclFeval(MWMCR.java:897)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.mathworks.toolbox.javabuilder.internal.MWMCR$2.invoke(MWMCR.java:784)
at com.sun.proxy.$Proxy0.mclFeval(Unknown Source)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.invoke(MWMCR.java:447)
at callReggui.Reggui.callReggui(Reggui.java:172)
at MyCallReggui.callRegguiExample(MyCallReggui.java:22)
at MyCallReggui.main(MyCallReggui.java:51)
When I compile the library, using Matlab 2017b, I can call into the library just fine and don't get the "Unknown exception".
I'm using the Amazon Corretto JDK 11 as my Java JDK.
The Matlab code that I'm compiling into the library reads DICOM images, so it uses the Image Processing toolbox.
Debugging the call, it appears that when MWMCR.mclFeval is executed, the static fields of MWArray get initialized, which initializes MWArray.EMPTY_ARRAY. After that, the Exception appears to be thrown (still in the static initialization of MWArray), but I'cant track it down further.
I appreciate any ideas of why this Exception is thrown and how to resolve it, since I would prefere to move from 2017b to 2020a.
Greetings,
Felix
EDIT:
When I run the code directly within Matlab 2020a (no compilation to a Java library), it works fine.