Java Code Examples for java.io.File#pathSeparatorChar()

The following examples show how to use java.io.File#pathSeparatorChar() . 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: CompilerInterface.java    From spring-ldap with Apache License 2.0 6 votes vote down vote up
public static void compile(String directory, String file) throws Exception {

        ProcessBuilder pb = new ProcessBuilder(
                new String[] { "javac", 
                               "-cp", "."+File.pathSeparatorChar+"target"+File.separatorChar+"classes"+
                                  File.pathSeparatorChar+System.getProperty("java.class.path"),
                                  directory+File.separatorChar+file });

        pb.redirectErrorStream(true);
        Process proc = pb.start();
        InputStream is = proc.getInputStream();
        InputStreamReader isr = new InputStreamReader(is);

        char[] buf = new char[1024];
        int count;
        StringBuilder builder = new StringBuilder();
        while ((count = isr.read(buf)) > 0) {
            builder.append(buf, 0, count);
        }
        
        boolean ok = proc.waitFor() == 0;

        if (!ok) {
            throw new RuntimeException(builder.toString());
        }
    }
 
Example 2
Source File: DynamicClassLoader.java    From baratine with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the resource path with most specific first.
 */
public final String getResourcePathSpecificFirst()
{
  ArrayList<String> pathList = new ArrayList<String>();

  buildResourcePathSpecificFirst(pathList);

  StringBuilder sb = new StringBuilder();
  char sep = File.pathSeparatorChar;

  if (pathList.size() == 0)
    return "";

  sb.append(pathList.get(0));
  for (int i = 1; i < pathList.size(); i++) {
    sb.append(sep);
    sb.append(pathList.get(i));
  }

  return sb.toString();
}
 
Example 3
Source File: CacheWriter.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void setDir (String dir, boolean clean) throws IOException {
    StringBuffer sb = new StringBuffer(dir);
    if (sb.charAt(sb.length()-1) != File.pathSeparatorChar) {
        sb.append (File.separatorChar);
    }
    this.dir = sb.toString();
    File f = new File (dir);
    if (!f.exists()) {
        f.mkdir();
    }
    if (clean) {
        File mf = new File (this.dir + filename + ".metadata");
        File fc = new File (this.dir + filename + ".cache");
        if (mf.exists()) {
            mf.delete();
        }
        if (fc.exists()) {
            fc.delete();
        }
    }
}
 
Example 4
Source File: InstallationController.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Builds <code>CLASSPATH</code> for the installed component, including <code>CLASSPATH</code>
 * for all separate delegate components that are utilized by the main installed component, if any.
 * 
 * @return The <code>CLASSPATH</code> for the installed component, or <code>null</code>, if
 *         the component has not been installed.
 * @throws IOException
 *           If any I/O exception occurred.
 */
public String buildComponentClassPath() throws IOException {
  if (_insdObject != null) {
    StringBuffer cpBuffer = new StringBuffer();
    // build main component classpath
    String mainClassPath = buildComponentClassPath(_mainComponentRootPath, _insdObject, true);
    cpBuffer.append(mainClassPath);
    // add component classpath for possible delegate components
    if (_installationTable.size() > 0) {
      Enumeration<String> dlgIdList = _installationTable.keys();
      while (dlgIdList.hasMoreElements()) {
        // process next delegate component
        String dlgId = dlgIdList.nextElement();
        String dlgRootPath = _installationTable.get(dlgId);
        InstallationDescriptor dlgInsD = _installationInsDs.get(dlgId);
        String dlgClassPath = buildComponentClassPath(dlgRootPath, dlgInsD, true);
        if (dlgClassPath.length() > 0) {
          if (cpBuffer.length() > 0
                  && cpBuffer.charAt(cpBuffer.length() - 1) != File.pathSeparatorChar)
            cpBuffer.append(File.pathSeparatorChar);
          cpBuffer.append(dlgClassPath);
        }
      }
    }
    return cpBuffer.toString();
  }
  return null;
}
 
Example 5
Source File: CauchoUtil.java    From baratine with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the system classpath, including the bootpath
 */
public static String getClassPath()
{
  if (_classPath != null)
    return _classPath;

  String cp = System.getProperty("java.class.path");

  String boot = System.getProperty("sun.boot.class.path");
  if (boot != null && ! boot.equals(""))
    cp = cp + File.pathSeparatorChar + boot;

  Pattern pattern = Pattern.compile("" + File.pathSeparatorChar);

  String []path = pattern.split(cp);

  CharBuffer cb = new CharBuffer();

  for (int i = 0; i < path.length; i++) {
    PathImpl subpath = VfsOld.lookup(path[i]);

    if (subpath.canRead() || subpath.isDirectory()) {
      if (cb.length() > 0)
        cb.append(File.pathSeparatorChar);

      cb.append(path[i]);
    }
  }

  _classPath = cb.toString();

  return _classPath;
}
 
Example 6
Source File: Main.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Launch nopol on project
 * @param cpClassFolder : location of project's compiled java
 * @param cpTestFolder : location of project's compiled tests
 * @param srcClassFolder : location of project's java
 * @param srcTestFolder : location of project's tests
 * @param destSrcTestFolder : location for the kept tests
 * @param destCpTestFolder : location to compile the kept tests
 * @param dependencies : all dependencies for the project and evosuite tests
 * @param testClasses : test class used to generate patch (null for all tests)
 * @return  the list of patch found by nopol
 */
public static List<Patch> NopolPatchGeneration(String cpClassFolder,String  cpTestFolder, 
        String srcClassFolder, String srcTestFolder, String destSrcTestFolder, 
        String destCpTestFolder, String dependencies, String[] testClasses) {

    //sources contain main java and test java.
    String sources = srcClassFolder+File.pathSeparatorChar+srcTestFolder+File.pathSeparatorChar+destSrcTestFolder;
    String cp = cpClassFolder+File.pathSeparatorChar+cpTestFolder+File.pathSeparatorChar+destCpTestFolder+File.pathSeparatorChar+dependencies;

    //create sources array
    String[] sourcesArray = sources.split(File.pathSeparator);
    File[] sourceFiles = new File[sourcesArray.length];
    for(int i = 0; i<sourcesArray.length; i++){
        sourceFiles[i] = FileLibrary.openFrom(sourcesArray[i]);	
    }


    //create getClasspath
    //URL[] classPath = FileUtils.getURLs(sources.split(File.pathSeparator));
    URL[] classPath = JavaLibrary.classpathFrom(cp);

    logger.debug("Launch nopol with:");
    logger.debug("sources = "+sources);
    logger.debug("classpath = "+cp);
    logger.debug("testClasses = "+testClasses);

    NopolContext nopolContext = new NopolContext(sourceFiles, classPath, testClasses);
    nopolContext.setMaxTimeInMinutes(maxTime);
    nopolContext.setType(nopolType);

    NoPol nopol = new NoPol(nopolContext);
    NopolResult status = nopol.build();

    return status.getPatches();
}
 
Example 7
Source File: JavaLibraryTest.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void joinClasspaths() throws MalformedURLException {
	URL url = new URL("file:///imaginary/project/folder/src");
	URL url2 = new URL("file:///imaginary/dependency/lib.jar");
	String classpath = asClasspath(new URL[] {url, url2});
	Character classPathSeparator = File.pathSeparatorChar;
	assertEquals("/imaginary/project/folder/src" + classPathSeparator + "/imaginary/dependency/lib.jar", classpath);
}
 
Example 8
Source File: AjcHelper.java    From aspectj-maven-plugin with MIT License 5 votes vote down vote up
/**
 * Constructs AspectJ compiler classpath string
 *
 * @param project the Maven Project
 * @param pluginArtifacts the plugin Artifacts
 * @param outDirs the outputDirectories
 * @return a os spesific classpath string
 */
@SuppressWarnings( "unchecked" )
public static String createClassPath( MavenProject project, List<Artifact> pluginArtifacts, List<String> outDirs )
{
    String cp = new String();
    Set<Artifact> classPathElements = Collections.synchronizedSet( new LinkedHashSet<Artifact>() );
    Set<Artifact> dependencyArtifacts = project.getDependencyArtifacts();
    classPathElements.addAll( dependencyArtifacts == null ? Collections.<Artifact>emptySet() : dependencyArtifacts );
    classPathElements.addAll( project.getArtifacts() );
    classPathElements.addAll( pluginArtifacts == null ? Collections.<Artifact>emptySet() : pluginArtifacts );
    for ( Artifact classPathElement  : classPathElements )
    {
        File artifact = classPathElement.getFile();
        if ( null != artifact )
        {
          String type = classPathElement.getType();
          if (!type.equals("pom")){
            cp += classPathElement.getFile().getAbsolutePath();
            cp += File.pathSeparatorChar;                
          }
        }
    }
    Iterator<String> outIter = outDirs.iterator();
    while ( outIter.hasNext() )
    {
        cp += outIter.next();
        cp += File.pathSeparatorChar;
    }

    if ( cp.endsWith( "" + File.pathSeparatorChar ) )
    {
        cp = cp.substring( 0, cp.length() - 1 );
    }

    cp = StringUtils.replace( cp, "//", "/" );
    return cp;
}
 
Example 9
Source File: BaratineBoot.java    From baratine with GNU General Public License v2.0 5 votes vote down vote up
private static String toNative(String filePath)
{
  if (File.pathSeparatorChar == '/') {
    return filePath;
  }
  
  if (filePath.indexOf(':') == 2 && filePath.startsWith("/")) {
    filePath = filePath.substring(1);
  }
  
  return filePath;
}
 
Example 10
Source File: RuntimeTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "jarFiles")
void testMVJarAsLib(String jar, int mainVer, int helperVer, int resVer)
        throws Throwable {
    String[] apps = { "UseByImport", "UseByReflection" };
    for (String app : apps) {
        String[] command = {"-cp",
                jar + File.pathSeparatorChar + "classes/test/", app };
        System.out.println("Command arguments:" + Arrays.asList(command));
        System.out.println();
        java(command).shouldHaveExitValue(SUCCESS)
                .shouldContain("Main version: " + mainVer)
                .shouldContain("Helpers version: " + helperVer)
                .shouldContain("Resource version: " + resVer);
    }
}
 
Example 11
Source File: JPFRunner.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
private String createClassPath(URL[] classpath) {
	classpath = addJPFLibraryToCassPath(classpath);
	String stringClassPath = outputCompiledFile.getAbsolutePath() + File.pathSeparatorChar;
	for (int i = 0; i < classpath.length; i++) {
		URL url = classpath[i];
		stringClassPath += url.getPath() + File.pathSeparatorChar;
	}
	return stringClassPath;
}
 
Example 12
Source File: WordReader.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
private boolean isDelimiter(char character)
{
    return character == '@' ||
           character == '{' ||
           character == '}' ||
           character == '(' ||
           character == ')' ||
           character == ',' ||
           character == ';' ||
           character == File.pathSeparatorChar;
}
 
Example 13
Source File: XmlSchemaGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static String calculateRelativePath(String uri, String base, boolean fileUrl) {
    // if this is a file URL (very likely), and if this is on a case-insensitive file system,
    // then treat it accordingly.
    boolean onWindows = File.pathSeparatorChar==';';

    if (base == null) {
        return null;
    }
    if ((fileUrl && onWindows && startsWithIgnoreCase(uri,base)) || uri.startsWith(base)) {
        return uri.substring(base.length());
    } else {
        return "../" + calculateRelativePath(uri, getParentUriPath(base), fileUrl);
    }
}
 
Example 14
Source File: SuspendOnSoftKillTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void startContainer(int suspendTimeout) throws Exception {

        suspendTimeout = suspendTimeout < 1 ? suspendTimeout : TimeoutUtil.adjust(suspendTimeout);

        jbossArgs = System.getProperty("jboss.args");
        String newArgs = jbossArgs == null ? "" : jbossArgs;
        newArgs += " -D[Standalone] -Dorg.wildfly.sigterm.suspend.timeout=" + suspendTimeout;
        System.setProperty("jboss.args", newArgs);

        if (File.pathSeparatorChar == ':'){
            processUtil = new UnixProcessUtil();
        } else {
            processUtil = new WindowsProcessUtil();
        }

        // Start the server
        serverController.start();

        // If there's already the deployment there from a previous test, remove it
        try {
            serverController.undeploy(WEB_SUSPEND_JAR);
        } catch (Exception ignored) {
            // assume it wasn't deployed. if it was we'll fail below
        }

        JavaArchive war = ShrinkWrap.create(JavaArchive.class, WEB_SUSPEND_JAR);
        war.addPackage(SuspendResumeHandler.class.getPackage());
        war.addAsServiceProvider(ServiceActivator.class, TestSuspendServiceActivator.class);
        war.addAsResource(new StringAsset("Dependencies: org.jboss.dmr, org.jboss.as.controller, io.undertow.core, org.jboss.as.server,org.wildfly.extension.request-controller, org.jboss.as.network\n"), "META-INF/MANIFEST.MF");
        war.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
                new RuntimePermission("createXnioWorker"),
                new SocketPermission(TestSuiteEnvironment.getServerAddress() + ":8080", "listen,resolve"),
                new SocketPermission("*", "accept,resolve")
        ), "permissions.xml");
        serverController.deploy(war, WEB_SUSPEND_JAR);
    }
 
Example 15
Source File: RespawnHttpTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@BeforeClass
public static void createProcessController() throws IOException, URISyntaxException, NoSuchAlgorithmException {

    // Setup client
    utils = TestControllerUtils.create("remote+http", DomainTestSupport.masterAddress, HC_PORT, getCallbackHandler());
    client = new TestControllerClient(utils.getConfiguration(), utils.getExecutor());

    final String testName = RespawnHttpTestCase.class.getSimpleName();
    final File domains = new File("target" + File.separator + "domains" + File.separator + testName);
    final File masterDir = new File(domains, "master");
    final String masterDirPath = masterDir.getAbsolutePath();
    domainConfigDir = new File(masterDir, "configuration");
    // TODO this should not be necessary
    domainConfigDir.mkdirs();

    if (File.pathSeparatorChar == ':'){
        processUtil = new UnixProcessUtil();
    } else {
        processUtil = new WindowsProcessUtil();
    }

    String jbossHome = System.getProperty("jboss.home");
    if (jbossHome == null) {
        throw new IllegalStateException("-Djboss.home must be set");
    }

    ClassLoader tccl = Thread.currentThread().getContextClassLoader();
    URL url = tccl.getResource("domain-configs/domain-respawn-http.xml");
    Assert.assertNotNull(url);
    File domainXml = new File(url.toURI());
    url = tccl.getResource("host-configs/respawn-master-http.xml");
    hostXml = new File(url.toURI());

    Assert.assertTrue(domainXml.exists());
    Assert.assertTrue(hostXml.exists());
    copyFile(domainXml, domainConfigDir);
    copyFile(hostXml, domainConfigDir);

    // No point backing up the file in a test scenario, just write what we need.
    File usersFile = new File(domainConfigDir, "mgmt-users.properties");
    Files.write(usersFile.toPath(),
            ("slave=" + new UsernamePasswordHashUtil().generateHashedHexURP("slave", "ManagementRealm", "slave_user_password".toCharArray())+"\n").getBytes(StandardCharsets.UTF_8));

    String localRepo = System.getProperty("settings.localRepository");

    final String address = System.getProperty("jboss.test.host.master.address", "127.0.0.1");

    List<String> args = new ArrayList<String>();
    args.add("-jboss-home");
    args.add(jbossHome);
    args.add("-jvm");
    args.add(processUtil.getJavaCommand());
    args.add("--");
    if(localRepo != null) {
        args.add("-Dmaven.repo.local=" + localRepo);
    }
    args.add("-Dorg.jboss.boot.log.file=" + masterDirPath + "/log/host-controller.log");
    args.add("-Dlogging.configuration=file:" + jbossHome + "/domain/configuration/logging.properties");
    args.add("-Djboss.test.host.master.address=" + address);
    TestSuiteEnvironment.getIpv6Args(args);
    args.add("-Xms64m");
    args.add("-Xmx512m");
    args.add("-XX:MaxMetaspaceSize=256m");
    String cliJvmArgs = System.getProperty("cli.jvm.args");
    if (cliJvmArgs != null && !cliJvmArgs.trim().isEmpty()) {
        args.addAll(Arrays.asList(cliJvmArgs.split("\\s+")));
    }
    args.add("--");
    args.add("-default-jvm");
    args.add(processUtil.getJavaCommand());
    args.add("--host-config=" + hostXml.getName());
    args.add("--domain-config=" + domainXml.getName());
    args.add("-Djboss.test.host.master.address=" + address);
    args.add("-Djboss.domain.base.dir=" + masterDir.getAbsolutePath());
    if(localRepo != null) {
        args.add("-Dmaven.repo.local=" + localRepo);
    }
    args.add("--interprocess-hc-address");
    args.add(address);
    args.add("--pc-address");
    args.add(address);

    log.info(args.toString());

    processController = Main.start(args.toArray(new String[args.size()]));
}
 
Example 16
Source File: ProjectModelTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testUpdateCompilationUnits() throws Exception {
    List sources;
    List units = new ArrayList();
    List expectedUnits;
    
    ProjectModel pm = createEmptyProjectModel();
    
    sources = generateSources(new String[]{"src1", "src2"});
    JavaProjectGenerator.JavaCompilationUnit cu = new JavaProjectGenerator.JavaCompilationUnit();
    cu.packageRoots = Collections.singletonList("src1");
    JavaProjectGenerator.JavaCompilationUnit.CP cp = new JavaProjectGenerator.JavaCompilationUnit.CP();
    cp.classpath = "cp1"+File.pathSeparatorChar+"cp2";
    cp.mode = "compile";
    cu.classpath = Collections.singletonList(cp);
    cu.output = Arrays.asList(new String[]{"out1", "out2"});
    units.add(cu);
    cu = new JavaProjectGenerator.JavaCompilationUnit();
    cu.packageRoots = Collections.singletonList("src2");
    cp = new JavaProjectGenerator.JavaCompilationUnit.CP();
    cp.classpath = "cp2"+File.pathSeparatorChar+"cp3";
    cp.mode = "compile";
    cu.classpath = Collections.singletonList(cp);
    cu.output = Arrays.asList(new String[]{"out3"});
    units.add(cu);
    pm.setSourceFolders(sources);
    pm.setJavaCompilationUnits(units);
    pm.setSourceLevel("S_L_14");
    pm.updateCompilationUnits(false);
    assertEquals("Compilation units has to be merged into one", 1, units.size());
    cu = (JavaProjectGenerator.JavaCompilationUnit)units.get(0);
    assertEquals("Compilation unit has to have two package roots", 2, cu.packageRoots.size());
    assertTrue("Missing expected package root: src1", cu.packageRoots.contains("src1"));
    assertTrue("Missing expected package root: src2", cu.packageRoots.contains("src2"));
    assertEquals("Compilation unit has to have three classpath items", 
        "cp1"+File.pathSeparatorChar+"cp2"+File.pathSeparatorChar+"cp3", 
        cu.classpath.get(0).classpath);
    assertEquals("Compilation unit has to have three output items", 3, cu.output.size());
    assertTrue("Missing expected package root: out1", cu.output.contains("out1"));
    assertTrue("Missing expected package root: out2", cu.output.contains("out2"));
    assertTrue("Missing expected package root: out2", cu.output.contains("out2"));
    assertTrue("Missing expected source level: S_L_14", cu.sourceLevel.equals("S_L_14"));
    
    pm.setSourceFolders(sources);
    pm.setJavaCompilationUnits(units);
    pm.setSourceLevel("S_L_15");
    pm.updateCompilationUnits(true);
    assertEquals("Compilation units has to be cloned into two", 2, units.size());
    cu = (JavaProjectGenerator.JavaCompilationUnit)units.get(0);
    assertEquals("Compilation unit has to have one package root", 1, cu.packageRoots.size());
    assertTrue("Missing expected package root", cu.packageRoots.contains("src1"));
    assertEquals("Compilation unit has to have three classpath items", 
        "cp1"+File.pathSeparatorChar+"cp2"+File.pathSeparatorChar+"cp3", 
        cu.classpath.get(0).classpath);
    assertEquals("Compilation unit has to have three output items", 3, cu.output.size());
    assertTrue("Missing expected package root: out1", cu.output.contains("out1"));
    assertTrue("Missing expected package root: out2", cu.output.contains("out2"));
    assertTrue("Missing expected package root: out2", cu.output.contains("out2"));
    assertTrue("Missing expected source level: S_L_14", cu.sourceLevel.equals("S_L_15"));
    cu = (JavaProjectGenerator.JavaCompilationUnit)units.get(1);
    assertEquals("Compilation unit has to have one package root", 1, cu.packageRoots.size());
    assertTrue("Missing expected package root", cu.packageRoots.contains("src2"));
    assertEquals("Compilation unit has to have three classpath items", 
        "cp1"+File.pathSeparatorChar+"cp2"+File.pathSeparatorChar+"cp3", 
        cu.classpath.get(0).classpath);
    assertEquals("Compilation unit has to have three output items", 3, cu.output.size());
    assertTrue("Missing expected package root: out1", cu.output.contains("out1"));
    assertTrue("Missing expected package root: out2", cu.output.contains("out2"));
    assertTrue("Missing expected package root: out2", cu.output.contains("out2"));
    assertTrue("Missing expected source level: S_L_14", cu.sourceLevel.equals("S_L_15"));
    
}
 
Example 17
Source File: TestScheduler.java    From scheduling with GNU Affero General Public License v3.0 4 votes vote down vote up
public static String testClasspath() {
    return (getRmHome() + File.separator + "dist" + File.separator + "lib" + File.separator + "*") +
           File.pathSeparatorChar + getRmHome() + File.separator + "addons" + File.separator + "*" +
           filterClassPath(System.getProperty("java.class.path"));
}
 
Example 18
Source File: BaseUtilities.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Get the operating system on which NetBeans is running.
* @return one of the <code>OS_*</code> constants (such as {@link #OS_WINNT})
*/
public static int getOperatingSystem() {
    if (operatingSystem == -1) {
        String osName = System.getProperty("os.name");

        if ("Windows NT".equals(osName)) { // NOI18N
            operatingSystem = OS_WINNT;
        } else if ("Windows 95".equals(osName)) { // NOI18N
            operatingSystem = OS_WIN95;
        } else if ("Windows 98".equals(osName)) { // NOI18N
            operatingSystem = OS_WIN98;
        } else if ("Windows 2000".equals(osName)) { // NOI18N
            operatingSystem = OS_WIN2000;
        } else if ("Windows Vista".equals(osName)) { // NOI18N
            operatingSystem = OS_WINVISTA;
        } else if (osName.startsWith("Windows ")) { // NOI18N
            operatingSystem = OS_WIN_OTHER;
        } else if ("Solaris".equals(osName)) { // NOI18N
            operatingSystem = OS_SOLARIS;
        } else if (osName.startsWith("SunOS")) { // NOI18N
            operatingSystem = OS_SOLARIS;
        }
        // JDK 1.4 b2 defines os.name for me as "Redhat Linux" -jglick
        else if (osName.endsWith("Linux")) { // NOI18N
            operatingSystem = OS_LINUX;
        } else if ("HP-UX".equals(osName)) { // NOI18N
            operatingSystem = OS_HP;
        } else if ("AIX".equals(osName)) { // NOI18N
            operatingSystem = OS_AIX;
        } else if ("Irix".equals(osName)) { // NOI18N
            operatingSystem = OS_IRIX;
        } else if ("SunOS".equals(osName)) { // NOI18N
            operatingSystem = OS_SUNOS;
        } else if ("Digital UNIX".equals(osName)) { // NOI18N
            operatingSystem = OS_TRU64;
        } else if ("OS/2".equals(osName)) { // NOI18N
            operatingSystem = OS_OS2;
        } else if ("OpenVMS".equals(osName)) { // NOI18N
            operatingSystem = OS_VMS;
        } else if (osName.equals("Mac OS X")) { // NOI18N
            operatingSystem = OS_MAC;
        } else if (osName.startsWith("Darwin")) { // NOI18N
            operatingSystem = OS_MAC;
        } else if (osName.toLowerCase(Locale.US).startsWith("freebsd")) { // NOI18N 
            operatingSystem = OS_FREEBSD;
        } else if ("OpenBSD".equals(osName)) { // NOI18N
            operatingSystem = OS_OPENBSD;
        } else if (File.pathSeparatorChar == ':') { // NOI18N
            operatingSystem = OS_UNIX_OTHER;
        } else {
            operatingSystem = OS_OTHER;
        }
    }

    return operatingSystem;
}
 
Example 19
Source File: Main.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Remove smart javac wrapper arguments, before feeding
 * the args to the plain javac.
 */
static String[] removeWrapperArgs(String[] args) {
    String[] out = new String[args.length];
    // The first source path index is remembered
    // here. So that all following can be concatenated to it.
    int source_path = -1;
    // The same for class path.
    int class_path = -1;
    // And module path.
    int module_path = -1;
    int j = 0;
    for (int i = 0; i<args.length; ++i) {
        if (args[i].equals("-src") ||
            args[i].equals("-x") ||
            args[i].equals("-i") ||
            args[i].equals("-xf") ||
            args[i].equals("-if") ||
            args[i].equals("-copy") ||
            args[i].equals("-tr") ||
            args[i].equals("-j")) {
            // Just skip it and skip following value
            i++;
        } else if (args[i].startsWith("--server:")) {
            // Just skip it.
        } else if (args[i].startsWith("--log=")) {
            // Just skip it.
        } else if (args[i].equals("--permit-unidentified-artifacts")) {
            // Just skip it.
        } else if (args[i].equals("--permit-sources-without-package")) {
            // Just skip it.
        } else if (args[i].equals("--compare-found-sources")) {
            // Just skip it and skip verify file name
            i++;
        } else if (args[i].equals("-sourcepath")) {
            if (source_path == -1) {
                source_path = j;
                out[j] = args[i];
                out[j+1] = args[i+1];
                j+=2;
                i++;
            } else {
                // Skip this and its argument, but
                // append argument to found sourcepath.
                out[source_path+1] = out[source_path+1]+File.pathSeparatorChar+args[i+1];
                i++;
            }
        } else if (args[i].equals("-classpath") || args[i].equals("-cp")) {
            if (class_path == -1) {
                class_path = j;
                out[j] = args[i];
                out[j+1] = args[i+1];
                j+=2;
                i++;
            } else {
                // Skip this and its argument, but
                // append argument to found sourcepath.
                out[class_path+1] = out[class_path+1]+File.pathSeparatorChar+args[i+1];
                i++;
            }
        } else if (args[i].equals("-modulepath")) {
            if (module_path == -1) {
                module_path = j;
                out[j] = args[i];
                out[j+1] = args[i+1];
                j+=2;
                i++;
            } else {
                // Skip this and its argument, but
                // append argument to found sourcepath.
                out[module_path+1] = out[module_path+1]+File.pathSeparatorChar+args[i+1];
                i++;
            }
         } else {
            // Copy argument.
            out[j] = args[i];
            j++;
        }
    }
    String[] ret = new String[j];
    System.arraycopy(out, 0, ret, 0, j);
    return ret;
}
 
Example 20
Source File: CliGitAPITempFileTest.java    From git-client-plugin with MIT License 2 votes vote down vote up
/**
 * inline ${@link hudson.Functions#isWindows()} to prevent a transient
 * remote classloader issue
 */
private static boolean isWindows() {
    return File.pathSeparatorChar == ';';
}