com.google.common.base.StandardSystemProperty Java Examples

The following examples show how to use com.google.common.base.StandardSystemProperty. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RMNodeUpdater.java    From scheduling with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Build the java subprocess which will be spawned from this JVM.
 * @param args current JVM arguments
 * @param jarFile up-to-date node jar file
 * @return
 */
private ProcessBuilder generateSubProcess(String[] args, String jarFile) {
    ProcessBuilder pb;
    List<String> command = new ArrayList<>();
    if (StandardSystemProperty.OS_NAME.value().toLowerCase().contains("windows")) {
        command.add((new File(StandardSystemProperty.JAVA_HOME.value(), "bin/java.exe")).getAbsolutePath());
    } else {
        command.add((new File(StandardSystemProperty.JAVA_HOME.value(), "bin/java")).getAbsolutePath());
    }
    command.addAll(buildJVMOptions());
    command.add("-jar");
    command.add(jarFile);
    command.addAll(removeOptionsUnrecognizedByRMNodeStarter(args));
    logger.info("Starting Java command: " + command);
    pb = new ProcessBuilder(command);
    pb.inheritIO();
    File nodeJarParentFolder = (new File(jarFile)).getParentFile();
    pb.directory(nodeJarParentFolder);
    if (pb.environment().containsKey("CLASSPATH")) {
        pb.environment().remove("CLASSPATH");
    }
    return pb;
}
 
Example #2
Source File: AppBundleGenerator.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
public static AppBundleGenerator of(DremioConfig config) {

    List<String> nativeLibraryPath = Optional.ofNullable(StandardSystemProperty.JAVA_LIBRARY_PATH.value())
        .map(p -> Arrays.asList(p.split(File.pathSeparator)))
        .orElse(Collections.emptyList());

    final Path pluginsPath = DremioConfig.getPluginsRootPath();

    return new AppBundleGenerator(
        AppBundleGenerator.class.getClassLoader(),
        config.getStringList(DremioConfig.YARN_APP_CLASSPATH_PREFIX),
        config.getStringList(DremioConfig.YARN_APP_CLASSPATH),
        nativeLibraryPath,
        pluginsPath
    );
  }
 
Example #3
Source File: KerberosUtils.java    From imhotep with Apache License 2.0 6 votes vote down vote up
public static void loginFromKeytab(@Nullable String principal, @Nullable String keytabPath) throws IOException {
    // if one of these is set, then assume they meant to set both
    if (!Strings.isNullOrEmpty(principal) || !Strings.isNullOrEmpty(keytabPath)) {
        log.info("Using properties from configuration file");
        with(principal, keytabPath);
    } else {
        // look for the file to be readable for this user
        final String username = StandardSystemProperty.USER_NAME.value();
        final File keytabFile = new File(String.format("/etc/local_keytabs/%1$s/%1$s.keytab", username));
        log.info("Checking for user " + username + " keytab, settings at " + keytabFile.getAbsolutePath());
        if (keytabFile.exists() && keytabFile.canRead()) {
            with(username + "/[email protected]", keytabFile.getAbsolutePath());
        } else {
            log.warn("Unable to find user keytab, maybe the keytab is in ticket from klist");
        }
    }
}
 
Example #4
Source File: RemoteSession.java    From selenium with Apache License 2.0 6 votes vote down vote up
protected RemoteSession(
    Dialect downstream,
    Dialect upstream,
    HttpHandler codec,
    SessionId id,
    Map<String, Object> capabilities) {
  this.downstream = Require.nonNull("Downstream dialect", downstream);
  this.upstream = Require.nonNull("Upstream dialect", upstream);
  this.codec = Require.nonNull("Codec", codec);
  this.id = Require.nonNull("Session id", id);
  this.capabilities = Require.nonNull("Capabilities", capabilities);

  File tempRoot = new File(StandardSystemProperty.JAVA_IO_TMPDIR.value(), id.toString());
  Require.stateCondition(tempRoot.mkdirs(), "Could not create directory %s", tempRoot);
  this.filesystem = TemporaryFilesystem.getTmpFsBasedOn(tempRoot);

  CommandExecutor executor = new ActiveSessionCommandExecutor(this);
  this.driver = new Augmenter().augment(new RemoteWebDriver(
      executor,
      new ImmutableCapabilities(getCapabilities())));
}
 
Example #5
Source File: InMemorySession.java    From selenium with Apache License 2.0 6 votes vote down vote up
private InMemorySession(WebDriver driver, Capabilities capabilities, Dialect downstream) {
  this.driver = Require.nonNull("Driver", driver);

  Capabilities caps;
  if (driver instanceof HasCapabilities) {
    caps = ((HasCapabilities) driver).getCapabilities();
  } else {
    caps = capabilities;
  }

  this.capabilities = caps.asMap().entrySet().stream()
      .filter(e -> e.getValue() != null)
      .collect(ImmutableMap.toImmutableMap(Map.Entry::getKey, Map.Entry::getValue));

  this.id = new SessionId(UUID.randomUUID().toString());
  this.downstream = Require.nonNull("Downstream dialect", downstream);

  File tempRoot = new File(StandardSystemProperty.JAVA_IO_TMPDIR.value(), id.toString());
  Require.stateCondition(tempRoot.mkdirs(), "Could not create directory %s", tempRoot);
  this.filesystem = TemporaryFilesystem.getTmpFsBasedOn(tempRoot);

  this.handler = new JsonHttpCommandHandler(
      new PretendDriverSessions(),
      LOG);
}
 
Example #6
Source File: CoreSelfTest.java    From selenium with Apache License 2.0 6 votes vote down vote up
@Test
public void executeTests() throws IOException {
  String testBase = server.whereIs("/common/rc/tests");
  Path outputFile = Paths.get(StandardSystemProperty.JAVA_IO_TMPDIR.value())
    .resolve("core-test-suite" + browser.replace('*', '-') + ".html");
  if (Files.exists(outputFile)) {
    Files.delete(outputFile);
  }
  Files.createDirectories(outputFile.getParent());

  String result = new HTMLLauncher()
    .runHTMLSuite(
      browser,
      // We need to do this because the path relativizing code in java.net.URL is
      // We need to do this because the path relativizing code in java.net.URL is
      // clearly having a bad day. "/selenium-server/tests" appended to "../tests/"
      // ends up as "/tests" rather than "/selenium-server/tests" as you'd expect.
      testBase + "/TestSuite.html",
      testBase + "/TestSuite.html",
      outputFile.toFile(),
      TimeUnit.MINUTES.toSeconds(5),
      null);

  assertEquals("PASSED", result);
}
 
Example #7
Source File: BuildEnvironmentDescription.java    From buck with Apache License 2.0 6 votes vote down vote up
public static BuildEnvironmentDescription of(
    ExecutionEnvironment executionEnvironment,
    ImmutableList<String> cacheModes,
    ImmutableMap<String, String> extraData) {
  Optional<Boolean> buckDirty;
  String dirty = System.getProperty("buck.git_dirty", "unknown");
  if (dirty.equals("1")) {
    buckDirty = Optional.of(true);
  } else if (dirty.equals("0")) {
    buckDirty = Optional.of(false);
  } else {
    buckDirty = Optional.empty();
  }

  return of(
      executionEnvironment.getUsername(),
      executionEnvironment.getHostname(),
      executionEnvironment.getPlatform().getPrintableName().toLowerCase().replace(' ', '_'),
      executionEnvironment.getAvailableCores(),
      executionEnvironment.getTotalMemory(),
      buckDirty,
      System.getProperty("buck.git_commit", "unknown"),
      Objects.requireNonNull(StandardSystemProperty.JAVA_VM_VERSION.value()),
      cacheModes,
      extraData);
}
 
Example #8
Source File: OverridesTest.java    From auto with Apache License 2.0 6 votes vote down vote up
private void evaluate(File dummySourceFile) throws Throwable {
  JavaCompiler compiler = new EclipseCompiler();
  StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, UTF_8);
  // This hack is only needed in a Google-internal Java 8 environment where symbolic links make
  // it hard for ecj to find the boot class path. Elsewhere it is unnecessary but harmless.
  File rtJar = new File(StandardSystemProperty.JAVA_HOME.value() + "/lib/rt.jar");
  if (rtJar.exists()) {
    List<File> bootClassPath = ImmutableList.<File>builder()
        .add(rtJar)
        .addAll(fileManager.getLocation(StandardLocation.PLATFORM_CLASS_PATH))
        .build();
    fileManager.setLocation(StandardLocation.PLATFORM_CLASS_PATH, bootClassPath);
  }
  Iterable<? extends JavaFileObject> sources = fileManager.getJavaFileObjects(dummySourceFile);
  JavaCompiler.CompilationTask task =
      compiler.getTask(null, fileManager, null, null, null, sources);
  EcjTestProcessor processor = new EcjTestProcessor(statement);
  task.setProcessors(ImmutableList.of(processor));
  assertThat(task.call()).isTrue();
  processor.maybeThrow();
}
 
Example #9
Source File: TestYarnDefaultsConfigurator.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
@Test
public void testMaprAppClasspath() {
  assumeMaprProfile();

  final Set<String> jars = Arrays.stream(StandardSystemProperty.JAVA_CLASS_PATH.value().split(":"))
      .map(Paths::get)
      .map(Path::getFileName)
      .map(Path::toString)
      .collect(Collectors.toSet());

  // Sanity check to make sure that jars required to start app are present in the test classpath
  // test itself does not require those jars but it should prevent naming mismatches
  final String appClassPath = YarnDefaultsConfigurator.MapRYarnDefaults.getAppClassPath();
  for(final String path : appClassPath.split(",")) {
    // Just checking filename is present since the layout depends on the actual distribution config
    final String filename = Paths.get(path).getFileName().toString();

    assertTrue(format("jar %s not present in classpath (%s)", filename, jars), checkExist(jars, filename));
  }
}
 
Example #10
Source File: ByteStoreManager.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
private void verifyDBOwner(File dbDirectory) throws IOException {
  // Skip file owner check if running on Windows
  if (StandardSystemProperty.OS_NAME.value().contains("Windows")) {
    return;
  }

  String procUser = StandardSystemProperty.USER_NAME.value();
  File[] dbFiles = dbDirectory.listFiles();
  for (File dbFile : dbFiles) {
    if (dbFile.isDirectory()) {
      continue;
    }

    String dbOwner = Files.getOwner(dbFile.toPath()).getName();
    if (!procUser.equals(dbOwner)) {
      throw new DatastoreException(
        String.format("Process user (%s) doesn't match local catalog db owner (%s).  Please run process as %s.",
          procUser, dbOwner, dbOwner));
    }

    // Break once verified, we assume the rest are owned by the same user.
    break;
  }
}
 
Example #11
Source File: Main.java    From copybara with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the base directory to be used by Copybara to write execution related files (Like
 * logs).
 */
private String getBaseExecDir() {
  // In this case we are not using GeneralOptions.getEnvironment() because we still haven't built
  // the options, but it's fine. This is the tool's Main and is also injecting System.getEnv()
  // to the options, so the value is the same.
  String userHome = StandardSystemProperty.USER_HOME.value();

  switch (StandardSystemProperty.OS_NAME.value()) {
    case "Linux":
      String xdgCacheHome = System.getenv("XDG_CACHE_HOME");
      return Strings.isNullOrEmpty(xdgCacheHome)
          ? userHome + "/.cache/" + COPYBARA_NAMESPACE
          : xdgCacheHome + COPYBARA_NAMESPACE;
    case "Mac OS X":
      return userHome + "/Library/Logs/" + COPYBARA_NAMESPACE;
    default:
      return "/var/tmp/" + COPYBARA_NAMESPACE;
  }
}
 
Example #12
Source File: WorkflowTest.java    From copybara with Apache License 2.0 6 votes vote down vote up
@Test
public void testEmptyDescriptionForFolderDestination() throws Exception {
  origin.singleFileChange(/*timestamp=*/44, "commit 1", "bar.txt", "1");
  options
      .setWorkdirToRealTempDir()
      .setHomeDir(StandardSystemProperty.USER_HOME.value());
  new SkylarkTestExecutor(options).loadConfig("core.workflow(\n"
      + "    name = 'foo',\n"
      + "    origin = testing.origin(),\n"
      + "    destination = folder.destination(),\n"
      + "    authoring = " + authoring + ",\n"
      + "    transformations = [metadata.replace_message(''),],\n"
      + ")\n")
      .getMigration("foo")
      .run(workdir, ImmutableList.of());
}
 
Example #13
Source File: JvmTool.java    From glowroot with Apache License 2.0 6 votes vote down vote up
private static List<String> buildClasspath(@Nullable File glowrootJarFile) {
    if (glowrootJarFile == null || !isShaded()) {
        // this is just to support testing
        List<String> classpath = Lists.newArrayList();
        if (glowrootJarFile != null) {
            classpath.add(glowrootJarFile.getAbsolutePath());
        }
        classpath.addAll(splitClasspath(StandardSystemProperty.JAVA_CLASS_PATH.value()));
        for (String jvmArg : ManagementFactory.getRuntimeMXBean().getInputArguments()) {
            if (jvmArg.startsWith("-Xbootclasspath/a:")) {
                classpath.addAll(
                        splitClasspath(jvmArg.substring("-Xbootclasspath/a:".length())));
                break;
            }
        }
        return classpath;
    } else {
        return ImmutableList.of(glowrootJarFile.getAbsolutePath());
    }
}
 
Example #14
Source File: WorkflowTest.java    From copybara with Apache License 2.0 6 votes vote down vote up
@Test
public void migrationIdentityWithUser() throws Exception {
  // Squash always sets the default author for the commit but not in the release notes
  origin.addSimpleChange(/*timestamp*/ 1);
  String withUser = workflow().getMigrationIdentity(origin.resolve(HEAD), transformWork);

  options.workflowOptions.workflowIdentityUser = StandardSystemProperty.USER_NAME.value();

  assertThat(withUser).isEqualTo(workflow().getMigrationIdentity(origin.resolve(HEAD),
      transformWork));

  options.workflowOptions.workflowIdentityUser = "TEST";

  String withOtherUser = workflow().getMigrationIdentity(origin.resolve(HEAD), transformWork);

  assertThat(withOtherUser).isNotEqualTo(withUser);
}
 
Example #15
Source File: EnvironmentCreator.java    From glowroot with Apache License 2.0 6 votes vote down vote up
private static JavaInfo createJavaInfo(String glowrootVersion, JvmConfig jvmConfig,
        RuntimeMXBean runtimeMXBean) {
    String jvm = "";
    String javaVmName = StandardSystemProperty.JAVA_VM_NAME.value();
    if (javaVmName != null) {
        jvm = javaVmName + " (" + StandardSystemProperty.JAVA_VM_VERSION.value() + ", "
                + System.getProperty("java.vm.info") + ")";
    }
    String javaVersion = StandardSystemProperty.JAVA_VERSION.value();
    String heapDumpPath = getHeapDumpPathFromCommandLine();
    if (heapDumpPath == null) {
        String javaTempDir =
                MoreObjects.firstNonNull(StandardSystemProperty.JAVA_IO_TMPDIR.value(), ".");
        heapDumpPath = new File(javaTempDir).getAbsolutePath();
    }
    return JavaInfo.newBuilder()
            .setVersion(Strings.nullToEmpty(javaVersion))
            .setVm(jvm)
            .addAllArg(Masking.maskJvmArgs(runtimeMXBean.getInputArguments(),
                    jvmConfig.maskSystemProperties()))
            .setHeapDumpDefaultDir(heapDumpPath)
            .setGlowrootAgentVersion(glowrootVersion)
            .build();
}
 
Example #16
Source File: MainEntryPoint.java    From glowroot with Apache License 2.0 6 votes vote down vote up
private static StringBuilder getJavaVersion() {
    StringBuilder sb = new StringBuilder();
    sb.append(StandardSystemProperty.JAVA_VERSION.value());
    String vendor = System.getProperty("java.vm.vendor");
    String os = System.getProperty("os.name");
    boolean appendVendor = !Strings.isNullOrEmpty(vendor);
    boolean appendOS = !Strings.isNullOrEmpty(os);
    if (appendVendor && appendOS) {
        sb.append(" (");
        if (appendVendor) {
            sb.append(vendor);
            if (appendOS) {
                sb.append(" / ");
            }
        }
        if (appendOS) {
            sb.append(os);
        }
        sb.append(")");
    }
    return sb;
}
 
Example #17
Source File: TempDirs.java    From glowroot with Apache License 2.0 6 votes vote down vote up
public static File createTempDir(String prefix) throws IOException {
    final int tempDirAttempts = 10000;
    String javaTempDir =
            MoreObjects.firstNonNull(StandardSystemProperty.JAVA_IO_TMPDIR.value(), ".");
    File baseDir = new File(javaTempDir);
    String baseName = prefix + "-" + System.currentTimeMillis() + "-";
    for (int counter = 0; counter < tempDirAttempts; counter++) {
        File tempDir = new File(baseDir, baseName + counter);
        if (tempDir.mkdir()) {
            return tempDir;
        }
    }
    throw new IOException(
            "Failed to create directory within " + tempDirAttempts + " attempts (tried "
                    + baseName + "0 to " + baseName + (tempDirAttempts - 1) + ')');
}
 
Example #18
Source File: KurentoClient.java    From kurento-java with Apache License 2.0 6 votes vote down vote up
public static synchronized String getKmsUrl(String id, Properties properties) {

    if (properties == null) {
      properties = new Properties();
    }

    if (kmsUrlLoader == null) {

      Path configFile =
          Paths.get(StandardSystemProperty.USER_HOME.value(), ".kurento", "config.properties");

      kmsUrlLoader = new KmsUrlLoader(configFile);
    }

    Object load = properties.get("loadPoints");
    if (load == null) {
      return kmsUrlLoader.getKmsUrl(id);
    } else {
      if (load instanceof Number) {
        return kmsUrlLoader.getKmsUrlLoad(id, ((Number) load).intValue());
      } else {
        return kmsUrlLoader.getKmsUrlLoad(id, Integer.parseInt(load.toString()));
      }
    }
  }
 
Example #19
Source File: DataPopulatorUtils.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
public static void addDefaultDremioUser(
  final UserService userService,
  final NamespaceService namespaceService) throws Exception {
  if (!userService.hasAnyUser()) {
    createUserIfNotExists(
      userService,
      namespaceService,
      DEFAULT_USER_NAME,
      PASSWORD,
      DEFAULT_USER_FIRSTNAME,
      DEFAULT_USER_LASTNAME);
    // Special case for regression until we move away from views as physical files.
    // View expansion requires the user who wrote the file on the filesystem
    // to be present in the usergroup db
    if (ADD_PROCESS_USER) {
      createUserIfNotExists(
        userService,
        namespaceService,
        StandardSystemProperty.USER_NAME.value(),
        PASSWORD,
        DEFAULT_USER_FIRSTNAME,
        DEFAULT_USER_LASTNAME);
    }
  }
}
 
Example #20
Source File: PrestoSystemRequirements.java    From presto with Apache License 2.0 6 votes vote down vote up
private static void verifyOsArchitecture()
{
    String osName = StandardSystemProperty.OS_NAME.value();
    String osArch = StandardSystemProperty.OS_ARCH.value();
    if ("Linux".equals(osName)) {
        if (!ImmutableSet.of("amd64", "aarch64", "ppc64le").contains(osArch)) {
            failRequirement("Presto requires amd64, aarch64, or ppc64le on Linux (found %s)", osArch);
        }
        if ("aarch64".equals(osArch)) {
            warnRequirement("Support for the ARM architecture is experimental");
        }
        else if ("ppc64le".equals(osArch)) {
            warnRequirement("Support for the POWER architecture is experimental");
        }
    }
    else if ("Mac OS X".equals(osName)) {
        if (!"x86_64".equals(osArch)) {
            failRequirement("Presto requires x86_64 on Mac OS X (found %s)", osArch);
        }
    }
    else {
        failRequirement("Presto requires Linux or Mac OS X (found %s)", osName);
    }
}
 
Example #21
Source File: ClasspathCache.java    From glowroot with Apache License 2.0 5 votes vote down vote up
@GuardedBy("this")
private void updateCacheWithClasspathClasses(Multimap<String, Location> newClassNameLocations) {
    String javaClassPath = StandardSystemProperty.JAVA_CLASS_PATH.value();
    if (javaClassPath == null) {
        return;
    }
    for (String path : Splitter.on(File.pathSeparatorChar).split(javaClassPath)) {
        File file = new File(path);
        Location location = getLocationFromFile(file);
        if (location != null) {
            loadClassNames(location, newClassNameLocations);
        }
    }
}
 
Example #22
Source File: Weaver.java    From glowroot with Apache License 2.0 5 votes vote down vote up
private static File getTempFile(String className, String prefix, String suffix) {
    String tmpDirProperty = StandardSystemProperty.JAVA_IO_TMPDIR.value();
    File tmpDir = tmpDirProperty == null ? new File(".") : new File(tmpDirProperty);
    String simpleName;
    int index = className.lastIndexOf('/');
    if (index == -1) {
        simpleName = className;
    } else {
        simpleName = className.substring(index + 1);
    }
    return new File(tmpDir, prefix + simpleName + suffix);
}
 
Example #23
Source File: WeaverTest.java    From glowroot with Apache License 2.0 5 votes vote down vote up
@Test
// test weaving against jdk 1.7 bytecode with stack frames
public void shouldWeaveBytecodeWithStackFrames5() throws Exception {
    Assume.assumeFalse(StandardSystemProperty.JAVA_VERSION.value().startsWith("1.6"));
    Misc test = newWovenObject(BytecodeWithStackFramesMisc.class, Misc.class,
            TestBytecodeWithStackFramesAdvice5.class);
    test.executeWithReturn();
}
 
Example #24
Source File: WeaverTest.java    From glowroot with Apache License 2.0 5 votes vote down vote up
@Test
// test weaving against jdk 1.7 bytecode with stack frames
public void shouldWeaveBytecodeWithStackFrames6() throws Exception {
    Assume.assumeFalse(StandardSystemProperty.JAVA_VERSION.value().startsWith("1.6"));
    Misc test = newWovenObject(BytecodeWithStackFramesMisc.class, Misc.class,
            TestBytecodeWithStackFramesAdvice6.class);
    test.executeWithReturn();
}
 
Example #25
Source File: ClassLoaderLeakIT.java    From glowroot with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUp() throws Exception {
    // need memory limited javaagent
    List<String> extraJvmArgs = Lists.newArrayList();
    String javaVersion = StandardSystemProperty.JAVA_VERSION.value();
    if (javaVersion.startsWith("1.6") || javaVersion.startsWith("1.7")) {
        // limit MaxPermSize for ClassLoaderLeakTest
        extraJvmArgs.add("-XX:MaxPermSize=64m");
    } else {
        // jdk8+ eliminated perm gen, so just limit overall memory
        extraJvmArgs.add("-Xmx64m");
    }
    container = JavaagentContainer.createWithExtraJvmArgs(extraJvmArgs);
}
 
Example #26
Source File: Compiler.java    From compile-testing with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the current classpaths of the given classloader including its parents.
 *
 * @throws IllegalArgumentException if the given classloader had classpaths which we could not
 *     determine or use for compilation.
 */
private static ImmutableList<File> getClasspathFromClassloader(ClassLoader currentClassloader) {
  ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();

  // Concatenate search paths from all classloaders in the hierarchy 'till the system classloader.
  Set<String> classpaths = new LinkedHashSet<>();
  while (true) {
    if (currentClassloader == systemClassLoader) {
      Iterables.addAll(
          classpaths,
          Splitter.on(StandardSystemProperty.PATH_SEPARATOR.value())
              .split(StandardSystemProperty.JAVA_CLASS_PATH.value()));
      break;
    }
    if (currentClassloader == platformClassLoader) {
      break;
    }
    if (currentClassloader instanceof URLClassLoader) {
      // We only know how to extract classpaths from URLClassloaders.
      for (URL url : ((URLClassLoader) currentClassloader).getURLs()) {
        if (url.getProtocol().equals("file")) {
          classpaths.add(url.getPath());
        } else {
          throw new IllegalArgumentException(
              "Given classloader consists of classpaths which are "
                  + "unsupported for compilation.");
        }
      }
    } else {
      throw new IllegalArgumentException(
          String.format(
              "Classpath for compilation could not be extracted "
                  + "since %s is not an instance of URLClassloader",
              currentClassloader));
    }
    currentClassloader = currentClassloader.getParent();
  }

  return classpaths.stream().map(File::new).collect(toImmutableList());
}
 
Example #27
Source File: SystemCommand.java    From LagMonitor with MIT License 5 votes vote down vote up
private void displayUserInfo(CommandSender sender) {
    sender.sendMessage(PRIMARY_COLOR + "User");

    sendMessage(sender, "    Timezone", System.getProperty("user.timezone", "Unknown"));
    sendMessage(sender, "    Country", System.getProperty("user.country", "Unknown"));
    sendMessage(sender, "    Language", System.getProperty("user.language", "Unknown"));
    sendMessage(sender, "    Home", StandardSystemProperty.USER_HOME.value());
    sendMessage(sender, "    Name", StandardSystemProperty.USER_NAME.value());
}
 
Example #28
Source File: OsHelper.java    From theta with Apache License 2.0 5 votes vote down vote up
public static OperatingSystem getOs() {

		final String os = StandardSystemProperty.OS_NAME.value();

		if (os.toLowerCase().startsWith("linux")) {
			return OperatingSystem.LINUX;
		} else if (os.toLowerCase().startsWith("windows")) {
			return OperatingSystem.WINDOWS;
		} else {
			throw new RuntimeException("Operating system \"" + os + "\" not supported.");
		}
	}
 
Example #29
Source File: PrestoServer.java    From presto with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args)
{
    String javaVersion = nullToEmpty(StandardSystemProperty.JAVA_VERSION.value());
    String majorVersion = javaVersion.split("[^\\d]", 2)[0];
    Integer major = Ints.tryParse(majorVersion);
    if (major == null || major < 11) {
        System.err.println(format("ERROR: Presto requires Java 11+ (found %s)", javaVersion));
        System.exit(100);
    }

    String version = PrestoServer.class.getPackage().getImplementationVersion();
    new Server().start(firstNonNull(version, "unknown"));
}
 
Example #30
Source File: GrailsIT.java    From glowroot with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUp() throws Exception {
    String javaVersion = StandardSystemProperty.JAVA_VERSION.value();
    if (Containers.useJavaagent()
            && (javaVersion.startsWith("1.6") || javaVersion.startsWith("1.7"))) {
        // grails loads lots of classes
        container = JavaagentContainer
                .createWithExtraJvmArgs(ImmutableList.of("-XX:MaxPermSize=128m"));
    } else {
        container = Containers.create();
    }
}