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