langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java
changeset 40602 50045337b3a1
parent 40308 274367a99f98
child 40604 92e423b99e98
equal deleted inserted replaced
40601:9af676462cbf 40602:50045337b3a1
   117 
   117 
   118     /** Force a completion failure on this name
   118     /** Force a completion failure on this name
   119      */
   119      */
   120     final Name completionFailureName;
   120     final Name completionFailureName;
   121 
   121 
   122     /** Module specified with -Xmodule:
       
   123      */
       
   124     final Name moduleOverride;
       
   125 
       
   126     /** Access to files
   122     /** Access to files
   127      */
   123      */
   128     private final JavaFileManager fileManager;
   124     private final JavaFileManager fileManager;
   129 
   125 
   130     /** Dependency tracker
   126     /** Dependency tracker
   207 
   203 
   208         completionFailureName =
   204         completionFailureName =
   209             options.isSet("failcomplete")
   205             options.isSet("failcomplete")
   210             ? names.fromString(options.get("failcomplete"))
   206             ? names.fromString(options.get("failcomplete"))
   211             : null;
   207             : null;
   212 
       
   213         moduleOverride = options.isSet(Option.XMODULE) ? names.fromString(options.get(Option.XMODULE))
       
   214                                                 : null;
       
   215 
   208 
   216         // Temporary, until more info is available from the module system.
   209         // Temporary, until more info is available from the module system.
   217         boolean useCtProps;
   210         boolean useCtProps;
   218         JavaFileManager fm = context.get(JavaFileManager.class);
   211         JavaFileManager fm = context.get(JavaFileManager.class);
   219         if (fm instanceof JavacFileManager) {
   212         if (fm instanceof JavacFileManager) {
   525         msym.complete();
   518         msym.complete();
   526 
   519 
   527         if (msym == syms.noModule) {
   520         if (msym == syms.noModule) {
   528             preferCurrent = false;
   521             preferCurrent = false;
   529             if (userPathsFirst) {
   522             if (userPathsFirst) {
   530                 scanUserPaths(p);
   523                 scanUserPaths(p, true);
   531                 preferCurrent = true;
   524                 preferCurrent = true;
   532                 scanPlatformPath(p);
   525                 scanPlatformPath(p);
   533             } else {
   526             } else {
   534                 scanPlatformPath(p);
   527                 scanPlatformPath(p);
   535                 scanUserPaths(p);
   528                 scanUserPaths(p, true);
   536             }
   529             }
   537         } else if (msym.classLocation == StandardLocation.CLASS_PATH) {
   530         } else if (msym.classLocation == StandardLocation.CLASS_PATH) {
   538             // assert p.modle.sourceLocation == StandardLocation.SOURCE_PATH);
   531             scanUserPaths(p, msym.sourceLocation == StandardLocation.SOURCE_PATH);
   539             scanUserPaths(p);
       
   540         } else {
   532         } else {
   541             scanModulePaths(p, msym);
   533             scanModulePaths(p, msym);
   542         }
   534         }
   543     }
   535     }
   544 
   536 
   559         sourceKinds.remove(JavaFileObject.Kind.CLASS);
   551         sourceKinds.remove(JavaFileObject.Kind.CLASS);
   560         boolean wantSourceFiles = !sourceKinds.isEmpty();
   552         boolean wantSourceFiles = !sourceKinds.isEmpty();
   561 
   553 
   562         String packageName = p.fullname.toString();
   554         String packageName = p.fullname.toString();
   563 
   555 
   564         if (msym.name == moduleOverride) {
       
   565             if (wantClassFiles) {
       
   566                 fillIn(p, CLASS_PATH,
       
   567                        fileManager.list(CLASS_PATH,
       
   568                                         packageName,
       
   569                                         classKinds,
       
   570                                         false));
       
   571             }
       
   572             if (wantSourceFiles && fileManager.hasLocation(SOURCE_PATH)) {
       
   573                 fillIn(p, SOURCE_PATH,
       
   574                         fileManager.list(SOURCE_PATH,
       
   575                                         packageName,
       
   576                                         sourceKinds,
       
   577                                         false));
       
   578             }
       
   579         }
       
   580 
       
   581         Location classLocn = msym.classLocation;
   556         Location classLocn = msym.classLocation;
   582         Location sourceLocn = msym.sourceLocation;
   557         Location sourceLocn = msym.sourceLocation;
   583 
   558 
   584         if (wantClassFiles && (classLocn != null)) {
   559         if (wantClassFiles && (classLocn != null)) {
   585             fillIn(p, classLocn,
   560             fillIn(p, classLocn,
   598     }
   573     }
   599 
   574 
   600     /**
   575     /**
   601      * Scans class path and source path for files in given package.
   576      * Scans class path and source path for files in given package.
   602      */
   577      */
   603     private void scanUserPaths(PackageSymbol p) throws IOException {
   578     private void scanUserPaths(PackageSymbol p, boolean includeSourcePath) throws IOException {
   604         Set<JavaFileObject.Kind> kinds = getPackageFileKinds();
   579         Set<JavaFileObject.Kind> kinds = getPackageFileKinds();
   605 
   580 
   606         Set<JavaFileObject.Kind> classKinds = EnumSet.copyOf(kinds);
   581         Set<JavaFileObject.Kind> classKinds = EnumSet.copyOf(kinds);
   607         classKinds.remove(JavaFileObject.Kind.SOURCE);
   582         classKinds.remove(JavaFileObject.Kind.SOURCE);
   608         boolean wantClassFiles = !classKinds.isEmpty();
   583         boolean wantClassFiles = !classKinds.isEmpty();
   609 
   584 
   610         Set<JavaFileObject.Kind> sourceKinds = EnumSet.copyOf(kinds);
   585         Set<JavaFileObject.Kind> sourceKinds = EnumSet.copyOf(kinds);
   611         sourceKinds.remove(JavaFileObject.Kind.CLASS);
   586         sourceKinds.remove(JavaFileObject.Kind.CLASS);
   612         boolean wantSourceFiles = !sourceKinds.isEmpty();
   587         boolean wantSourceFiles = !sourceKinds.isEmpty();
   613 
   588 
   614         boolean haveSourcePath = fileManager.hasLocation(SOURCE_PATH);
   589         boolean haveSourcePath = includeSourcePath && fileManager.hasLocation(SOURCE_PATH);
   615 
   590 
   616         if (verbose && verbosePath) {
   591         if (verbose && verbosePath) {
   617             if (fileManager instanceof StandardJavaFileManager) {
   592             if (fileManager instanceof StandardJavaFileManager) {
   618                 StandardJavaFileManager fm = (StandardJavaFileManager)fileManager;
   593                 StandardJavaFileManager fm = (StandardJavaFileManager)fileManager;
   619                 if (haveSourcePath && wantSourceFiles) {
   594                 if (haveSourcePath && wantSourceFiles) {