Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit dccfdad

Browse files
CaelmBleidddenis-fokin
authored andcommitted
Fix the way of looking for native libraries (#1960)
(cherry picked from commit 18fcbdd)
1 parent 257f289 commit dccfdad

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

‎utbot-framework/src/main/kotlin/org/utbot/engine/z3/Z3initializer.kt‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import com.microsoft.z3.Context
44
import com.microsoft.z3.Global
55
import org.utbot.common.FileUtil
66
import java.io.File
7-
import java.nio.file.Files.createTempDirectory
87

98
abstract class Z3Initializer : AutoCloseable {
109
protected val context: Context by lazy {
@@ -27,27 +26,30 @@ abstract class Z3Initializer : AutoCloseable {
2726
val arch = System.getProperty("os.arch")
2827
require(arch in supportedArchs) { "Not supported arch: $arch" }
2928

30-
val osProperty = System.getProperty("os.name").toLowerCase()
29+
val osProperty = System.getProperty("os.name").lowercase()
3130
val (ext, allLibraries) = when {
3231
osProperty.startsWith("windows") -> ".dll" to vcWinLibrariesToLoadBefore + libraries
3332
osProperty.startsWith("linux") -> ".so" to libraries
3433
osProperty.startsWith("mac") -> ".dylib" to libraries
3534
else -> error("Unknown OS: $osProperty")
3635
}
37-
val libZ3DllUrl = Z3Initializer::class.java
36+
37+
val dist = if (arch == "aarch64") "arm" else "x64"
38+
39+
val libZ3FilesUrl = Z3Initializer::class.java
3840
.classLoader
39-
.getResource("lib/x64/libz3.dll") ?: error("Can't find native library folder")
41+
.getResource("lib/$dist/libz3$ext") ?: error("Can't find native library folder")
4042
// can't take resource of parent folder right here because in obfuscated jar parent folder
4143
// can be missed (e.g., in case if obfuscation was applied)
4244

4345
val libFolder: String?
44-
if (libZ3DllUrl.toURI().scheme == "jar") {
46+
if (libZ3FilesUrl.toURI().scheme == "jar") {
4547
val tempDir = FileUtil.createTempDirectory("libs-").toFile()
4648

4749
allLibraries.forEach { name ->
4850
Z3Initializer::class.java
4951
.classLoader
50-
.getResourceAsStream("lib/x64/$name$ext")
52+
.getResourceAsStream("lib/$dist/$name$ext")
5153
?.use { input ->
5254
File(tempDir, "$name$ext")
5355
.outputStream()
@@ -57,7 +59,7 @@ abstract class Z3Initializer : AutoCloseable {
5759

5860
libFolder = "$tempDir"
5961
} else {
60-
libFolder = File(libZ3DllUrl.file).parent
62+
libFolder = File(libZ3FilesUrl.file).parent
6163
}
6264

6365
allLibraries.forEach { System.load("$libFolder/$it$ext") }

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /