File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
main/java/org/purejava/appindicator
test/java/org/purejava/appindicator Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ final class RuntimeHelper {
3030 private static final String LD_CONFIG = "/etc/ld.so.conf.d/" ;
3131 private static final String LIB_NAME_VERSION = "libappindicator3.so.1" ;
3232 private static final String FLATPAK_LIB_NAME_VERSION = "libappindicator3.so" ;
33+ private static final String LIBNAME_WITH_VERSION = "appindicator3" ;
3334 private static List <String > allPath = new LinkedList <>();
3435 private static final Logger LOG = LoggerFactory .getLogger (RuntimeHelper .class );
3536
@@ -64,6 +65,14 @@ final class RuntimeHelper {
6465 break ;
6566 } catch (UnsatisfiedLinkError ignored ) { }
6667 }
68+
69+ // When loading via System.load wasn't successfull, try to load via System.loadLibrary
70+ if (!isLoaded ) {
71+ try {
72+ System .loadLibrary (LIBNAME_WITH_VERSION );
73+ isLoaded = true ;
74+ } catch (UnsatisfiedLinkError ignored ) { }
75+ }
6776 LOG .info (isLoaded ? "Native code library libappindicator3 successfully loaded" : "Native code library libappindicator3 failed to load" );
6877 SymbolLookup loaderLookup = SymbolLookup .loaderLookup ();
6978 SYMBOL_LOOKUP = name -> loaderLookup .find (name ).or (() -> LINKER .defaultLookup ().find (name ));
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ class AppIndicatorTest {
2222 private static final String LD_CONFIG = "/etc/ld.so.conf.d/" ;
2323 private static final String LIB_NAME_VERSION = "libappindicator3.so.1" ;
2424 private static final String FLATPAK_LIB_NAME_VERSION = "libappindicator3.so" ;
25+ private static final String LIBNAME_WITH_VERSION = "appindicator3" ;
2526 private static List <String > allPath = new LinkedList <>();
2627
2728 @ Test
@@ -56,6 +57,14 @@ public void shouldHaveNoErrors() {
5657 break ;
5758 } catch (UnsatisfiedLinkError ignored ) { }
5859 }
60+
61+ // When loading via System.load wasn't successfull, try to load via System.loadLibrary
62+ if (!isLoaded ) {
63+ try {
64+ System .loadLibrary (LIBNAME_WITH_VERSION );
65+ isLoaded = true ;
66+ } catch (UnsatisfiedLinkError ignored ) { }
67+ }
5968 LOG .info (isLoaded ? "Native code library libappindicator3 successfully loaded" : "Native code library libappindicator3 failed to load" );
6069 }
6170}
You can’t perform that action at this time.
0 commit comments