langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java
changeset 42824 89b14017e8d6
parent 42823 58864b03c7b9
child 42827 36468b5fa7f4
equal deleted inserted replaced
42823:58864b03c7b9 42824:89b14017e8d6
   260         depth++;
   260         depth++;
   261         try {
   261         try {
   262             // scan trees for module defs
   262             // scan trees for module defs
   263             Set<ModuleSymbol> roots = enterModules(trees, c);
   263             Set<ModuleSymbol> roots = enterModules(trees, c);
   264 
   264 
   265             setCompilationUnitModules(trees, roots);
   265             setCompilationUnitModules(trees, roots, c);
   266 
   266 
   267             init.accept(roots);
   267             init.accept(roots);
   268 
   268 
   269             for (ModuleSymbol msym: roots) {
   269             for (ModuleSymbol msym: roots) {
   270                 msym.complete();
   270                 msym.complete();
   349                 log.error(tree.pos(), Errors.ExpectedModule);
   349                 log.error(tree.pos(), Errors.ExpectedModule);
   350             }
   350             }
   351         }
   351         }
   352     }
   352     }
   353 
   353 
   354     private void setCompilationUnitModules(List<JCCompilationUnit> trees, Set<ModuleSymbol> rootModules) {
   354     private void setCompilationUnitModules(List<JCCompilationUnit> trees, Set<ModuleSymbol> rootModules, ClassSymbol c) {
   355         // update the module for each compilation unit
   355         // update the module for each compilation unit
   356         if (multiModuleMode) {
   356         if (multiModuleMode) {
   357             checkNoAllModulePath();
   357             checkNoAllModulePath();
   358             for (JCCompilationUnit tree: trees) {
   358             for (JCCompilationUnit tree: trees) {
   359                 if (tree.defs.isEmpty()) {
   359                 if (tree.defs.isEmpty()) {
   383                                         StandardLocation.CLASS_OUTPUT, msym.name.toString());
   383                                         StandardLocation.CLASS_OUTPUT, msym.name.toString());
   384                             }
   384                             }
   385                         }
   385                         }
   386                         tree.modle = msym;
   386                         tree.modle = msym;
   387                         rootModules.add(msym);
   387                         rootModules.add(msym);
       
   388                     } else if (c != null && c.packge().modle == syms.unnamedModule) {
       
   389                         tree.modle = syms.unnamedModule;
   388                     } else {
   390                     } else {
   389                         log.error(tree.pos(), Errors.UnnamedPkgNotAllowedNamedModules);
   391                         log.error(tree.pos(), Errors.UnnamedPkgNotAllowedNamedModules);
   390                         tree.modle = syms.errModule;
   392                         tree.modle = syms.errModule;
   391                     }
   393                     }
   392                 } catch (IOException e) {
   394                 } catch (IOException e) {
   449                 rootModules.add(defaultModule);
   451                 rootModules.add(defaultModule);
   450             }
   452             }
   451 
   453 
   452             if (defaultModule != syms.unnamedModule) {
   454             if (defaultModule != syms.unnamedModule) {
   453                 syms.unnamedModule.completer = getUnnamedModuleCompleter();
   455                 syms.unnamedModule.completer = getUnnamedModuleCompleter();
   454                 if (moduleOverride == null) {
       
   455                     syms.unnamedModule.sourceLocation = StandardLocation.SOURCE_PATH;
       
   456                 }
       
   457                 syms.unnamedModule.classLocation = StandardLocation.CLASS_PATH;
   456                 syms.unnamedModule.classLocation = StandardLocation.CLASS_PATH;
   458             }
   457             }
   459 
   458 
   460             for (JCCompilationUnit tree: trees) {
   459             for (JCCompilationUnit tree: trees) {
   461                 tree.modle = defaultModule;
   460                 tree.modle = defaultModule;