langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java
changeset 22163 3651128c74eb
parent 22153 f9f06fcca59d
child 24296 296e59a84663
equal deleted inserted replaced
22162:3b3e23e67329 22163:3651128c74eb
    45 import javax.tools.JavaFileManager;
    45 import javax.tools.JavaFileManager;
    46 import javax.tools.JavaFileObject;
    46 import javax.tools.JavaFileObject;
    47 import javax.tools.StandardJavaFileManager;
    47 import javax.tools.StandardJavaFileManager;
    48 
    48 
    49 import com.sun.tools.javac.util.Context;
    49 import com.sun.tools.javac.util.Context;
       
    50 import com.sun.tools.javac.util.ListBuffer;
    50 import com.sun.tools.javac.util.Log;
    51 import com.sun.tools.javac.util.Log;
    51 import com.sun.tools.javac.util.BaseFileManager;
    52 import com.sun.tools.javac.util.BaseFileManager;
    52 import com.sun.tools.javac.util.StringUtils;
    53 import com.sun.tools.javac.util.StringUtils;
    53 import com.sun.tools.sjavac.comp.Dependencies;
    54 import com.sun.tools.sjavac.comp.Dependencies;
    54 import com.sun.tools.sjavac.comp.JavaCompilerWithDeps;
    55 import com.sun.tools.sjavac.comp.JavaCompilerWithDeps;
   129         smartFileManager = new SmartFileManager(fileManager);
   130         smartFileManager = new SmartFileManager(fileManager);
   130         context = new Context();
   131         context = new Context();
   131         context.put(JavaFileManager.class, smartFileManager);
   132         context.put(JavaFileManager.class, smartFileManager);
   132         ResolveWithDeps.preRegister(context);
   133         ResolveWithDeps.preRegister(context);
   133         JavaCompilerWithDeps.preRegister(context, this);
   134         JavaCompilerWithDeps.preRegister(context, this);
   134         subTasks = new ArrayList<Future<?>>();
   135         subTasks = new ArrayList<>();
   135     }
   136     }
   136 
   137 
   137     /**
   138     /**
   138      * Prepare the compiler thread for idleness.
   139      * Prepare the compiler thread for idleness.
   139      */
   140      */
   216             if (id == null)
   217             if (id == null)
   217                 return;
   218                 return;
   218             if (!expect(in, JavacServer.PROTOCOL_ARGS)) {
   219             if (!expect(in, JavacServer.PROTOCOL_ARGS)) {
   219                 return;
   220                 return;
   220             }
   221             }
   221             ArrayList<String> the_options = new ArrayList<String>();
   222             ArrayList<String> the_options = new ArrayList<>();
   222             ArrayList<File> the_classes = new ArrayList<File>();
   223             ArrayList<File> the_classes = new ArrayList<>();
   223             Iterable<File> path = Arrays.<File> asList(new File(cwd));
   224             Iterable<File> path = Arrays.<File> asList(new File(cwd));
   224 
   225 
   225             for (;;) {
   226             for (;;) {
   226                 String l = in.readLine();
   227                 String l = in.readLine();
   227                 if (l == null)
   228                 if (l == null)
   238                 }
   239                 }
   239                 continue;
   240                 continue;
   240             }
   241             }
   241 
   242 
   242             // Load sources to compile
   243             // Load sources to compile
   243             Set<URI> sourcesToCompile = new HashSet<URI>();
   244             Set<URI> sourcesToCompile = new HashSet<>();
   244             for (;;) {
   245             for (;;) {
   245                 String l = in.readLine();
   246                 String l = in.readLine();
   246                 if (l == null)
   247                 if (l == null)
   247                     return;
   248                     return;
   248                 if (l.equals(JavacServer.PROTOCOL_VISIBLE_SOURCES))
   249                 if (l.equals(JavacServer.PROTOCOL_VISIBLE_SOURCES))
   253                 } catch (URISyntaxException e) {
   254                 } catch (URISyntaxException e) {
   254                     return;
   255                     return;
   255                 }
   256                 }
   256             }
   257             }
   257             // Load visible sources
   258             // Load visible sources
   258             Set<URI> visibleSources = new HashSet<URI>();
   259             Set<URI> visibleSources = new HashSet<>();
   259             boolean fix_drive_letter_case =
   260             boolean fix_drive_letter_case =
   260                 StringUtils.toLowerCase(System.getProperty("os.name")).startsWith("windows");
   261                 StringUtils.toLowerCase(System.getProperty("os.name")).startsWith("windows");
   261             for (;;) {
   262             for (;;) {
   262                 String l = in.readLine();
   263                 String l = in.readLine();
   263                 if (l == null)
   264                 if (l == null)
   282 
   283 
   283             // A completed request has been received.
   284             // A completed request has been received.
   284 
   285 
   285             // Now setup the actual compilation....
   286             // Now setup the actual compilation....
   286             // First deal with explicit source files on cmdline and in at file.
   287             // First deal with explicit source files on cmdline and in at file.
   287             com.sun.tools.javac.util.ListBuffer<JavaFileObject> compilationUnits =
   288             ListBuffer<JavaFileObject> compilationUnits = new ListBuffer<>();
   288                 new com.sun.tools.javac.util.ListBuffer<JavaFileObject>();
       
   289             for (JavaFileObject i : fileManager.getJavaFileObjectsFromFiles(the_classes)) {
   289             for (JavaFileObject i : fileManager.getJavaFileObjectsFromFiles(the_classes)) {
   290                 compilationUnits.append(i);
   290                 compilationUnits.append(i);
   291             }
   291             }
   292             // Now deal with sources supplied as source_to_compile.
   292             // Now deal with sources supplied as source_to_compile.
   293             com.sun.tools.javac.util.ListBuffer<File> sourcesToCompileFiles =
   293             ListBuffer<File> sourcesToCompileFiles = new ListBuffer<>();
   294                 new com.sun.tools.javac.util.ListBuffer<File>();
       
   295             for (URI u : sourcesToCompile) {
   294             for (URI u : sourcesToCompile) {
   296                 sourcesToCompileFiles.append(new File(u));
   295                 sourcesToCompileFiles.append(new File(u));
   297             }
   296             }
   298             for (JavaFileObject i : fileManager.getJavaFileObjectsFromFiles(sourcesToCompileFiles)) {
   297             for (JavaFileObject i : fileManager.getJavaFileObjectsFromFiles(sourcesToCompileFiles)) {
   299                 compilationUnits.append(i);
   298                 compilationUnits.append(i);