Beispiel #1
0
  private Path computeUserClassPath() {
    String cp = options.get(CLASSPATH);

    /*
     * Ceylon: disabled because we use the -cp flag or set it up via module repos
     *
    // CLASSPATH environment variable when run from `javac'.
    if (cp == null) cp = System.getProperty("env.class.path");

    // If invoked via a java VM (not the javac launcher), use the
    // platform class path
    if (cp == null && System.getProperty("application.home") == null)
        cp = System.getProperty("java.class.path");

    // Default to current working directory.
    if (cp == null) cp = ".";
    */

    Path ret =
        new Path()
            .expandJarClassPaths(true) // Only search user jars for Class-Paths
            .emptyPathDefault(new File(".")); // Empty path elt ==> current directory
    if (cp != null) ret.addFiles(cp);
    return ret;
  }
Beispiel #2
0
  private Path computeBootClassPath() {
    bootClassPathRtJar = null;
    String optionValue;
    Path path = new Path();

    path.addFiles(options.get(XBOOTCLASSPATH_PREPEND));

    if ((optionValue = options.get(ENDORSEDDIRS)) != null) path.addDirectories(optionValue);
    else path.addDirectories(System.getProperty("java.endorsed.dirs"), false);

    if ((optionValue = options.get(BOOTCLASSPATH)) != null) {
      path.addFiles(optionValue);
    } else {
      // Standard system classes for this compiler's release.
      String files = System.getProperty("sun.boot.class.path");
      path.addFiles(files, false);
      File rt_jar = new File("rt.jar");
      for (File file : getPathEntries(files)) {
        if (new File(file.getName()).equals(rt_jar)) bootClassPathRtJar = file;
      }
    }

    path.addFiles(options.get(XBOOTCLASSPATH_APPEND));

    // Strictly speaking, standard extensions are not bootstrap
    // classes, but we treat them identically, so we'll pretend
    // that they are.
    if ((optionValue = options.get(EXTDIRS)) != null) path.addDirectories(optionValue);
    else path.addDirectories(System.getProperty("java.ext.dirs"), false);

    return path;
  }
Beispiel #3
0
  private Path computeSourcePath() {
    List<String> sourcePathArgs = options.getMulti(SOURCEPATH);
    // Ceylon: default source path
    if (sourcePathArgs.isEmpty())
      sourcePathArgs = FileUtil.filesToPathList(DefaultToolOptions.getCompilerSourceDirs(config));

    Path path = new Path();
    for (String pathArg : sourcePathArgs) {
      path.addFiles(pathArg);
    }
    return path;
  }
Beispiel #4
0
 Collection<File> otherSearchPath() {
   if (otherSearchPath == null) {
     lazy();
     Path userClassPath = getPathForLocation(CLASS_PATH);
     Path sourcePath = getPathForLocation(SOURCE_PATH);
     if (sourcePath == null) otherSearchPath = userClassPath;
     else {
       otherSearchPath = new Path();
       otherSearchPath.addAll(userClassPath);
       otherSearchPath.addAll(sourcePath);
     }
   }
   return Collections.unmodifiableCollection(otherSearchPath);
 }
Beispiel #5
0
 void setPathForLocation(Location location, Iterable<? extends File> path) {
   // TODO? if (inited) throw new IllegalStateException
   // TODO: otherwise reset sourceSearchPath, classSearchPath as needed
   Path p;
   if (path == null) {
     if (location == CLASS_PATH) p = computeUserClassPath();
     else if (location == PLATFORM_CLASS_PATH) p = computeBootClassPath();
     else if (location == ANNOTATION_PROCESSOR_PATH) p = computeAnnotationProcessorPath();
     else if (location == SOURCE_PATH) p = computeSourcePath();
     else
       // no defaults for other paths
       p = null;
   } else {
     p = new Path();
     for (File f : path) p.addFile(f, warn); // TODO: is use of warn appropriate?
   }
   pathsForLocation.put(location, p);
 }
Beispiel #6
0
 public Collection<File> classSearchPath() {
   if (classSearchPath == null) {
     lazy();
     Path bootClassPath = getPathForLocation(PLATFORM_CLASS_PATH);
     Path userClassPath = getPathForLocation(CLASS_PATH);
     classSearchPath = new Path();
     classSearchPath.addAll(bootClassPath);
     classSearchPath.addAll(userClassPath);
   }
   return Collections.unmodifiableCollection(classSearchPath);
 }
Beispiel #7
0
 public Collection<File> sourcePath() {
   lazy();
   Path p = getPathForLocation(SOURCE_PATH);
   return p == null || p.size() == 0 ? null : Collections.unmodifiableCollection(p);
 }