6832154: refactor Paths to be just a utility class for JavacFileManager

Tue, 19 May 2009 15:07:15 -0700

author
jjg
date
Tue, 19 May 2009 15:07:15 -0700
changeset 285
4ce1c1400334
parent 284
0c6cd88f72b9
child 286
79eb8795a1de

6832154: refactor Paths to be just a utility class for JavacFileManager
Reviewed-by: darcy

src/share/classes/com/sun/tools/apt/main/Main.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/file/Paths.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/apt/main/Main.java	Tue May 19 13:53:00 2009 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/apt/main/Main.java	Tue May 19 15:07:15 2009 -0700
     1.3 @@ -26,7 +26,6 @@
     1.4  package com.sun.tools.apt.main;
     1.5  
     1.6  import java.io.File;
     1.7 -import java.io.FileOutputStream;
     1.8  import java.io.FileWriter;
     1.9  import java.io.IOException;
    1.10  import java.io.PrintWriter;
    1.11 @@ -37,14 +36,15 @@
    1.12  import java.util.Map;
    1.13  import java.util.HashMap;
    1.14  import java.util.Collections;
    1.15 -import java.util.Collection;
    1.16  
    1.17  import java.net.URLClassLoader;
    1.18  import java.net.URL;
    1.19 -import java.io.File;
    1.20  import java.net.MalformedURLException;
    1.21  
    1.22 -import com.sun.tools.javac.file.Paths;
    1.23 +import javax.tools.JavaFileManager;
    1.24 +import javax.tools.StandardLocation;
    1.25 +
    1.26 +import com.sun.tools.javac.file.JavacFileManager;
    1.27  import com.sun.tools.javac.code.Source;
    1.28  import com.sun.tools.javac.code.Symbol;
    1.29  import com.sun.tools.javac.code.Type;
    1.30 @@ -766,6 +766,7 @@
    1.31          providedFactory = factory;
    1.32  
    1.33          Context context = new Context();
    1.34 +        JavacFileManager.preRegister(context);
    1.35          options = Options.instance(context);
    1.36          Bark bark;
    1.37  
    1.38 @@ -862,14 +863,14 @@
    1.39              }
    1.40              origOptions = Collections.unmodifiableMap(origOptions);
    1.41  
    1.42 +            JavacFileManager fm = (JavacFileManager) context.get(JavaFileManager.class);
    1.43              {
    1.44                  // Note: it might be necessary to check for an empty
    1.45                  // component ("") of the source path or class path
    1.46 -                Paths paths = Paths.instance(context);
    1.47  
    1.48                  String sourceDest = options.get("-s");
    1.49 -                if (paths.sourcePath() != null) {
    1.50 -                    for(File f: paths.sourcePath())
    1.51 +                if (fm.hasLocation(StandardLocation.SOURCE_PATH)) {
    1.52 +                    for(File f: fm.getLocation(StandardLocation.SOURCE_PATH))
    1.53                          augmentedSourcePath += (f + File.pathSeparator);
    1.54                      augmentedSourcePath += (sourceDest == null)?".":sourceDest;
    1.55                  } else {
    1.56 @@ -880,8 +881,8 @@
    1.57                  }
    1.58  
    1.59                  String classDest = options.get("-d");
    1.60 -                if (paths.userClassPath() != null) {
    1.61 -                    for(File f: paths.userClassPath())
    1.62 +                if (fm.hasLocation(StandardLocation.CLASS_PATH)) {
    1.63 +                    for(File f: fm.getLocation(StandardLocation.CLASS_PATH))
    1.64                          baseClassPath += (f + File.pathSeparator);
    1.65                      // put baseClassPath into map to handle any
    1.66                      // value needed for the classloader
    1.67 @@ -908,9 +909,8 @@
    1.68               * uses.
    1.69               */
    1.70                  String aptclasspath = "";
    1.71 -                Paths paths = Paths.instance(context);
    1.72                  String bcp = "";
    1.73 -                Collection<File> bootclasspath = paths.bootClassPath();
    1.74 +                Iterable<? extends File> bootclasspath = fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH);
    1.75  
    1.76                  if (bootclasspath != null) {
    1.77                      for(File f: bootclasspath)
     2.1 --- a/src/share/classes/com/sun/tools/javac/file/Paths.java	Tue May 19 13:53:00 2009 -0700
     2.2 +++ b/src/share/classes/com/sun/tools/javac/file/Paths.java	Tue May 19 15:07:15 2009 -0700
     2.3 @@ -66,7 +66,7 @@
     2.4       *  @param context the context
     2.5       *  @return the Paths instance for this context
     2.6       */
     2.7 -    public static Paths instance(Context context) {
     2.8 +    static Paths instance(Context context) {
     2.9          Paths instance = context.get(pathsKey);
    2.10          if (instance == null)
    2.11              instance = new Paths(context);
     3.1 --- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Tue May 19 13:53:00 2009 -0700
     3.2 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Tue May 19 15:07:15 2009 -0700
     3.3 @@ -55,7 +55,6 @@
     3.4  import com.sun.tools.javac.api.JavacTaskImpl;
     3.5  import com.sun.tools.javac.code.*;
     3.6  import com.sun.tools.javac.code.Symbol.*;
     3.7 -import com.sun.tools.javac.file.Paths;
     3.8  import com.sun.tools.javac.file.JavacFileManager;
     3.9  import com.sun.tools.javac.jvm.*;
    3.10  import com.sun.tools.javac.main.JavaCompiler;
    3.11 @@ -180,7 +179,6 @@
    3.12      }
    3.13  
    3.14      private void initProcessorIterator(Context context, Iterable<? extends Processor> processors) {
    3.15 -        Paths paths = Paths.instance(context);
    3.16          Log   log   = Log.instance(context);
    3.17          Iterator<? extends Processor> processorIterator;
    3.18  

mercurial