Skip to content

Commit de8934b

Browse files
committed
Add method to check whether the library was loaded
1 parent f15fe4c commit de8934b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/main/java/org/purejava/linux/MemoryAllocator.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@ public static MemorySegment ALLOCATE_FOR(String str) {
1111
public static MemorySegment ALLOCATE_CALLBACK_FOR(GCallback cb, MemorySession session) {
1212
return GCallback.allocate(cb, session);
1313
}
14+
15+
public static boolean isLoadedNativeLib() {
16+
return RuntimeHelper.isLoaded();
17+
}
1418
}

src/main/java/org/purejava/linux/RuntimeHelper.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ private RuntimeHelper() {}
1818
private final static ClassLoader LOADER = RuntimeHelper.class.getClassLoader();
1919
private final static MethodHandles.Lookup MH_LOOKUP = MethodHandles.lookup();
2020
private final static SymbolLookup SYMBOL_LOOKUP;
21+
private static boolean isLoaded = false;
2122
private static final Logger LOG = LoggerFactory.getLogger(RuntimeHelper.class);
2223

2324
final static SegmentAllocator CONSTANT_ALLOCATOR =
@@ -26,6 +27,7 @@ private RuntimeHelper() {}
2627
static {
2728
try {
2829
System.loadLibrary("appindicator3");
30+
isLoaded = true;
2931
} catch (UnsatisfiedLinkError e) {
3032
LOG.error("Native code library failed to load.\n", e);
3133
}
@@ -221,4 +223,9 @@ private MemoryLayout variadicLayout(Class<?> c) {
221223
}
222224
}
223225
}
226+
227+
// Getter
228+
public static boolean isLoaded() {
229+
return isLoaded;
230+
}
224231
}

0 commit comments

Comments
 (0)