Skip to content

Commit

Permalink
NativeBinaryLoader: loading native binary after closing extraction pr…
Browse files Browse the repository at this point in the history
…ocess resources

*	modified:   snaploader-examples/src/main/java/com/avrsandbox/snaploader/examples/TestBasicFeatures.java
*	modified:   snaploader/src/main/java/com/avrsandbox/snaploader/NativeBinaryLoader.java
  • Loading branch information
Scrappers-glitch committed Jul 17, 2023
1 parent 2047bb0 commit 08f1b7e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static void main(String[] args) throws IOException {
loader.setRetryWithCleanExtraction(true);
/* Native dynamic library properties */
printDetails(loader);
loader.loadLibrary(LoadingCriterion.CLEAN_EXTRACTION);
loader.loadLibrary(LoadingCriterion.INCREMENTAL_LOADING);
}

protected static void printDetails(NativeBinaryLoader loader) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ protected void loadBinary(NativeDynamicLibrary library) throws IOException {
return;
}
System.load(library.getExtractedLibrary());
log(Level.INFO, "loadBinary", "Successfully loaded library: " + library.getExtractedLibrary(), null);
} catch (final UnsatisfiedLinkError error) {
log(Level.SEVERE, "loadBinary", "Cannot load the dynamic library: " + library.getExtractedLibrary(), error);
/* Retry with clean extract */
Expand All @@ -247,11 +248,11 @@ protected void cleanExtractBinary(NativeDynamicLibrary library) throws IOExcepti
/* CLEAR RESOURCES AND RESET OBJECTS ON-EXTRACTION */
libraryExtractor.setExtractionListener(() -> {
try{
loadBinary(library);
libraryExtractor.getFileLocator().close();
libraryExtractor.close();
libraryExtractor = null;
log(Level.INFO, "cleanExtractBinary", "Extracted successfully to " + library.getExtractedLibrary(), null);
loadBinary(library);
} catch (Exception e) {
log(Level.SEVERE, "cleanExtractBinary", "Error while closing the resources!", e);
}
Expand Down

0 comments on commit 08f1b7e

Please sign in to comment.