1073 Assert.checkNonNull(s, () -> "no entry in cache for " + d.module);
1074 readable.addAll(s);
1075 if (d.flags.contains(RequiresFlag.PUBLIC)) {
1076 requiresPublic.add(d.module);
1077 requiresPublic.addAll(s);
1078 }
1079 }
1080
1081 requiresPublicCache.put(msym, requiresPublic);
1082 initVisiblePackages(msym, readable);
1083 for (ExportsDirective d: msym.exports) {
1084 d.packge.modle = msym;
1085 }
1086
1087 }
1088
1089 private Set<ModuleSymbol> retrieveRequiresPublic(ModuleSymbol msym) {
1090 Set<ModuleSymbol> requiresPublic = requiresPublicCache.get(msym);
1091
1092 if (requiresPublic == null) {
1093 //the module graph may contain cycles involving automatic modules or -XaddReads edges
1094 requiresPublic = new HashSet<>();
1095
1096 Set<ModuleSymbol> seen = new HashSet<>();
1097 List<ModuleSymbol> todo = List.of(msym);
1098
1099 while (todo.nonEmpty()) {
1100 ModuleSymbol current = todo.head;
1101 todo = todo.tail;
1102 if (!seen.add(current))
1103 continue;
1104 requiresPublic.add(current);
1105 current.complete();
1106 Iterable<? extends RequiresDirective> requires;
1107 if (current != syms.unnamedModule) {
1108 Assert.checkNonNull(current.requires, () -> current + ".requires == null; " + msym);
1109 requires = current.requires;
1110 for (RequiresDirective rd : requires) {
1111 if (rd.isPublic())
1112 todo = todo.prepend(rd.module);
1113 }
1175 if (addExports != null)
1176 return;
1177
1178 addExports = new LinkedHashMap<>();
1179
1180 if (addExportsOpt == null)
1181 return;
1182
1183 // System.err.println("Modules.addExports:\n " + addExportsOpt.replace("\0", "\n "));
1184
1185 Pattern ep = Pattern.compile("([^/]+)/([^=]+)=(.*)");
1186 for (String s: addExportsOpt.split("\0+")) {
1187 if (s.isEmpty())
1188 continue;
1189 Matcher em = ep.matcher(s);
1190 if (!em.matches()) {
1191 continue;
1192 }
1193
1194 // Terminology comes from
1195 // -XaddExports:module/package=target,...
1196 // Compare to
1197 // module module { exports package to target, ... }
1198 String moduleName = em.group(1);
1199 String packageName = em.group(2);
1200 String targetNames = em.group(3);
1201
1202 ModuleSymbol msym = syms.enterModule(names.fromString(moduleName));
1203 PackageSymbol p = syms.enterPackage(msym, names.fromString(packageName));
1204 p.modle = msym; // TODO: do we need this?
1205
1206 List<ModuleSymbol> targetModules = List.nil();
1207 for (String toModule : targetNames.split("[ ,]+")) {
1208 ModuleSymbol m;
1209 if (toModule.equals("ALL-UNNAMED")) {
1210 m = syms.unnamedModule;
1211 } else {
1212 if (!SourceVersion.isName(toModule)) {
1213 // TODO: error: invalid module name
1214 continue;
1215 }
1228 if (addReads != null)
1229 return;
1230
1231 addReads = new LinkedHashMap<>();
1232
1233 if (addReadsOpt == null)
1234 return;
1235
1236 // System.err.println("Modules.addReads:\n " + addReadsOpt.replace("\0", "\n "));
1237
1238 Pattern rp = Pattern.compile("([^=]+)=(.*)");
1239 for (String s : addReadsOpt.split("\0+")) {
1240 if (s.isEmpty())
1241 continue;
1242 Matcher rm = rp.matcher(s);
1243 if (!rm.matches()) {
1244 continue;
1245 }
1246
1247 // Terminology comes from
1248 // -XaddReads:target-module=source-module,...
1249 // Compare to
1250 // module target-module { requires source-module; ... }
1251 String targetName = rm.group(1);
1252 String sources = rm.group(2);
1253
1254 ModuleSymbol msym = syms.enterModule(names.fromString(targetName));
1255 for (String source : sources.split("[ ,]+")) {
1256 ModuleSymbol sourceModule;
1257 if (source.equals("ALL-UNNAMED")) {
1258 sourceModule = syms.unnamedModule;
1259 } else {
1260 if (!SourceVersion.isName(source)) {
1261 // TODO: error: invalid module name
1262 continue;
1263 }
1264 sourceModule = syms.enterModule(names.fromString(source));
1265 }
1266 addReads.computeIfAbsent(msym, m -> new HashSet<>())
1267 .add(new RequiresDirective(sourceModule, EnumSet.of(RequiresFlag.EXTRA)));
1268 }
|
1073 Assert.checkNonNull(s, () -> "no entry in cache for " + d.module);
1074 readable.addAll(s);
1075 if (d.flags.contains(RequiresFlag.PUBLIC)) {
1076 requiresPublic.add(d.module);
1077 requiresPublic.addAll(s);
1078 }
1079 }
1080
1081 requiresPublicCache.put(msym, requiresPublic);
1082 initVisiblePackages(msym, readable);
1083 for (ExportsDirective d: msym.exports) {
1084 d.packge.modle = msym;
1085 }
1086
1087 }
1088
1089 private Set<ModuleSymbol> retrieveRequiresPublic(ModuleSymbol msym) {
1090 Set<ModuleSymbol> requiresPublic = requiresPublicCache.get(msym);
1091
1092 if (requiresPublic == null) {
1093 //the module graph may contain cycles involving automatic modules or --add-reads edges
1094 requiresPublic = new HashSet<>();
1095
1096 Set<ModuleSymbol> seen = new HashSet<>();
1097 List<ModuleSymbol> todo = List.of(msym);
1098
1099 while (todo.nonEmpty()) {
1100 ModuleSymbol current = todo.head;
1101 todo = todo.tail;
1102 if (!seen.add(current))
1103 continue;
1104 requiresPublic.add(current);
1105 current.complete();
1106 Iterable<? extends RequiresDirective> requires;
1107 if (current != syms.unnamedModule) {
1108 Assert.checkNonNull(current.requires, () -> current + ".requires == null; " + msym);
1109 requires = current.requires;
1110 for (RequiresDirective rd : requires) {
1111 if (rd.isPublic())
1112 todo = todo.prepend(rd.module);
1113 }
1175 if (addExports != null)
1176 return;
1177
1178 addExports = new LinkedHashMap<>();
1179
1180 if (addExportsOpt == null)
1181 return;
1182
1183 // System.err.println("Modules.addExports:\n " + addExportsOpt.replace("\0", "\n "));
1184
1185 Pattern ep = Pattern.compile("([^/]+)/([^=]+)=(.*)");
1186 for (String s: addExportsOpt.split("\0+")) {
1187 if (s.isEmpty())
1188 continue;
1189 Matcher em = ep.matcher(s);
1190 if (!em.matches()) {
1191 continue;
1192 }
1193
1194 // Terminology comes from
1195 // --add-exports module/package=target,...
1196 // Compare to
1197 // module module { exports package to target, ... }
1198 String moduleName = em.group(1);
1199 String packageName = em.group(2);
1200 String targetNames = em.group(3);
1201
1202 ModuleSymbol msym = syms.enterModule(names.fromString(moduleName));
1203 PackageSymbol p = syms.enterPackage(msym, names.fromString(packageName));
1204 p.modle = msym; // TODO: do we need this?
1205
1206 List<ModuleSymbol> targetModules = List.nil();
1207 for (String toModule : targetNames.split("[ ,]+")) {
1208 ModuleSymbol m;
1209 if (toModule.equals("ALL-UNNAMED")) {
1210 m = syms.unnamedModule;
1211 } else {
1212 if (!SourceVersion.isName(toModule)) {
1213 // TODO: error: invalid module name
1214 continue;
1215 }
1228 if (addReads != null)
1229 return;
1230
1231 addReads = new LinkedHashMap<>();
1232
1233 if (addReadsOpt == null)
1234 return;
1235
1236 // System.err.println("Modules.addReads:\n " + addReadsOpt.replace("\0", "\n "));
1237
1238 Pattern rp = Pattern.compile("([^=]+)=(.*)");
1239 for (String s : addReadsOpt.split("\0+")) {
1240 if (s.isEmpty())
1241 continue;
1242 Matcher rm = rp.matcher(s);
1243 if (!rm.matches()) {
1244 continue;
1245 }
1246
1247 // Terminology comes from
1248 // --add-reads target-module=source-module,...
1249 // Compare to
1250 // module target-module { requires source-module; ... }
1251 String targetName = rm.group(1);
1252 String sources = rm.group(2);
1253
1254 ModuleSymbol msym = syms.enterModule(names.fromString(targetName));
1255 for (String source : sources.split("[ ,]+")) {
1256 ModuleSymbol sourceModule;
1257 if (source.equals("ALL-UNNAMED")) {
1258 sourceModule = syms.unnamedModule;
1259 } else {
1260 if (!SourceVersion.isName(source)) {
1261 // TODO: error: invalid module name
1262 continue;
1263 }
1264 sourceModule = syms.enterModule(names.fromString(source));
1265 }
1266 addReads.computeIfAbsent(msym, m -> new HashSet<>())
1267 .add(new RequiresDirective(sourceModule, EnumSet.of(RequiresFlag.EXTRA)));
1268 }
|