Skip to content

Commit 764e033

Browse files
authored
Specify and document value for environment variable for loading native library in Java bindings (#5477)
* limit range of environment variable for loading the native library in Java to "true". This change specifies the range of values that are allowed to set the environment variable "z3.skipLibraryLoad". Only the value "true" (in upper-, lower-, and mixed-case is accepted as valid value. Other values, such as "false", "0", "1", "foo", an empty or a missing value are evaluated to "false" and cause the default loading of the native library. * adding documentation about environment variable for (not) loading the native library in Java. This is a follow-up commit for #4667 to provide a publicly visible documentation.
1 parent 35698c6 commit 764e033

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

examples/java/README

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,9 @@ On Linux and FreeBSD, we must use
1212
LD_LIBRARY_PATH=. java -cp com.microsoft.z3.jar:. JavaExample
1313
On macOS, the corresponding option is DYLD_LIBRARY_PATH:
1414
DYLD_LIBRARY_PATH=. java -cp com.microsoft.z3.jar:. JavaExample
15+
16+
By default, Z3 Java bindings are automatically loading the required native library for Z3 from the default library path.
17+
In certain environments, depending on the developing process, the Z3 library is not available in the given library path.
18+
To disable the automated loading process, the user can set the environment variable "z3.skipLibraryLoad=true".
19+
In that case, the calling application should directly load the corresponding libraries before any interaction with Z3.
20+

scripts/update_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ def mk_java(java_dir, package_name):
545545
java_native.write(' public static native void setInternalErrorHandler(long ctx);\n\n')
546546

547547
java_native.write(' static {\n')
548-
java_native.write(' if (null == System.getProperty("z3.skipLibraryLoad")) {\n')
548+
java_native.write(' if (!Boolean.parseBoolean(System.getProperty("z3.skipLibraryLoad"))) {\n')
549549
java_native.write(' try {\n')
550550
java_native.write(' System.loadLibrary("z3java");\n')
551551
java_native.write(' } catch (UnsatisfiedLinkError ex) {\n')

0 commit comments

Comments
 (0)