Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
优化 JNI
Browse files Browse the repository at this point in the history
(cherry picked from commit e9021a2)
  • Loading branch information
4ra1n committed Aug 2, 2024
1 parent 4e85acb commit da6e7c6
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/main/java/me/n1ar4/jar/obfuscator/utils/JNIUtil.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package me.n1ar4.jar.obfuscator.utils;

import me.n1ar4.jar.obfuscator.Const;
import me.n1ar4.jar.obfuscator.jvmti.Constants;

import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -42,11 +41,9 @@ private static boolean deleteUrls() {
public static boolean loadLib(String path) {
Path p = Paths.get(path);
if (!Files.exists(p)) {

return false;
}
if (Files.isDirectory(p)) {

return false;
}
String os = System.getProperty("os.name").toLowerCase();
Expand All @@ -63,14 +60,15 @@ public static boolean loadLib(String path) {
return false;
}
System.load(p.toFile().getAbsolutePath());
return true;
} else {
String so = p.toFile().getAbsolutePath();
if (!so.endsWith(".so")) {
return false;
if (so.endsWith(".so") || so.endsWith(".dylib")) {
System.load(so);
return true;
}
System.load(so);
return false;
}
return true;
}

/**
Expand Down

0 comments on commit da6e7c6

Please sign in to comment.