--- old/src/java.base/share/classes/jdk/internal/module/Builder.java 2017-02-07 13:13:42.437863094 +0000 +++ new/src/java.base/share/classes/jdk/internal/module/Builder.java 2017-02-07 13:13:42.269851556 +0000 @@ -31,6 +31,7 @@ import java.lang.module.ModuleDescriptor.Requires; import java.lang.module.ModuleDescriptor.Version; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Set; @@ -137,7 +138,6 @@ final String name; boolean open; - boolean automatic; boolean synthetic; Set requires; Set exports; @@ -165,11 +165,6 @@ return this; } - Builder automatic(boolean value) { - this.automatic = value; - return this; - } - Builder synthetic(boolean value) { this.synthetic = value; return this; @@ -228,13 +223,10 @@ * * @throws IllegalArgumentException if {@code v} is null or cannot be * parsed as a version string - * @throws IllegalStateException if the module version is already set * * @see Version#parse(String) */ public Builder version(String v) { - if (version != null) - throw new IllegalStateException("module version already set"); Version ver = cachedVersion; if (ver != null && v.equals(ver.toString())) { version = ver; @@ -246,36 +238,24 @@ /** * Sets the module main class. - * - * @throws IllegalStateException if already set */ public Builder mainClass(String mc) { - if (mainClass != null) - throw new IllegalStateException("main class already set"); mainClass = mc; return this; } /** * Sets the OS name. - * - * @throws IllegalStateException if already set */ public Builder osName(String name) { - if (osName != null) - throw new IllegalStateException("OS name already set"); this.osName = name; return this; } /** * Sets the OS arch. - * - * @throws IllegalStateException if already set */ public Builder osArch(String arch) { - if (osArch != null) - throw new IllegalStateException("OS arch already set"); this.osArch = arch; return this; } @@ -286,8 +266,6 @@ * @throws IllegalStateException if already set */ public Builder osVersion(String version) { - if (osVersion != null) - throw new IllegalStateException("OS version already set"); this.osVersion = version; return this; } @@ -298,11 +276,19 @@ public ModuleDescriptor build(int hashCode) { assert name != null; + Set modifiers; + if (open || synthetic) { + modifiers = new HashSet<>(); + if (open) modifiers.add(ModuleDescriptor.Modifier.OPEN); + if (synthetic) modifiers.add(ModuleDescriptor.Modifier.SYNTHETIC); + modifiers = Collections.unmodifiableSet(modifiers); + } else { + modifiers = Collections.emptySet(); + } + return JLMA.newModuleDescriptor(name, version, - open, - automatic, - synthetic, + modifiers, requires, exports, opens,