src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java
changeset 50738 6cc2dc161c64
parent 50285 5b6bdc59f8cc
child 51123 d7c4c42ab260
equal deleted inserted replaced
50734:0828a0f6676b 50738:6cc2dc161c64
    79 import com.sun.tools.javac.code.Symtab;
    79 import com.sun.tools.javac.code.Symtab;
    80 import com.sun.tools.javac.code.Type;
    80 import com.sun.tools.javac.code.Type;
    81 import com.sun.tools.javac.code.Types;
    81 import com.sun.tools.javac.code.Types;
    82 import com.sun.tools.javac.jvm.ClassWriter;
    82 import com.sun.tools.javac.jvm.ClassWriter;
    83 import com.sun.tools.javac.jvm.JNIWriter;
    83 import com.sun.tools.javac.jvm.JNIWriter;
       
    84 import com.sun.tools.javac.jvm.Target;
    84 import com.sun.tools.javac.main.Option;
    85 import com.sun.tools.javac.main.Option;
    85 import com.sun.tools.javac.resources.CompilerProperties.Errors;
    86 import com.sun.tools.javac.resources.CompilerProperties.Errors;
    86 import com.sun.tools.javac.resources.CompilerProperties.Warnings;
    87 import com.sun.tools.javac.resources.CompilerProperties.Warnings;
    87 import com.sun.tools.javac.tree.JCTree;
    88 import com.sun.tools.javac.tree.JCTree;
    88 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
    89 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
   142     private final TypeEnvs typeEnvs;
   143     private final TypeEnvs typeEnvs;
   143     private final Types types;
   144     private final Types types;
   144     private final JavaFileManager fileManager;
   145     private final JavaFileManager fileManager;
   145     private final ModuleFinder moduleFinder;
   146     private final ModuleFinder moduleFinder;
   146     private final Source source;
   147     private final Source source;
       
   148     private final Target target;
   147     private final boolean allowModules;
   149     private final boolean allowModules;
   148     private final boolean allowAccessIntoSystem;
   150     private final boolean allowAccessIntoSystem;
   149 
   151 
   150     public final boolean multiModuleMode;
   152     public final boolean multiModuleMode;
   151 
   153 
   189         typeEnvs = TypeEnvs.instance(context);
   191         typeEnvs = TypeEnvs.instance(context);
   190         moduleFinder = ModuleFinder.instance(context);
   192         moduleFinder = ModuleFinder.instance(context);
   191         types = Types.instance(context);
   193         types = Types.instance(context);
   192         fileManager = context.get(JavaFileManager.class);
   194         fileManager = context.get(JavaFileManager.class);
   193         source = Source.instance(context);
   195         source = Source.instance(context);
       
   196         target = Target.instance(context);
   194         allowModules = Feature.MODULES.allowedInSource(source);
   197         allowModules = Feature.MODULES.allowedInSource(source);
   195         Options options = Options.instance(context);
   198         Options options = Options.instance(context);
   196 
   199 
   197         allowAccessIntoSystem = options.isUnset(Option.RELEASE);
   200         allowAccessIntoSystem = options.isUnset(Option.RELEASE);
   198         lintOptions = options.isUnset(Option.XLINT_CUSTOM, "-" + LintCategory.OPTIONS.option);
   201         lintOptions = options.isUnset(Option.XLINT_CUSTOM, "-" + LintCategory.OPTIONS.option);
  1232              (observable == null) ? (moduleFinder.findModule(sym).kind != ERR) : observable.contains(sym);
  1235              (observable == null) ? (moduleFinder.findModule(sym).kind != ERR) : observable.contains(sym);
  1233         Predicate<ModuleSymbol> systemModulePred = sym -> (sym.flags() & Flags.SYSTEM_MODULE) != 0;
  1236         Predicate<ModuleSymbol> systemModulePred = sym -> (sym.flags() & Flags.SYSTEM_MODULE) != 0;
  1234         Set<ModuleSymbol> enabledRoot = new LinkedHashSet<>();
  1237         Set<ModuleSymbol> enabledRoot = new LinkedHashSet<>();
  1235 
  1238 
  1236         if (rootModules.contains(syms.unnamedModule)) {
  1239         if (rootModules.contains(syms.unnamedModule)) {
  1237             ModuleSymbol javaSE = syms.getModule(java_se);
       
  1238             Predicate<ModuleSymbol> jdkModulePred;
  1240             Predicate<ModuleSymbol> jdkModulePred;
  1239 
  1241             if (target.allApiModulesAreRoots()) {
  1240             if (javaSE != null && (observable == null || observable.contains(javaSE))) {
       
  1241                 jdkModulePred = sym -> {
  1242                 jdkModulePred = sym -> {
  1242                     sym.complete();
  1243                     sym.complete();
  1243                     return   !sym.name.startsWith(java_)
  1244                     return sym.exports.stream().anyMatch(e -> e.modules == null);
  1244                            && sym.exports.stream().anyMatch(e -> e.modules == null);
       
  1245                 };
  1245                 };
  1246                 enabledRoot.add(javaSE);
       
  1247             } else {
  1246             } else {
  1248                 jdkModulePred = sym -> true;
  1247                 ModuleSymbol javaSE = syms.getModule(java_se);
       
  1248                 if (javaSE != null && (observable == null || observable.contains(javaSE))) {
       
  1249                     jdkModulePred = sym -> {
       
  1250                         sym.complete();
       
  1251                         return !sym.name.startsWith(java_)
       
  1252                             && sym.exports.stream().anyMatch(e -> e.modules == null);
       
  1253                     };
       
  1254                     enabledRoot.add(javaSE);
       
  1255                 } else {
       
  1256                     jdkModulePred = sym -> true;
       
  1257                 }
  1249             }
  1258             }
  1250 
  1259 
  1251             Predicate<ModuleSymbol> noIncubatorPred = sym -> {
  1260             Predicate<ModuleSymbol> noIncubatorPred = sym -> {
  1252                 sym.complete();
  1261                 sym.complete();
  1253                 return !sym.resolutionFlags.contains(ModuleResolutionFlags.DO_NOT_RESOLVE_BY_DEFAULT);
  1262                 return !sym.resolutionFlags.contains(ModuleResolutionFlags.DO_NOT_RESOLVE_BY_DEFAULT);