make/tools/classanalyzer/src/com/sun/classanalyzer/ModuleConfig.java
Print this page
*** 31,55 ****
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import java.util.regex.Pattern;
!
! import com.sun.classanalyzer.Module.RequiresModule;
import java.util.LinkedHashMap;
import java.util.Map;
/**
*
* @author Mandy Chung
*/
public class ModuleConfig {
private final Set<String> roots;
! private final Set<String> includes;
! private final Set<String> permits;
! private final Map<String, RequiresModule> requires;
private final Filter filter;
private List<String> members;
private String mainClass;
final String module;
--- 31,55 ----
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import java.util.regex.Pattern;
! import java.util.EnumSet;
import java.util.LinkedHashMap;
import java.util.Map;
+ import com.sun.classanalyzer.ModuleInfo.Dependence;
/**
*
* @author Mandy Chung
*/
public class ModuleConfig {
private final Set<String> roots;
! protected final Set<String> includes;
! protected final Set<String> permits;
! protected final Map<String, Dependence> requires;
private final Filter filter;
private List<String> members;
private String mainClass;
final String module;
*** 60,70 ****
ModuleConfig(String name, String mainClass) throws IOException {
this.module = name;
this.roots = new TreeSet<String>();
this.includes = new TreeSet<String>();
this.permits = new TreeSet<String>();
! this.requires = new LinkedHashMap<String, RequiresModule>();
this.filter = new Filter(this);
this.mainClass = mainClass;
}
List<String> members() {
--- 60,70 ----
ModuleConfig(String name, String mainClass) throws IOException {
this.module = name;
this.roots = new TreeSet<String>();
this.includes = new TreeSet<String>();
this.permits = new TreeSet<String>();
! this.requires = new LinkedHashMap<String, Dependence>();
this.filter = new Filter(this);
this.mainClass = mainClass;
}
List<String> members() {
*** 83,96 ****
Set<String> permits() {
return permits;
}
! Collection<RequiresModule> requires() {
return requires.values();
}
String mainClass() {
return mainClass;
}
boolean matchesRoot(String name) {
--- 83,110 ----
Set<String> permits() {
return permits;
}
! Collection<Dependence> requires() {
return requires.values();
}
+ void export(Module m) {
+ Dependence d = requires.get(m.name());
+ if (d == null) {
+ d = new Dependence(m, EnumSet.of(Dependence.Modifier.PUBLIC));
+ } else if (!d.isPublic()){
+ throw new RuntimeException(module + " should require public " + m.name());
+ }
+ requires.put(m.name(), d);
+ }
+
+ void addPermit(Module m) {
+ permits.add(m.name());
+ }
+
String mainClass() {
return mainClass;
}
boolean matchesRoot(String name) {
*** 562,573 ****
boolean isBootModule = s.equals("jdk.boot");
if (!local && isBootModule) {
throw new RuntimeException(file + ", line " +
lineNumber + " requires: \"" + s + "\" must be local");
}
! RequiresModule rm = new RequiresModule(s, optional, reexport, local);
! config.requires.put(s, rm);
}
}
}
if (lastchar == ';') {
inRoots = false;
--- 576,587 ----
boolean isBootModule = s.equals("jdk.boot");
if (!local && isBootModule) {
throw new RuntimeException(file + ", line " +
lineNumber + " requires: \"" + s + "\" must be local");
}
! Dependence d = new Dependence(s, optional, reexport, local);
! config.requires.put(s, d);
}
}
}
if (lastchar == ';') {
inRoots = false;
*** 626,636 ****
sb.append(format("include", includes));
sb.append(format("root", roots));
sb.append(format("allow", filter.allow));
sb.append(format("exclude", filter.exclude));
Set<String> reqs = new TreeSet<String>();
! for (RequiresModule rm : requires.values()) {
reqs.add(rm.toString());
}
sb.append(format("requires", reqs));
sb.append(format("permits", permits));
sb.append("}\n");
--- 640,650 ----
sb.append(format("include", includes));
sb.append(format("root", roots));
sb.append(format("allow", filter.allow));
sb.append(format("exclude", filter.exclude));
Set<String> reqs = new TreeSet<String>();
! for (Dependence rm : requires.values()) {
reqs.add(rm.toString());
}
sb.append(format("requires", reqs));
sb.append(format("permits", permits));
sb.append("}\n");