registeredLibraries, final LibraryInfo libraryInfo) {
super(registeredLibraries, libraryInfo);
}
-
+
+ @Override
+ public NativeBinaryLoader initPlatformLibrary() throws UnSupportedSystemError {
+ try {
+ /* CRITICAL SECTION STARTS */
+ lock.lock();
+ return super.initPlatformLibrary();
+ } finally {
+ lock.unlock();
+ /* CRITICAL SECTION ENDS */
+ }
+ }
+
+ @Override
+ public NativeBinaryLoader loadLibrary(LoadingCriterion criterion) throws Exception {
+ try {
+ /* CRITICAL SECTION STARTS */
+ lock.lock();
+ return super.loadLibrary(criterion);
+ } finally {
+ lock.unlock();
+ /* CRITICAL SECTION ENDS */
+ }
+ }
+
@Override
protected void cleanExtractBinary(NativeDynamicLibrary library) throws Exception {
try {
diff --git a/snaploader/src/main/java/electrostatic4j/snaploader/LoadingCriterion.java b/snaploader/src/main/java/electrostatic4j/snaploader/LoadingCriterion.java
index 715f80b..e7fdf31 100644
--- a/snaploader/src/main/java/electrostatic4j/snaploader/LoadingCriterion.java
+++ b/snaploader/src/main/java/electrostatic4j/snaploader/LoadingCriterion.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2023-2024, The Electrostatic-Sandbox Distributed Simulation Framework, jSnapLoader
+ * Copyright (c) 2023-2025, The Electrostatic-Sandbox Distributed Simulation Framework, jSnapLoader
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -47,5 +47,88 @@ public enum LoadingCriterion {
/**
* Extracts the native binary only if the current binary isn't present on the extraction directory.
*/
- INCREMENTAL_LOADING;
+ INCREMENTAL_LOADING,
+
+ /**
+ * Commands to load a native dynamic library from the system directories.
+ *
+ * This criterion instructs the loader to search for the native library in predefined
+ * system locations, relying on the operating system's dynamic linker to resolve the library.
+ * The library must be pre-installed and accessible through standard system paths.
+ *
+ *
+ * System Library Search Paths
+ * The specific directories searched depend on the operating system:
+ *
+ * - Linux: Searches in:
+ *
+ * - Directories specified in {@code LD_LIBRARY_PATH}.
+ * - System-wide library directories:
+ *
+ * - {@code /lib}
+ * - {@code /usr/lib}
+ * - {@code /usr/local/lib}
+ * - Paths configured in {@code /etc/ld.so.conf} and {@code /etc/ld.so.conf.d/}.
+ *
+ *
+ *
+ *
+ * - Windows: Searches in:
+ *
+ * - Directories listed in the {@code PATH} environment variable.
+ * - System directories:
+ *
+ * - {@code C:\Windows\System32} (for 64-bit DLLs)
+ * - {@code C:\Windows\SysWOW64} (for 32-bit DLLs on 64-bit Windows)
+ * - Current working directory of the running process.
+ *
+ *
+ *
+ *
+ * - macOS: Searches in:
+ *
+ * - Directories specified in {@code DYLD_LIBRARY_PATH}.
+ * - System library locations:
+ *
+ * - {@code /usr/lib}
+ * - {@code /usr/local/lib}
+ * - {@code /System/Library/Frameworks/} (for framework-based libraries).
+ *
+ *
+ *
+ *
+ * - Android: Searches in:
+ *
+ * - Application-specific native library directories:
+ *
+ * - {@code /data/data//lib}
+ * - Native library folders inside the APK:
+ *
+ * - {@code /lib/armeabi-v7a/}
+ * - {@code /lib/arm64-v8a/}
+ * - {@code /lib/x86/}
+ * - {@code /lib/x86_64/}
+ *
+ *
+ *
+ *
+ * - System native library locations:
+ *
+ * - {@code /system/lib} (for 32-bit libraries).
+ * - {@code /system/lib64} (for 64-bit libraries).
+ *
+ *
+ *
+ *
+ *
+ *
+ * Usage Considerations
+ *
+ * This approach requires the library to be present on the system beforehand.
+ * If the library is missing, the loading process will fail with an {@code UnsatisfiedLinkError}.
+ * To ensure compatibility across different systems, consider providing a fallback
+ * mechanism to extract the library dynamically when needed via {@link NativeBinaryLoadingListener#onLoadingFailure(NativeBinaryLoader)}.
+ *
+ */
+ SYSTEM_LOAD
}
diff --git a/snaploader/src/main/java/electrostatic4j/snaploader/NativeBinaryLoader.java b/snaploader/src/main/java/electrostatic4j/snaploader/NativeBinaryLoader.java
index d6e2894..4db2668 100644
--- a/snaploader/src/main/java/electrostatic4j/snaploader/NativeBinaryLoader.java
+++ b/snaploader/src/main/java/electrostatic4j/snaploader/NativeBinaryLoader.java
@@ -37,7 +37,6 @@
import java.util.List;
import java.util.jar.JarFile;
import java.util.logging.Level;
-import java.lang.UnsatisfiedLinkError;
import electrostatic4j.snaploader.filesystem.FileExtractionListener;
import electrostatic4j.snaploader.filesystem.FileExtractor;
import electrostatic4j.snaploader.filesystem.FileLocalizingListener;
@@ -51,9 +50,9 @@
import electrostatic4j.snaploader.util.SnapLoaderLogger;
/**
- * A cross-platform utility for extracting and loading native binaries based on
+ * A cross-platform utility for extracting and loading native binaries based on
* the variant properties (OS + ARCH + VM).
- *
+ *
* @author pavl_g.
*/
public class NativeBinaryLoader {
@@ -111,12 +110,12 @@ public NativeBinaryLoader registerNativeLibraries(NativeDynamicLibrary[] nativeD
/**
* Initializes the platform-dependent native dynamic library.
- *
+ *
* @return this instance for chained invocations
* @throws UnSupportedSystemError if the OS is not supported by jSnapLoader
*/
public NativeBinaryLoader initPlatformLibrary() throws UnSupportedSystemError {
- final boolean[] isSystemFound = new boolean[] {false};
+ final boolean[] isSystemFound = new boolean[]{false};
// search for the compatible library using the predefined predicate
// a predicate is a conditional statement composed of multiple propositions
// representing the complete system variant (OS + ARCH + VM).
@@ -151,14 +150,34 @@ public NativeBinaryLoader initPlatformLibrary() throws UnSupportedSystemError {
}
/**
- * Extracts and load the system and the architecture-specific library from the output jar to the [user.dir]
- * according to a loading criterion (incremental-load or clean-extract).
- *
- * @param criterion the initial loading criterion, either {@link LoadingCriterion#INCREMENTAL_LOADING} or {@link LoadingCriterion#CLEAN_EXTRACTION}
+ * Extracts and loads the system and the architecture-specific library from the output jar to a specified directory
+ * according to a loading criterion (incremental-load or clean-extract). The directory is determined by the selected
+ * {@link NativeDynamicLibrary} from the registered platform libraries.
+ *
+ *
+ * Note: The default loading action for Android Systems is loading the libraries from the System directories (i.e., /lib/ABI inside the APK
+ * packages), while the default loading action for other desktop systems is determined by the user through this parameterized function.
+ *
+ *
+ *
+ * Fallback loading routines can be implemented as needed via {@link NativeBinaryLoadingListener#onLoadingFailure(NativeBinaryLoader)}
+ * and are left for the user applications.
+ *
+ *
+ * @param criterion the initial loading criterion, either {@link LoadingCriterion#INCREMENTAL_LOADING}, {@link LoadingCriterion#CLEAN_EXTRACTION}
+ * or {@link LoadingCriterion#SYSTEM_LOAD} for loading native dlls from system directories.
* @return this instance for chained invocations
* @throws IOException if the library to extract is not present in the jar filesystem
*/
public NativeBinaryLoader loadLibrary(LoadingCriterion criterion) throws Exception {
+ if (nativeDynamicLibrary == null || libraryInfo == null) {
+ throw new IllegalArgumentException("Native library data structures cannot be null!");
+ }
+ // commands and loads the library from the system directories
+ if (NativeVariant.Os.isAndroid() || criterion == LoadingCriterion.SYSTEM_LOAD) {
+ loadSystemBinary();
+ return this;
+ }
if (criterion == LoadingCriterion.INCREMENTAL_LOADING && nativeDynamicLibrary.isExtracted()) {
loadBinary(nativeDynamicLibrary);
return this;
@@ -166,10 +185,10 @@ public NativeBinaryLoader loadLibrary(LoadingCriterion criterion) throws Excepti
cleanExtractBinary(nativeDynamicLibrary);
return this;
}
-
+
/**
* Retrieves the native dynamic library object representing the library to extract and load.
- *
+ *
* @return an object representing the platform-dependent native dynamic library
*/
public NativeDynamicLibrary getNativeDynamicLibrary() {
@@ -185,84 +204,99 @@ public void setLoggingEnabled(boolean loggingEnabled) {
SnapLoaderLogger.setLoggingEnabled(loggingEnabled);
}
- /**
- * Enables the retry with clean extraction after a load failure, default value is false.
- *
- * @param retryWithCleanExtraction true to enable the flag, false otherwise
- */
- public void setRetryWithCleanExtraction(boolean retryWithCleanExtraction) {
- this.retryWithCleanExtraction = retryWithCleanExtraction;
- }
-
/**
* Tests the retry with clean extraction flag, default value is false.
- *
+ *
* @return true if enabled, false otherwise
*/
public boolean isRetryWithCleanExtraction() {
return retryWithCleanExtraction;
}
- public List getRegisteredLibraries() {
- return registeredLibraries;
+ /**
+ * Enables the retry with clean extraction after a load failure, default value is false.
+ *
+ * @param retryWithCleanExtraction true to enable the flag, false otherwise
+ */
+ public void setRetryWithCleanExtraction(boolean retryWithCleanExtraction) {
+ this.retryWithCleanExtraction = retryWithCleanExtraction;
}
- public void setNativeBinaryLoadingListener(NativeBinaryLoadingListener nativeBinaryLoadingListener) {
- this.nativeBinaryLoadingListener = nativeBinaryLoadingListener;
+ public List getRegisteredLibraries() {
+ return registeredLibraries;
}
public NativeBinaryLoadingListener getNativeBinaryLoadingListener() {
return nativeBinaryLoadingListener;
}
- public void setSystemDetectionListener(SystemDetectionListener systemDetectionListener) {
- this.systemDetectionListener = systemDetectionListener;
+ public void setNativeBinaryLoadingListener(NativeBinaryLoadingListener nativeBinaryLoadingListener) {
+ this.nativeBinaryLoadingListener = nativeBinaryLoadingListener;
}
public SystemDetectionListener getSystemDetectionListener() {
return systemDetectionListener;
}
- public void setLibraryExtractionListener(FileExtractionListener libraryExtractionListener) {
- this.libraryExtractionListener = libraryExtractionListener;
+ public void setSystemDetectionListener(SystemDetectionListener systemDetectionListener) {
+ this.systemDetectionListener = systemDetectionListener;
}
public FileExtractionListener getLibraryExtractionListener() {
return libraryExtractionListener;
}
- public void setLibraryLocalizingListener(FileLocalizingListener libraryLocalizingListener) {
- this.libraryLocalizingListener = libraryLocalizingListener;
+ public void setLibraryExtractionListener(FileExtractionListener libraryExtractionListener) {
+ this.libraryExtractionListener = libraryExtractionListener;
}
public FileLocalizingListener getLibraryLocalizingListener() {
return libraryLocalizingListener;
}
+ public void setLibraryLocalizingListener(FileLocalizingListener libraryLocalizingListener) {
+ this.libraryLocalizingListener = libraryLocalizingListener;
+ }
+
public void setMaxNumberOfLoadingFailure(int maxNumberOfLoadingFailure) {
this.maxNumberOfLoadingFailure = Math.abs(maxNumberOfLoadingFailure);
}
/**
- * Loads a native binary using the platform-dependent object, for Android;
- * the library is loaded by its basename (variant is managed internally by the android sdk).
- *
+ * Loads a native binary from the system directories into the process virtual
+ * address space using the library basename in a platform-dependent way.
+ */
+ protected void loadSystemBinary() {
+ try {
+ System.loadLibrary(libraryInfo.getBaseName());
+ SnapLoaderLogger.log(Level.INFO, getClass().getName(), "loadSystemBinary", "Successfully loaded library from the system: "
+ + libraryInfo.getBaseName());
+ if (nativeBinaryLoadingListener != null) {
+ nativeBinaryLoadingListener.onLoadingSuccess(this);
+ }
+ } catch (UnsatisfiedLinkError e) {
+ SnapLoaderLogger.log(Level.SEVERE, getClass().getName(), "loadSystemBinary", "Cannot load the dynamic library from the system: "
+ + libraryInfo.getBaseName(), e);
+ // fire failure routine for fallback criteria
+ if (nativeBinaryLoadingListener != null) {
+ nativeBinaryLoadingListener.onLoadingFailure(this);
+ }
+ }
+ }
+
+ /**
+ * Loads a native binary into the virtual process address space from a specified
+ * native library data structure defining the directory path.
+ *
* @param library the platform-specific library to load
- * @throws IOException in case the binary to be extracted is not found on the specified jar
+ * @throws IOException in case the binary to be extracted is not found on the specified jar
* @throws LoadingRetryExhaustionException if the number of loading failure exceeds the specified
* number.
*/
protected void loadBinary(NativeDynamicLibrary library) throws Exception {
try {
- /* sanity-check for android java vm (the dalvik) */
- if (NativeVariant.Os.isAndroid()) {
- System.loadLibrary(libraryInfo.getBaseName());
- SnapLoaderLogger.log(Level.INFO, getClass().getName(),"loadBinary", "Successfully loaded library for Android: "
- + library.getExtractedLibrary());
- return;
- }
System.load(library.getExtractedLibrary());
- SnapLoaderLogger.log(Level.INFO, getClass().getName(),"loadBinary", "Successfully loaded library: "
+ SnapLoaderLogger.log(Level.INFO, getClass().getName(), "loadBinary", "Successfully loaded library: "
+ library.getExtractedLibrary());
if (nativeBinaryLoadingListener != null) {
nativeBinaryLoadingListener.onLoadingSuccess(this);
@@ -292,7 +326,7 @@ protected void loadBinary(NativeDynamicLibrary library) throws Exception {
/**
* Cleanly extracts and loads the native binary to the current [user.dir].
- *
+ *
* @param library the platform-specific library to extract and load
* @throws IOException in case the binary to be extracted is not found on the specified jar, or an
* interrupted I/O operation has occurred
@@ -300,7 +334,7 @@ protected void loadBinary(NativeDynamicLibrary library) throws Exception {
protected void cleanExtractBinary(NativeDynamicLibrary library) throws Exception {
libraryExtractor = initializeLibraryExtractor(library);
SnapLoaderLogger.log(Level.INFO, getClass().getName(), "cleanExtractBinary",
- "File extractor handler initialized!");
+ "File extractor handler initialized!");
/* CLEAR RESOURCES AND RESET OBJECTS ON-EXTRACTION */
libraryExtractor.setExtractionListener(new FileExtractionListener() {
@Override
@@ -360,8 +394,8 @@ public void onExtractionFinalization(FileExtractor fileExtractor, FileLocator fi
/**
* Initializes a filesystem extractor object
* if the filesystem extractor object associated with this loader isn't defined.
- *
- * @param library the native dynamic library to load
+ *
+ * @param library the native dynamic library to load
* @return a new FileExtractor object that represents an output stream provider
* @throws IOException if the jar filesystem to be located is not found, or if the extraction destination is not found
*/
diff --git a/snaploader/src/main/java/electrostatic4j/snaploader/platform/util/DefaultDynamicLibraries.java b/snaploader/src/main/java/electrostatic4j/snaploader/platform/util/DefaultDynamicLibraries.java
index 8cb23e2..4ff7660 100644
--- a/snaploader/src/main/java/electrostatic4j/snaploader/platform/util/DefaultDynamicLibraries.java
+++ b/snaploader/src/main/java/electrostatic4j/snaploader/platform/util/DefaultDynamicLibraries.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2023-2024, The Electrostatic-Sandbox Distributed Simulation Framework, jSnapLoader
+ * Copyright (c) 2023-2025, The Electrostatic-Sandbox Distributed Simulation Framework, jSnapLoader
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -44,6 +44,12 @@
*/
public class DefaultDynamicLibraries {
+ /**
+ * Represents a System Directory Android Library.
+ */
+ public static NativeDynamicLibrary ANDROID_ALL =
+ new NativeDynamicLibrary("", PlatformPredicate.ANDROID);
+
/**
* Represents a linux x86 binary with 64-bit instruction set.
*/
diff --git a/snaploader/src/main/java/electrostatic4j/snaploader/platform/util/NativeVariant.java b/snaploader/src/main/java/electrostatic4j/snaploader/platform/util/NativeVariant.java
index 07a10b8..ea09558 100644
--- a/snaploader/src/main/java/electrostatic4j/snaploader/platform/util/NativeVariant.java
+++ b/snaploader/src/main/java/electrostatic4j/snaploader/platform/util/NativeVariant.java
@@ -87,6 +87,7 @@ public enum NativeVariant {
private static final String Linux = "Linux";
private static final String Windows = "Windows";
private static final String Mac = "Mac";
+ private static final String WebOs = "WebOs";
private static final String Dalvik = "Dalvik";
private final String property;
@@ -136,6 +137,37 @@ public static boolean isMac() {
public static boolean isAndroid() {
return JVM.getProperty().contains(NativeVariant.Dalvik);
}
+
+ /**
+ * Tests whether the current system runtime is Desktop. A
+ * system runtime is said to be desktop if it's not an Android,
+ * and not Web-OS, and not iOS.
+ *
+ * @return true if the current runtime is a desktop binary, false otherwise.
+ */
+ public static boolean isDesktop() {
+ return !isAndroid() && !isWebOs() && !isIos();
+ }
+
+ /**
+ * Contemplated to test whether the current system runtime is
+ * a web os.
+ *
+ * @return true if web-os; false otherwise. Current value is constantly false.
+ */
+ public static boolean isWebOs() {
+ return false;
+ }
+
+ /**
+ * Contemplated to test whether the current system runtime is
+ * an iOS os.
+ *
+ * @return true if iOS; false otherwise. Current value is constantly false.
+ */
+ public static boolean isIos() {
+ return false;
+ }
}
/**
diff --git a/snaploader/src/main/java/electrostatic4j/snaploader/platform/util/PackageVariant.java b/snaploader/src/main/java/electrostatic4j/snaploader/platform/util/PackageVariant.java
new file mode 100644
index 0000000..bdfa918
--- /dev/null
+++ b/snaploader/src/main/java/electrostatic4j/snaploader/platform/util/PackageVariant.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2023-2025, The Electrostatic-Sandbox Distributed Simulation Framework, jSnapLoader
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'Electrostatic-Sandbox' nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package electrostatic4j.snaploader.platform.util;
+
+/**
+ * A namespace class exposing checks for the native window
+ * currently in runtime; this could give some more insights
+ * about the type of the framework the application is running
+ * on.
+ *
+ * @author pavl_g.
+ */
+public final class PackageVariant {
+
+ private static final String FLUTTER_ACTIVITY_PATH = "io.flutter.embedding.android.FlutterActivity";
+ private static final String JME_CONTEXT_PATH = "com.jme3.system.JmeContext";
+ private static final String ANDROID_CONTEXT_PATH = "android.content.Context";
+ private static final String JAVA_FX_CONTEXT_PATH = "javafx.application.Application";
+ private static final String JAVA_AWT_CONTEXT_PATH = "java.awt.Frame";
+ private static final String GWT_CONTEXT_PATH = "com.google.gwt.user.client.Window";
+
+ private PackageVariant() {
+ }
+
+ public static boolean hasJavaFxWindow() {
+ try {
+ return ClassLoader.getSystemClassLoader().loadClass(PackageVariant.JAVA_FX_CONTEXT_PATH) != null;
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+ }
+
+ public static boolean hasJavaAWTWindow() {
+ try {
+ return ClassLoader.getSystemClassLoader().loadClass(PackageVariant.JAVA_AWT_CONTEXT_PATH) != null;
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+ }
+
+ public static boolean hasAndroidActivity() {
+ try {
+ return ClassLoader.getSystemClassLoader().loadClass(PackageVariant.ANDROID_CONTEXT_PATH) != null;
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+ }
+
+ public static boolean hasGWTContext() {
+ try {
+ return ClassLoader.getSystemClassLoader().loadClass(PackageVariant.GWT_CONTEXT_PATH) != null;
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+ }
+
+ public static boolean hasJmeContext() {
+ try {
+ return ClassLoader.getSystemClassLoader().loadClass(PackageVariant.JME_CONTEXT_PATH) != null;
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+ }
+
+ public static boolean hasFlutterActivity() {
+ try {
+ return ClassLoader.getSystemClassLoader().loadClass(PackageVariant.FLUTTER_ACTIVITY_PATH) != null;
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+ }
+
+ public static boolean hasAndroidActivityOnly() {
+ return hasAndroidActivity() && !hasFlutterActivity();
+ }
+
+ public static boolean hasJmeAndroidContext() {
+ return hasAndroidActivity() && hasJmeContext();
+ }
+
+ public static boolean hasJmeFlutterContext() {
+ return hasFlutterActivity() && hasJmeContext();
+ }
+}
\ No newline at end of file
diff --git a/snaploader/src/main/java/electrostatic4j/snaploader/platform/util/PlatformPredicate.java b/snaploader/src/main/java/electrostatic4j/snaploader/platform/util/PlatformPredicate.java
index 25de2c2..acf6aeb 100644
--- a/snaploader/src/main/java/electrostatic4j/snaploader/platform/util/PlatformPredicate.java
+++ b/snaploader/src/main/java/electrostatic4j/snaploader/platform/util/PlatformPredicate.java
@@ -42,24 +42,34 @@
public final class PlatformPredicate {
/**
- * Alias object for Linux on X86 Chipset.
+ * Alias object for Linux on X86 Desktop Chipset.
*/
- public static final PlatformPredicate LINUX_X86 = new PlatformPredicate(NativeVariant.Os.isLinux() && NativeVariant.Cpu.isX86());
+ public static final PlatformPredicate LINUX_X86 = new PlatformPredicate(NativeVariant.Os.isDesktop() &&
+ NativeVariant.Os.isLinux() && NativeVariant.Cpu.isX86());
/**
- * Alias object for Linux on X86-64 Chipset.
+ * Alias object for Android all variants (i.e., x86, AARCH64, ARM32)
+ * when using {@link Runtime#loadLibrary(String)}.
*/
- public static final PlatformPredicate LINUX_X86_64 = new PlatformPredicate(NativeVariant.Os.isLinux() && NativeVariant.Cpu.isAMD() && NativeVariant.Cpu.is64());
+ public static final PlatformPredicate ANDROID = new PlatformPredicate(NativeVariant.Os.isAndroid());
/**
- * Alias object for Linux on arm-32 Chipset.
+ * Alias object for Linux on X86-64 Desktop Chipset.
*/
- public static final PlatformPredicate LINUX_ARM_32 = new PlatformPredicate(NativeVariant.Os.isLinux() && NativeVariant.Cpu.isARM());
+ public static final PlatformPredicate LINUX_X86_64 = new PlatformPredicate(NativeVariant.Os.isDesktop() &&
+ NativeVariant.Os.isLinux() && NativeVariant.Cpu.isAMD() && NativeVariant.Cpu.is64());
/**
- * Alias object for Linux on arm-64 Chipset.
+ * Alias object for Linux on arm-32 Desktop Chipset.
*/
- public static final PlatformPredicate LINUX_ARM_64 = new PlatformPredicate(NativeVariant.Os.isLinux() && NativeVariant.Cpu.isARM() && NativeVariant.Cpu.is64());
+ public static final PlatformPredicate LINUX_ARM_32 = new PlatformPredicate(NativeVariant.Os.isDesktop() &&
+ NativeVariant.Os.isLinux() && NativeVariant.Cpu.isARM());
+
+ /**
+ * Alias object for Linux on arm-64 Desktop Chipset.
+ */
+ public static final PlatformPredicate LINUX_ARM_64 = new PlatformPredicate(NativeVariant.Os.isDesktop() &&
+ NativeVariant.Os.isLinux() && NativeVariant.Cpu.isARM() && NativeVariant.Cpu.is64());
/**
* Alias object for Linux on RiscV-32 Chipset.
@@ -139,7 +149,7 @@ public PlatformPredicate(boolean predicate) {
* with one or more instruction-set extensions. The result is true if and
* only if the base predicate is true and all named extensions are present.
*
- * @param base a pre-existing predicate (not null)
+ * @param base a pre-existing predicate (not null)
* @param isaExtensions names of required ISA extensions
*/
public PlatformPredicate(PlatformPredicate base, String... isaExtensions) {