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; }
private Path computeUserClassPath() { String cp = options.get(CLASSPATH); // 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 = "."; return new Path() .expandJarClassPaths(true) // Only search user jars for Class-Paths .emptyPathDefault(new File(".")) // Empty path elt ==> current directory .addFiles(cp); }
/** * Utility method for converting a search path string to an array of directory and JAR file URLs. * * <p>Note that this method is called by apt and the DocletInvoker. * * @param path the search path string * @return the resulting array of directory and JAR file URLs */ public static URL[] pathToURLs(String path) { StringTokenizer st = new StringTokenizer(path, File.pathSeparator); URL[] urls = new URL[st.countTokens()]; int count = 0; while (st.hasMoreTokens()) { URL url = fileToURL(new File(st.nextToken())); if (url != null) { urls[count++] = url; } } if (urls.length != count) { URL[] tmp = new URL[count]; System.arraycopy(urls, 0, tmp, 0, count); urls = tmp; } return urls; }