Tabnine Logo
PlatformDetector$OS
Code IndexAdd Tabnine to your IDE (free)

How to use
PlatformDetector$OS
in
com.eclipsesource.v8

Best Java code snippets using com.eclipsesource.v8.PlatformDetector$OS (Showing top 20 results out of 315)

origin: eclipsesource/J2V8

public static boolean isNativeClient() {
  return getName().equals(Platform.NATIVE_CLIENT);
}
origin: eclipsesource/J2V8

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$
}
origin: eclipsesource/J2V8

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());
}
origin: eclipsesource/J2V8

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$
}
origin: eclipsesource/J2V8

@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");
}
origin: eclipsesource/J2V8

/**
 * Returns the base-name for the native J2V8 library file.
 * @param withLinuxVendor include/exclude the {vendor} part from the returned filename
 * <p>NOTE: Vendors are only included for linux systems</p>
 * @return The filename string has the following structure:
 * <pre><code>{arch}-[vendor]-{operating_system}</pre></code>
 */
public static String computeLibraryShortName(boolean withLinuxVendor) {
  String prefix = "j2v8";
  String vendor = withLinuxVendor && PlatformDetector.OS.isLinux() ? PlatformDetector.Vendor.getName() : null;
  String os = PlatformDetector.OS.getName();
  String arch = PlatformDetector.Arch.getName();
  final String separator = "-";
  return
    prefix +
    (vendor != null ? separator + vendor : "") +
    separator + os +
    separator + arch;
}
origin: eclipsesource/J2V8

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());
}
origin: eclipsesource/J2V8

public static boolean isNativeClient() {
  return getName().equals(Platform.NATIVE_CLIENT);
}
origin: eclipsesource/J2V8

private static boolean skipTest() {
  return "android".equalsIgnoreCase(PlatformDetector.OS.getName());
}
origin: eclipsesource/J2V8

public static boolean isMac() {
  return getName().equals(Platform.MACOSX);
}
origin: eclipsesource/J2V8

@Test
public void testGetOSUnknown() {
  assumeFalse(skipMessage, skipTest()); // conditional skip
  System.setProperty("os.name", "???");
  System.setProperty("java.specification.vendor", "???");
  try {
    PlatformDetector.OS.getName();
  } catch (Error e) {
    assertTrue("Expected UnsatisfiedLinkError", e instanceof UnsatisfiedLinkError);
    assertTrue(e.getMessage().startsWith("Unsupported platform/vendor"));
    return;
  }
  fail("Expected exception");
}
origin: eclipsesource/J2V8

public static String computeLibraryFullName(boolean withLinuxVendor) {
  return "lib" + computeLibraryShortName(withLinuxVendor) + "." + PlatformDetector.OS.getLibFileExtension();
}
origin: eclipsesource/J2V8

public static boolean isLinux() {
  return getName().equals(Platform.LINUX);
}
origin: eclipsesource/J2V8

public static boolean isWindows() {
  return getName().equals(Platform.WINDOWS);
}
origin: eclipsesource/J2V8

public static boolean isAndroid() {
  return getName().equals(Platform.ANDROID);
}
origin: eclipsesource/J2V8

private static boolean skipTest() {
  return "android".equalsIgnoreCase(PlatformDetector.OS.getName());
}
origin: eclipsesource/J2V8

  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());
  }
}
origin: eclipsesource/J2V8

@Test
public void testGetOSWindows() {
  assumeFalse(skipMessage, skipTest()); // conditional skip
  System.setProperty("os.name", "Windows");
  System.setProperty("java.specification.vendor", "Microsoft");
  assertEquals("windows", PlatformDetector.OS.getName());
}
origin: eclipsesource/J2V8

@Test
public void testGetOSFileExtensionAndroid() {
  System.setProperty("os.name", "naclthe android project");
  System.setProperty("java.specification.vendor", "The Android Project");
  assertEquals("so", PlatformDetector.OS.getLibFileExtension());
}
origin: eclipsesource/J2V8

@Test
public void testGetOSAndroid() {
  System.setProperty("os.name", "Linux");
  System.setProperty("java.specification.vendor", "The Android Project");
  assertEquals("android", PlatformDetector.OS.getName());
}
com.eclipsesource.v8PlatformDetector$OS

Most used methods

  • getLibFileExtension
  • getName
  • isAndroid
  • isLinux
  • isMac
  • isNativeClient
  • isWindows

Popular in Java

  • Reading from database using SQL prepared statement
  • onRequestPermissionsResult (Fragment)
  • getApplicationContext (Context)
  • requestLocationUpdates (LocationManager)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now