6832154: refactor Paths to be just a utility class for JavacFileManager
Reviewed-by: darcy
This commit is contained in:
parent
9de58af34f
commit
131c3e10ee
@ -26,7 +26,6 @@
|
||||
package com.sun.tools.apt.main;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
@ -37,14 +36,15 @@ import java.util.StringTokenizer;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.Collection;
|
||||
|
||||
import java.net.URLClassLoader;
|
||||
import java.net.URL;
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import com.sun.tools.javac.file.Paths;
|
||||
import javax.tools.JavaFileManager;
|
||||
import javax.tools.StandardLocation;
|
||||
|
||||
import com.sun.tools.javac.file.JavacFileManager;
|
||||
import com.sun.tools.javac.code.Source;
|
||||
import com.sun.tools.javac.code.Symbol;
|
||||
import com.sun.tools.javac.code.Type;
|
||||
@ -766,6 +766,7 @@ public class Main {
|
||||
providedFactory = factory;
|
||||
|
||||
Context context = new Context();
|
||||
JavacFileManager.preRegister(context);
|
||||
options = Options.instance(context);
|
||||
Bark bark;
|
||||
|
||||
@ -862,14 +863,14 @@ public class Main {
|
||||
}
|
||||
origOptions = Collections.unmodifiableMap(origOptions);
|
||||
|
||||
JavacFileManager fm = (JavacFileManager) context.get(JavaFileManager.class);
|
||||
{
|
||||
// Note: it might be necessary to check for an empty
|
||||
// component ("") of the source path or class path
|
||||
Paths paths = Paths.instance(context);
|
||||
|
||||
String sourceDest = options.get("-s");
|
||||
if (paths.sourcePath() != null) {
|
||||
for(File f: paths.sourcePath())
|
||||
if (fm.hasLocation(StandardLocation.SOURCE_PATH)) {
|
||||
for(File f: fm.getLocation(StandardLocation.SOURCE_PATH))
|
||||
augmentedSourcePath += (f + File.pathSeparator);
|
||||
augmentedSourcePath += (sourceDest == null)?".":sourceDest;
|
||||
} else {
|
||||
@ -880,8 +881,8 @@ public class Main {
|
||||
}
|
||||
|
||||
String classDest = options.get("-d");
|
||||
if (paths.userClassPath() != null) {
|
||||
for(File f: paths.userClassPath())
|
||||
if (fm.hasLocation(StandardLocation.CLASS_PATH)) {
|
||||
for(File f: fm.getLocation(StandardLocation.CLASS_PATH))
|
||||
baseClassPath += (f + File.pathSeparator);
|
||||
// put baseClassPath into map to handle any
|
||||
// value needed for the classloader
|
||||
@ -908,9 +909,8 @@ public class Main {
|
||||
* uses.
|
||||
*/
|
||||
String aptclasspath = "";
|
||||
Paths paths = Paths.instance(context);
|
||||
String bcp = "";
|
||||
Collection<File> bootclasspath = paths.bootClassPath();
|
||||
Iterable<? extends File> bootclasspath = fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH);
|
||||
|
||||
if (bootclasspath != null) {
|
||||
for(File f: bootclasspath)
|
||||
|
@ -66,7 +66,7 @@ public class Paths {
|
||||
* @param context the context
|
||||
* @return the Paths instance for this context
|
||||
*/
|
||||
public static Paths instance(Context context) {
|
||||
static Paths instance(Context context) {
|
||||
Paths instance = context.get(pathsKey);
|
||||
if (instance == null)
|
||||
instance = new Paths(context);
|
||||
|
@ -55,7 +55,6 @@ import com.sun.source.util.TaskListener;
|
||||
import com.sun.tools.javac.api.JavacTaskImpl;
|
||||
import com.sun.tools.javac.code.*;
|
||||
import com.sun.tools.javac.code.Symbol.*;
|
||||
import com.sun.tools.javac.file.Paths;
|
||||
import com.sun.tools.javac.file.JavacFileManager;
|
||||
import com.sun.tools.javac.jvm.*;
|
||||
import com.sun.tools.javac.main.JavaCompiler;
|
||||
@ -180,7 +179,6 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
|
||||
}
|
||||
|
||||
private void initProcessorIterator(Context context, Iterable<? extends Processor> processors) {
|
||||
Paths paths = Paths.instance(context);
|
||||
Log log = Log.instance(context);
|
||||
Iterator<? extends Processor> processorIterator;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user