When using JavaSMT with Z3 in an Eclipse PDE launch environment, the solver fails to initialize with the following exception:
org.sosy_lab.common.configuration.InvalidConfigurationException: The SMT solver Z3 is not available on this machine because of missing libraries ('long com.microsoft.z3.Native.INTERNALmkConfig()')..
Caused by: java.lang.UnsatisfiedLinkError: 'long com.microsoft.z3.Native.INTERNALmkConfig()' at com.microsoft.z3.Native.INTERNALmkConfig(Native Method) at com.microsoft.z3.Native.mkConfig(Native.java:895)
Steps to reproduce:
- Create an Eclipse plugin project.
- Include all necessary dependencies for JavaSMT and Z3.
- Include the native library bundle containing:
- Launch the product via PDE (
Run As → Eclipse Application) with a VM argument pointing to the bundle containing the native libs
- Attempt to create a solver context:
SolverContext context = SolverContextFactory.createSolverContext(SolverContextFactory.Solvers.Z3);
- Observe an exception throw:
org.sosy_lab.common.configuration.InvalidConfigurationException: The SMT solver Z3 is not available on this machine because of missing libraries ('long com.microsoft.z3.Native.INTERNALmkConfig()')..
...
Caused by: java.lang.UnsatisfiedLinkError: 'long com.microsoft.z3.Native.INTERNALmkConfig()' at com.microsoft.z3.Native.INTERNALmkConfig(Native Method) at com.microsoft.z3.Native.mkConfig(Native.java:895)
JavaSMT can't create the solver even though the native .so files are present and visible in /proc/<YOURPID>/maps or cat /proc/$(pgrep -f eclipse)/maps | grep z3.
When running the Eclipse PDE with LD_DEBUG=bindings you get the following output:
121431: /usr/lib/jvm/java-21-openjdk/bin/java: error: symbol lookup error: undefined symbol: JNI_OnLoad_z3 (fatal)
121431: /usr/lib/jvm/java-21-openjdk/bin/java: error: symbol lookup error: undefined symbol: JNI_OnLoad_z3 (fatal)
121431: /home/.../z3.bundle/lib/libz3.so: error: symbol lookup error: undefined symbol: JNI_OnLoad (fatal)
What's interesting here is, that JavaSMT tries to load an JNI symbol JNI_OnLoad in the libz3.so first, before loading libz3java.so (where the symbol is defined).
When using Z3 without JavaSMT (exactly the same setup but using the com.microsoft.z3.* API) everything works as expected.
I suspect a load issue where the libz3.so is first loaded before the libz3java.so.
I think the issue is how the common-lib does the library loading here: https://github.com/sosy-lab/java-common-lib/blob/main/src/org/sosy_lab/common/NativeLibraries.java#L174
When using JavaSMT with Z3 in an Eclipse PDE launch environment, the solver fails to initialize with the following exception:
Steps to reproduce:
libz3.solibz3java.soRun As → Eclipse Application) with a VM argument pointing to the bundle containing the native libsJavaSMT can't create the solver even though the native
.sofiles are present and visible in/proc/<YOURPID>/mapsorcat /proc/$(pgrep -f eclipse)/maps | grep z3.When running the Eclipse PDE with
LD_DEBUG=bindingsyou get the following output:What's interesting here is, that JavaSMT tries to load an JNI symbol
JNI_OnLoadin thelibz3.sofirst, before loadinglibz3java.so(where the symbol is defined).When using Z3 without JavaSMT (exactly the same setup but using the
com.microsoft.z3.*API) everything works as expected.I suspect a load issue where thelibz3.sois first loaded before thelibz3java.so.I think the issue is how the
common-libdoes the library loading here: https://github.com/sosy-lab/java-common-lib/blob/main/src/org/sosy_lab/common/NativeLibraries.java#L174