static void loadLibrary(final String tempDirectory) { if (PlatformDetector.OS.isAndroid()) { System.loadLibrary("j2v8"); return; } StringBuffer message = new StringBuffer(); // try loading a vendor-specific library first if (tryLoad(true, message)) return; // if there is no vendor-specific library, just try to load the default OS library if (tryLoad(false, message)) return; String path = null; if (tempDirectory != null) { path = tempDirectory; } else { path = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$ } // try extracting a vendor-specific library first if (extract(path, true, message)) return; // if there is no vendor-specific library, just try to extract the default OS library if (extract(path, false, message)) return; /* Failed to find the library */ throw new UnsatisfiedLinkError("Could not load J2V8 library. Reasons: " + message.toString()); //$NON-NLS-1$ }
public static String getName() { if (OS.isWindows()) { return "microsoft"; } if (OS.isMac()) { return "apple"; } if (OS.isLinux()) { return getLinuxOsReleaseId(); } if (OS.isAndroid()) { return "google"; } throw new UnsatisfiedLinkError("Unsupported vendor: " + getName()); }
public static String getLibFileExtension() { if (isWindows()) { return "dll"; } if (isMac()) { return "dylib"; } if (isLinux() || isAndroid() || isNativeClient()) { return "so"; } throw new UnsatisfiedLinkError("Unsupported platform library-extension for: " + getName()); } }
static void loadLibrary(final String tempDirectory) { if (PlatformDetector.OS.isAndroid()) { System.loadLibrary("j2v8"); return; } StringBuffer message = new StringBuffer(); // try loading a vendor-specific library first if (tryLoad(true, message)) return; // if there is no vendor-specific library, just try to load the default OS library if (tryLoad(false, message)) return; String path = null; if (tempDirectory != null) { path = tempDirectory; } else { path = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$ } // try extracting a vendor-specific library first if (extract(path, true, message)) return; // if there is no vendor-specific library, just try to extract the default OS library if (extract(path, false, message)) return; /* Failed to find the library */ throw new UnsatisfiedLinkError("Could not load J2V8 library. Reasons: " + message.toString()); //$NON-NLS-1$ }
@Test public void testLinuxLibNameStructure() throws Exception { // skip this test on android if (PlatformDetector.OS.isAndroid()) { return; } System.setProperty("os.name", "Linux"); System.setProperty("java.specification.vendor", "OSS"); System.setProperty("os.arch", "x64"); final String os_release_test_path = "./test-mockup-os-release"; final String test_vendor = "linux_vendor"; // mock /etc/os-release file releaseFilesField.set(null, new String[] { os_release_test_path }); PrintWriter out = new PrintWriter(os_release_test_path); out.println( "NAME=The-Linux-Vendor\n" + "VERSION=\"towel_42\"\n" + "ID=" + test_vendor + "\n" + "VERSION_ID=42\n" ); out.close(); performTests(Platform.LINUX, test_vendor, ".so"); }
public static String getName() { if (OS.isWindows()) { return "microsoft"; } if (OS.isMac()) { return "apple"; } if (OS.isLinux()) { return getLinuxOsReleaseId(); } if (OS.isAndroid()) { return "google"; } throw new UnsatisfiedLinkError("Unsupported vendor: " + getName()); }
public static String getLibFileExtension() { if (isWindows()) { return "dll"; } if (isMac()) { return "dylib"; } if (isLinux() || isAndroid() || isNativeClient()) { return "so"; } throw new UnsatisfiedLinkError("Unsupported platform library-extension for: " + getName()); } }
/** * NOTE: we need to skip these tests, because on Android the SystemClassLoader * can not be cast to an URLClassLoader and some other issues (see TestClassLoader below) */ private static boolean skipTest() { return PlatformDetector.OS.isAndroid(); }