< prev index next >
src/java.base/share/classes/java/lang/module/ModuleDescriptor.java
Print this page
*** 27,46 ****
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.UncheckedIOException;
- import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
- import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
--- 27,44 ----
*** 50,60 ****
import static jdk.internal.module.Checks.*;
import static java.util.Objects.*;
import jdk.internal.module.Checks;
! import jdk.internal.module.ModuleHashes;
/**
* A module descriptor.
*
--- 48,58 ----
import static jdk.internal.module.Checks.*;
import static java.util.Objects.*;
import jdk.internal.module.Checks;
! import jdk.internal.module.ModuleInfo;
/**
* A module descriptor.
*
*** 121,144 ****
}
private final Set<Modifier> mods;
private final String name;
! private Requires(Set<Modifier> ms, String mn) {
if (ms.isEmpty()) {
ms = Collections.emptySet();
} else {
ms = Collections.unmodifiableSet(EnumSet.copyOf(ms));
}
this.mods = ms;
this.name = mn;
}
! private Requires(Set<Modifier> ms, String mn, boolean unused) {
this.mods = ms;
this.name = mn;
}
/**
* Returns the set of modifiers.
*
--- 119,145 ----
}
private final Set<Modifier> mods;
private final String name;
+ private final Version compiledVersion;
! private Requires(Set<Modifier> ms, String mn, Version v) {
if (ms.isEmpty()) {
ms = Collections.emptySet();
} else {
ms = Collections.unmodifiableSet(EnumSet.copyOf(ms));
}
this.mods = ms;
this.name = mn;
+ this.compiledVersion = v;
}
! private Requires(Set<Modifier> ms, String mn, Version v, boolean unused) {
this.mods = ms;
this.name = mn;
+ this.compiledVersion = v;
}
/**
* Returns the set of modifiers.
*
*** 156,183 ****
public String name() {
return name;
}
/**
* Compares this module dependence to another.
*
* <p> Two {@code Requires} objects are compared by comparing their
* module name lexicographically. Where the module names are equal then
* the sets of modifiers are compared based on a value computed from the
! * ordinal of each modifier. </p>
*
* @return A negative integer, zero, or a positive integer if this module
* dependence is less than, equal to, or greater than the given
* module dependence
*/
@Override
public int compareTo(Requires that) {
int c = this.name().compareTo(that.name());
if (c != 0)
return c;
! // same name, compare by modifiers
! return Long.compare(this.modsValue(), that.modsValue());
}
/**
* Return a value for the modifiers to allow sets of modifiers to be
* compared.
--- 157,214 ----
public String name() {
return name;
}
/**
+ * Returns the version of the module if recorded at compile-time.
+ *
+ * @return The version of the module if recorded at compile-time
+ */
+ public Optional<Version> compiledVersion() {
+ return Optional.ofNullable(compiledVersion);
+ }
+
+ /**
* Compares this module dependence to another.
*
* <p> Two {@code Requires} objects are compared by comparing their
* module name lexicographically. Where the module names are equal then
* the sets of modifiers are compared based on a value computed from the
! * ordinal of each modifier. Where the module names are equal and the
! * set of modifiers are equal then the version of the modules recorded
! * at compile-time are compared. When comparing the versions recorded
! * at compile-time then a dependence that has a recorded version is
! * considered to succeed a dependence that does not have a recorded
! * version. </p>
*
* @return A negative integer, zero, or a positive integer if this module
* dependence is less than, equal to, or greater than the given
* module dependence
*/
@Override
public int compareTo(Requires that) {
int c = this.name().compareTo(that.name());
if (c != 0)
return c;
!
! // modifiers
! c = Long.compare(this.modsValue(), that.modsValue());
! if (c != 0)
! return c;
!
! // compiledVersion
! if (this.compiledVersion != null) {
! if (that.compiledVersion != null)
! c = this.compiledVersion.compareTo(that.compiledVersion);
! else
! c = 1;
! } else {
! if (that.compiledVersion != null)
! c = -1;
! }
!
! return c;
}
/**
* Return a value for the modifiers to allow sets of modifiers to be
* compared.
*** 193,203 ****
/**
* Tests this module dependence for equality with the given object.
*
* <p> If the given object is not a {@code Requires} then this method
* returns {@code false}. Two module dependence objects are equal if
! * the module names are equal and set of modifiers are equal. </p>
*
* <p> This method satisfies the general contract of the {@link
* java.lang.Object#equals(Object) Object.equals} method. </p>
*
* @param ob
--- 224,236 ----
/**
* Tests this module dependence for equality with the given object.
*
* <p> If the given object is not a {@code Requires} then this method
* returns {@code false}. Two module dependence objects are equal if
! * the module names are equal, set of modifiers are equal, and the
! * compiled version of both modules is equal or not recorded for
! * both modules. </p>
*
* <p> This method satisfies the general contract of the {@link
* java.lang.Object#equals(Object) Object.equals} method. </p>
*
* @param ob
*** 209,243 ****
@Override
public boolean equals(Object ob) {
if (!(ob instanceof Requires))
return false;
Requires that = (Requires)ob;
! return (name.equals(that.name) && mods.equals(that.mods));
}
/**
* Computes a hash code for this module dependence.
*
! * <p> The hash code is based upon the module name and modifiers. It
! * satisfies the general contract of the {@link Object#hashCode
! * Object.hashCode} method. </p>
*
* @return The hash-code value for this module dependence
*/
@Override
public int hashCode() {
! return name.hashCode() * 43 + mods.hashCode();
}
/**
* Returns a string describing module dependence.
*
* @return A string describing module dependence
*/
@Override
public String toString() {
! return ModuleDescriptor.toString(mods, name);
}
}
--- 242,286 ----
@Override
public boolean equals(Object ob) {
if (!(ob instanceof Requires))
return false;
Requires that = (Requires)ob;
! return name.equals(that.name) && mods.equals(that.mods)
! && Objects.equals(compiledVersion, that.compiledVersion);
}
/**
* Computes a hash code for this module dependence.
*
! * <p> The hash code is based upon the module name, modifiers, and the
! * module version if recorded at compile time. It satisfies the general
! * contract of the {@link Object#hashCode Object.hashCode} method. </p>
*
* @return The hash-code value for this module dependence
*/
@Override
public int hashCode() {
! int hash = name.hashCode() * 43 + mods.hashCode();
! if (compiledVersion != null)
! hash = hash * 43 + compiledVersion.hashCode();
! return hash;
}
/**
* Returns a string describing module dependence.
*
* @return A string describing module dependence
*/
@Override
public String toString() {
! String what;
! if (compiledVersion != null) {
! what = name() + " (@" + compiledVersion + ")";
! } else {
! what = name();
! }
! return ModuleDescriptor.toString(mods, what);
}
}
*** 965,977 ****
}
}
-
- // From module declarations
private final String name;
private final boolean open;
// Indicates if synthesised for a JAR file found on the module path
private final boolean automatic;
--- 1008,1019 ----
}
}
private final String name;
+ private final Version version;
private final boolean open;
// Indicates if synthesised for a JAR file found on the module path
private final boolean automatic;
*** 982,1106 ****
private final Set<Exports> exports;
private final Set<Opens> opens;
private final Set<String> uses;
private final Set<Provides> provides;
! // "Extended" information, added post-compilation by tools
! private final Version version;
private final String mainClass;
private final String osName;
private final String osArch;
private final String osVersion;
- private final Set<String> packages;
- private final ModuleHashes hashes;
private ModuleDescriptor(String name,
boolean open,
boolean automatic,
boolean synthetic,
Set<Requires> requires,
Set<Exports> exports,
Set<Opens> opens,
Set<String> uses,
Set<Provides> provides,
! Version version,
String mainClass,
String osName,
String osArch,
! String osVersion,
! Set<String> packages,
! ModuleHashes hashes)
{
-
this.name = name;
this.open = open;
this.automatic = automatic;
this.synthetic = synthetic;
assert (requires.stream().map(Requires::name).distinct().count()
== requires.size());
this.requires = emptyOrUnmodifiableSet(requires);
-
this.exports = emptyOrUnmodifiableSet(exports);
this.opens = emptyOrUnmodifiableSet(opens);
this.uses = emptyOrUnmodifiableSet(uses);
this.provides = emptyOrUnmodifiableSet(provides);
! this.version = version;
this.mainClass = mainClass;
this.osName = osName;
this.osArch = osArch;
this.osVersion = osVersion;
- this.hashes = hashes;
- this.packages = emptyOrUnmodifiableSet(packages);
}
/**
* Clones the given module descriptor with an augmented set of packages
*/
ModuleDescriptor(ModuleDescriptor md, Set<String> pkgs) {
this.name = md.name;
this.open = md.open;
this.automatic = md.automatic;
this.synthetic = md.synthetic;
this.requires = md.requires;
this.exports = md.exports;
this.opens = md.opens;
this.uses = md.uses;
this.provides = md.provides;
! this.version = md.version;
this.mainClass = md.mainClass;
this.osName = md.osName;
this.osArch = md.osArch;
this.osVersion = md.osVersion;
- this.hashes = null; // need to ignore
-
- Set<String> packages = new HashSet<>(md.packages);
- packages.addAll(pkgs);
- this.packages = emptyOrUnmodifiableSet(packages);
}
/**
* Creates a module descriptor from its components.
* The arguments are pre-validated and sets are unmodifiable sets.
*/
ModuleDescriptor(String name,
boolean open,
boolean automatic,
boolean synthetic,
Set<Requires> requires,
Set<Exports> exports,
Set<Opens> opens,
Set<String> uses,
Set<Provides> provides,
! Version version,
String mainClass,
String osName,
String osArch,
String osVersion,
- Set<String> packages,
- ModuleHashes hashes,
int hashCode,
boolean unused) {
this.name = name;
this.open = open;
this.automatic = automatic;
this.synthetic = synthetic;
this.requires = requires;
this.exports = exports;
this.opens = opens;
this.uses = uses;
this.provides = provides;
this.packages = packages;
- this.version = version;
this.mainClass = mainClass;
this.osName = osName;
this.osArch = osArch;
this.osVersion = osVersion;
- this.hashes = hashes;
this.hash = hashCode;
}
/**
* <p> The module name. </p>
--- 1024,1140 ----
private final Set<Exports> exports;
private final Set<Opens> opens;
private final Set<String> uses;
private final Set<Provides> provides;
! // Added post-compilation by tools
! private final Set<String> packages;
private final String mainClass;
private final String osName;
private final String osArch;
private final String osVersion;
private ModuleDescriptor(String name,
+ Version version,
boolean open,
boolean automatic,
boolean synthetic,
Set<Requires> requires,
Set<Exports> exports,
Set<Opens> opens,
Set<String> uses,
Set<Provides> provides,
! Set<String> packages,
String mainClass,
String osName,
String osArch,
! String osVersion)
{
this.name = name;
+ this.version = version;
this.open = open;
this.automatic = automatic;
this.synthetic = synthetic;
assert (requires.stream().map(Requires::name).distinct().count()
== requires.size());
this.requires = emptyOrUnmodifiableSet(requires);
this.exports = emptyOrUnmodifiableSet(exports);
this.opens = emptyOrUnmodifiableSet(opens);
this.uses = emptyOrUnmodifiableSet(uses);
this.provides = emptyOrUnmodifiableSet(provides);
!
! this.packages = emptyOrUnmodifiableSet(packages);
this.mainClass = mainClass;
this.osName = osName;
this.osArch = osArch;
this.osVersion = osVersion;
}
/**
* Clones the given module descriptor with an augmented set of packages
*/
ModuleDescriptor(ModuleDescriptor md, Set<String> pkgs) {
this.name = md.name;
+ this.version = md.version;
this.open = md.open;
this.automatic = md.automatic;
this.synthetic = md.synthetic;
this.requires = md.requires;
this.exports = md.exports;
this.opens = md.opens;
this.uses = md.uses;
this.provides = md.provides;
! Set<String> packages = new HashSet<>(md.packages);
! packages.addAll(pkgs);
! this.packages = emptyOrUnmodifiableSet(packages);
!
this.mainClass = md.mainClass;
this.osName = md.osName;
this.osArch = md.osArch;
this.osVersion = md.osVersion;
}
/**
* Creates a module descriptor from its components.
* The arguments are pre-validated and sets are unmodifiable sets.
*/
ModuleDescriptor(String name,
+ Version version,
boolean open,
boolean automatic,
boolean synthetic,
Set<Requires> requires,
Set<Exports> exports,
Set<Opens> opens,
Set<String> uses,
Set<Provides> provides,
! Set<String> packages,
String mainClass,
String osName,
String osArch,
String osVersion,
int hashCode,
boolean unused) {
this.name = name;
+ this.version = version;
this.open = open;
this.automatic = automatic;
this.synthetic = synthetic;
this.requires = requires;
this.exports = exports;
this.opens = opens;
this.uses = uses;
this.provides = provides;
this.packages = packages;
this.mainClass = mainClass;
this.osName = osName;
this.osArch = osArch;
this.osVersion = osVersion;
this.hash = hashCode;
}
/**
* <p> The module name. </p>
*** 1282,1298 ****
*/
public Set<String> packages() {
return packages;
}
- /**
- * Returns the object with the hashes of other modules
- */
- Optional<ModuleHashes> hashes() {
- return Optional.ofNullable(hashes);
- }
-
/**
* A builder used for building {@link ModuleDescriptor} objects.
*
* <p> {@code ModuleDescriptor} defines the {@link #module module}, {@link
--- 1316,1325 ----
*** 1315,1367 ****
* @since 9
*/
public static final class Builder {
final String name;
final boolean strict; // true if module names are checked
! boolean open;
boolean automatic;
- boolean synthetic;
final Map<String, Requires> requires = new HashMap<>();
-
final Map<String, Exports> exports = new HashMap<>();
final Map<String, Opens> opens = new HashMap<>();
final Set<String> concealedPackages = new HashSet<>();
-
final Set<String> uses = new HashSet<>();
final Map<String, Provides> provides = new HashMap<>();
Version version;
String osName;
String osArch;
String osVersion;
String mainClass;
- ModuleHashes hashes;
/**
* Initializes a new builder with the given module name.
*
* @param strict
* Indicates whether module names are checked or not
*/
! Builder(String name, boolean strict) {
! this.strict = strict;
this.name = (strict) ? requireModuleName(name) : name;
! }
!
! /* package */ Builder open(boolean open) {
this.open = open;
! return this;
}
/* package */ Builder automatic(boolean automatic) {
this.automatic = automatic;
return this;
}
! /* package */ boolean isOpen() { return open; }
! /* package */ boolean isAutomatic() {
! return automatic;
}
/**
* Adds a dependence on a module.
*
--- 1342,1398 ----
* @since 9
*/
public static final class Builder {
final String name;
final boolean strict; // true if module names are checked
! final boolean open;
! final boolean synthetic;
boolean automatic;
final Map<String, Requires> requires = new HashMap<>();
final Map<String, Exports> exports = new HashMap<>();
final Map<String, Opens> opens = new HashMap<>();
final Set<String> concealedPackages = new HashSet<>();
final Set<String> uses = new HashSet<>();
final Map<String, Provides> provides = new HashMap<>();
Version version;
String osName;
String osArch;
String osVersion;
String mainClass;
/**
* Initializes a new builder with the given module name.
*
* @param strict
* Indicates whether module names are checked or not
*/
! Builder(String name, boolean strict, boolean open, boolean synthetic) {
this.name = (strict) ? requireModuleName(name) : name;
! this.strict = strict;
this.open = open;
! this.synthetic = synthetic;
}
/* package */ Builder automatic(boolean automatic) {
this.automatic = automatic;
return this;
}
! /**
! * Returns the set of packages that are exported (unconditionally or
! * unconditionally).
! */
! /* package */ Set<String> exportedPackages() {
! return exports.keySet();
! }
! /**
! * Returns the set of packages that are opened (unconditionally or
! * unconditionally).
! */
! /* package */Set<String> openPackages() {
! return opens.keySet();
}
/**
* Adds a dependence on a module.
*
*** 1387,1396 ****
--- 1418,1457 ----
return this;
}
/**
* Adds a dependence on a module with the given (and possibly empty)
+ * set of modifiers. The dependence includes the version of the
+ * module that that was recorded at compile-time.
+ *
+ * @param ms
+ * The set of modifiers
+ * @param mn
+ * The module name
+ * @param compiledVersion
+ * The version of the module recorded at compile-time
+ *
+ * @return This builder
+ *
+ * @throws IllegalArgumentException
+ * If the module name is {@code null}, is not a legal Java
+ * identifier, or is equal to the module name that this builder
+ * was initialized to build
+ * @throws IllegalStateException
+ * If the dependence on the module has already been declared
+ */
+ public Builder requires(Set<Requires.Modifier> ms,
+ String mn,
+ Version compiledVersion) {
+ Objects.requireNonNull(compiledVersion);
+ if (strict)
+ mn = requireModuleName(mn);
+ return requires(new Requires(ms, mn, compiledVersion));
+ }
+
+ /**
+ * Adds a dependence on a module with the given (and possibly empty)
* set of modifiers.
*
* @param ms
* The set of modifiers
* @param mn
*** 1406,1416 ****
* If the dependence on the module has already been declared
*/
public Builder requires(Set<Requires.Modifier> ms, String mn) {
if (strict)
mn = requireModuleName(mn);
! return requires(new Requires(ms, mn));
}
/**
* Adds a dependence on a module with an empty set of modifiers.
*
--- 1467,1477 ----
* If the dependence on the module has already been declared
*/
public Builder requires(Set<Requires.Modifier> ms, String mn) {
if (strict)
mn = requireModuleName(mn);
! return requires(new Requires(ms, mn, null));
}
/**
* Adds a dependence on a module with an empty set of modifiers.
*
*** 1703,1723 ****
*/
public Builder opens(String pn) {
return opens(Collections.emptySet(), pn);
}
-
- // Used by ModuleInfo, after a packageFinder is invoked
- /* package */ Set<String> exportedAndOpenPackages() {
- if (opens.isEmpty())
- return exports.keySet();
- Set<String> result = new HashSet<>();
- result.addAll(exports.keySet());
- result.addAll(opens.keySet());
- return result;
- }
-
/**
* Adds a service dependence.
*
* @param service
* The service type
--- 1764,1773 ----
*** 1787,1797 ****
// check providers after the set has been copied.
List<String> providerNames = p.providers();
if (providerNames.isEmpty())
throw new IllegalArgumentException("Empty providers set");
providerNames.forEach(Checks::requireServiceProviderName);
-
provides.put(service, p);
return this;
}
/**
--- 1837,1846 ----
*** 1912,1922 ****
*
* @throws IllegalArgumentException
* If {@code mainClass} is null or is not a legal Java identifier
*/
public Builder mainClass(String mc) {
! mainClass = requireJavaIdentifier("main class name", mc);
return this;
}
/**
* Sets the operating system name.
--- 1961,1971 ----
*
* @throws IllegalArgumentException
* If {@code mainClass} is null or is not a legal Java identifier
*/
public Builder mainClass(String mc) {
! mainClass = requireBinaryName("main class name", mc);
return this;
}
/**
* Sets the operating system name.
*** 1970,2021 ****
throw new IllegalArgumentException("OS version is null or empty");
osVersion = version;
return this;
}
- /* package */ Builder hashes(ModuleHashes hashes) {
- this.hashes = hashes;
- return this;
- }
-
- /* package */ Builder synthetic(boolean v) {
- this.synthetic = v;
- return this;
- }
-
/**
* Builds and returns a {@code ModuleDescriptor} from its components.
*
* @return The module descriptor
*/
public ModuleDescriptor build() {
Set<Requires> requires = new HashSet<>(this.requires.values());
! Set<String> packages = new HashSet<>(exportedAndOpenPackages());
packages.addAll(concealedPackages);
Set<Exports> exports = new HashSet<>(this.exports.values());
Set<Opens> opens = new HashSet<>(this.opens.values());
Set<Provides> provides = new HashSet<>(this.provides.values());
return new ModuleDescriptor(name,
open,
automatic,
synthetic,
requires,
exports,
opens,
uses,
provides,
! version,
mainClass,
osName,
osArch,
! osVersion,
! packages,
! hashes);
}
}
/**
--- 2019,2061 ----
throw new IllegalArgumentException("OS version is null or empty");
osVersion = version;
return this;
}
/**
* Builds and returns a {@code ModuleDescriptor} from its components.
*
* @return The module descriptor
*/
public ModuleDescriptor build() {
Set<Requires> requires = new HashSet<>(this.requires.values());
! Set<String> packages = new HashSet<>();
! packages.addAll(exports.keySet());
! packages.addAll(opens.keySet());
packages.addAll(concealedPackages);
Set<Exports> exports = new HashSet<>(this.exports.values());
Set<Opens> opens = new HashSet<>(this.opens.values());
Set<Provides> provides = new HashSet<>(this.provides.values());
return new ModuleDescriptor(name,
+ version,
open,
automatic,
synthetic,
requires,
exports,
opens,
uses,
provides,
! packages,
mainClass,
osName,
osArch,
! osVersion);
}
}
/**
*** 2086,2097 ****
&& Objects.equals(version, that.version)
&& Objects.equals(mainClass, that.mainClass)
&& Objects.equals(osName, that.osName)
&& Objects.equals(osArch, that.osArch)
&& Objects.equals(osVersion, that.osVersion)
! && Objects.equals(packages, that.packages)
! && Objects.equals(hashes, that.hashes));
}
private transient int hash; // cached hash code
/**
--- 2126,2136 ----
&& Objects.equals(version, that.version)
&& Objects.equals(mainClass, that.mainClass)
&& Objects.equals(osName, that.osName)
&& Objects.equals(osArch, that.osArch)
&& Objects.equals(osVersion, that.osVersion)
! && Objects.equals(packages, that.packages));
}
private transient int hash; // cached hash code
/**
*** 2120,2130 ****
hc = hc * 43 + Objects.hashCode(mainClass);
hc = hc * 43 + Objects.hashCode(osName);
hc = hc * 43 + Objects.hashCode(osArch);
hc = hc * 43 + Objects.hashCode(osVersion);
hc = hc * 43 + Objects.hashCode(packages);
- hc = hc * 43 + Objects.hashCode(hashes);
if (hc == 0)
hc = -1;
hash = hc;
}
return hc;
--- 2159,2168 ----
*** 2143,2153 ****
sb.append("open ");
sb.append("module { name: ").append(toNameAndVersion());
if (!requires.isEmpty())
sb.append(", ").append(requires);
if (!uses.isEmpty())
! sb.append(", ").append(uses);
if (!exports.isEmpty())
sb.append(", exports: ").append(exports);
if (!opens.isEmpty())
sb.append(", opens: ").append(opens);
if (!provides.isEmpty()) {
--- 2181,2191 ----
sb.append("open ");
sb.append("module { name: ").append(toNameAndVersion());
if (!requires.isEmpty())
sb.append(", ").append(requires);
if (!uses.isEmpty())
! sb.append(", uses: ").append(uses);
if (!exports.isEmpty())
sb.append(", exports: ").append(exports);
if (!opens.isEmpty())
sb.append(", opens: ").append(opens);
if (!provides.isEmpty()) {
*** 2169,2179 ****
* @throws IllegalArgumentException
* If the module name is {@code null} or is not a legal Java
* identifier
*/
public static Builder module(String name) {
! return new Builder(name, true);
}
/**
* Instantiates a builder to build a module descriptor for an open module.
* An open module does not declare any open packages but the resulting
--- 2207,2217 ----
* @throws IllegalArgumentException
* If the module name is {@code null} or is not a legal Java
* identifier
*/
public static Builder module(String name) {
! return new Builder(name, true, false, false);
}
/**
* Instantiates a builder to build a module descriptor for an open module.
* An open module does not declare any open packages but the resulting
*** 2197,2207 ****
* @throws IllegalArgumentException
* If the module name is {@code null} or is not a legal Java
* identifier
*/
public static Builder openModule(String name) {
! return new Builder(name, true).open(true);
}
/**
* Instantiates a builder to build a module descriptor for an automatic
* module. Automatic modules receive special treatment during resolution
--- 2235,2245 ----
* @throws IllegalArgumentException
* If the module name is {@code null} or is not a legal Java
* identifier
*/
public static Builder openModule(String name) {
! return new Builder(name, true, true, false);
}
/**
* Instantiates a builder to build a module descriptor for an automatic
* module. Automatic modules receive special treatment during resolution
*** 2219,2229 ****
* identifier
*
* @see ModuleFinder#of(Path[])
*/
public static Builder automaticModule(String name) {
! return new Builder(name, true).automatic(true);
}
/**
* Reads the binary form of a module declaration from an input stream
--- 2257,2267 ----
* identifier
*
* @see ModuleFinder#of(Path[])
*/
public static Builder automaticModule(String name) {
! return new Builder(name, true, false, false).automatic(true);
}
/**
* Reads the binary form of a module declaration from an input stream
*** 2261,2271 ****
*/
public static ModuleDescriptor read(InputStream in,
Supplier<Set<String>> packageFinder)
throws IOException
{
! return ModuleInfo.read(in, requireNonNull(packageFinder));
}
/**
* Reads the binary form of a module declaration from an input stream
* as a module descriptor.
--- 2299,2309 ----
*/
public static ModuleDescriptor read(InputStream in,
Supplier<Set<String>> packageFinder)
throws IOException
{
! return ModuleInfo.read(in, requireNonNull(packageFinder)).descriptor();
}
/**
* Reads the binary form of a module declaration from an input stream
* as a module descriptor.
*** 2279,2289 ****
* If an invalid module descriptor is detected
* @throws IOException
* If an I/O error occurs reading from the input stream
*/
public static ModuleDescriptor read(InputStream in) throws IOException {
! return ModuleInfo.read(in, null);
}
/**
* Reads the binary form of a module declaration from a byte buffer
* as a module descriptor.
--- 2317,2327 ----
* If an invalid module descriptor is detected
* @throws IOException
* If an I/O error occurs reading from the input stream
*/
public static ModuleDescriptor read(InputStream in) throws IOException {
! return ModuleInfo.read(in, null).descriptor();
}
/**
* Reads the binary form of a module declaration from a byte buffer
* as a module descriptor.
*** 2318,2328 ****
* If an invalid module descriptor is detected
*/
public static ModuleDescriptor read(ByteBuffer bb,
Supplier<Set<String>> packageFinder)
{
! return ModuleInfo.read(bb, requireNonNull(packageFinder));
}
/**
* Reads the binary form of a module declaration from a byte buffer
* as a module descriptor.
--- 2356,2366 ----
* If an invalid module descriptor is detected
*/
public static ModuleDescriptor read(ByteBuffer bb,
Supplier<Set<String>> packageFinder)
{
! return ModuleInfo.read(bb, requireNonNull(packageFinder)).descriptor();
}
/**
* Reads the binary form of a module declaration from a byte buffer
* as a module descriptor.
*** 2334,2344 ****
*
* @throws InvalidModuleDescriptorException
* If an invalid module descriptor is detected
*/
public static ModuleDescriptor read(ByteBuffer bb) {
! return ModuleInfo.read(bb, null);
}
private static <K,V> Map<K,V> emptyOrUnmodifiableMap(Map<K,V> map) {
if (map.isEmpty()) {
return Collections.emptyMap();
--- 2372,2382 ----
*
* @throws InvalidModuleDescriptorException
* If an invalid module descriptor is detected
*/
public static ModuleDescriptor read(ByteBuffer bb) {
! return ModuleInfo.read(bb, null).descriptor();
}
private static <K,V> Map<K,V> emptyOrUnmodifiableMap(Map<K,V> map) {
if (map.isEmpty()) {
return Collections.emptyMap();
*** 2375,2396 ****
* private package methods in java.lang.module.
*/
jdk.internal.misc.SharedSecrets
.setJavaLangModuleAccess(new jdk.internal.misc.JavaLangModuleAccess() {
@Override
! public Builder newModuleBuilder(String mn, boolean strict) {
! return new Builder(mn, strict);
}
@Override
! public Builder newOpenModuleBuilder(String mn, boolean strict) {
! return new Builder(mn, strict).open(true);
}
@Override
! public Requires newRequires(Set<Requires.Modifier> ms, String mn) {
! return new Requires(ms, mn, true);
}
@Override
public Exports newExports(Set<Exports.Modifier> ms, String source) {
return new Exports(ms, source, Collections.emptySet(), true);
--- 2413,2442 ----
* private package methods in java.lang.module.
*/
jdk.internal.misc.SharedSecrets
.setJavaLangModuleAccess(new jdk.internal.misc.JavaLangModuleAccess() {
@Override
! public Builder newModuleBuilder(String mn,
! boolean strict,
! boolean open,
! boolean synthetic) {
! return new Builder(mn, strict, open, synthetic);
! }
!
! @Override
! public Set<String> exportedPackages(ModuleDescriptor.Builder builder) {
! return builder.exportedPackages();
}
@Override
! public Set<String> openPackages(ModuleDescriptor.Builder builder) {
! return builder.openPackages();
}
@Override
! public Requires newRequires(Set<Requires.Modifier> ms, String mn, Version v) {
! return new Requires(ms, mn, v, true);
}
@Override
public Exports newExports(Set<Exports.Modifier> ms, String source) {
return new Exports(ms, source, Collections.emptySet(), true);
*** 2431,2502 ****
return new ModuleDescriptor(md, pkgs);
}
@Override
public ModuleDescriptor newModuleDescriptor(String name,
boolean open,
boolean automatic,
boolean synthetic,
Set<Requires> requires,
Set<Exports> exports,
Set<Opens> opens,
Set<String> uses,
Set<Provides> provides,
! Version version,
String mainClass,
String osName,
String osArch,
String osVersion,
- Set<String> packages,
- ModuleHashes hashes,
int hashCode) {
return new ModuleDescriptor(name,
open,
automatic,
synthetic,
requires,
exports,
opens,
uses,
provides,
! version,
mainClass,
osName,
osArch,
osVersion,
- packages,
- hashes,
hashCode,
false);
}
@Override
- public Optional<ModuleHashes> hashes(ModuleDescriptor descriptor) {
- return descriptor.hashes();
- }
-
- @Override
public Configuration resolveRequiresAndUses(ModuleFinder finder,
Collection<String> roots,
boolean check,
PrintStream traceOutput)
{
return Configuration.resolveRequiresAndUses(finder, roots, check, traceOutput);
}
-
- @Override
- public ModuleReference newPatchedModule(ModuleDescriptor descriptor,
- URI location,
- Supplier<ModuleReader> s) {
- return new ModuleReference(descriptor, location, s, true, null);
- }
-
- @Override
- public ModuleFinder newModulePath(Runtime.Version version,
- boolean isLinkPhase,
- Path... entries) {
- return new ModulePath(version, isLinkPhase, entries);
- }
});
}
}
--- 2477,2527 ----
return new ModuleDescriptor(md, pkgs);
}
@Override
public ModuleDescriptor newModuleDescriptor(String name,
+ Version version,
boolean open,
boolean automatic,
boolean synthetic,
Set<Requires> requires,
Set<Exports> exports,
Set<Opens> opens,
Set<String> uses,
Set<Provides> provides,
! Set<String> packages,
String mainClass,
String osName,
String osArch,
String osVersion,
int hashCode) {
return new ModuleDescriptor(name,
+ version,
open,
automatic,
synthetic,
requires,
exports,
opens,
uses,
provides,
! packages,
mainClass,
osName,
osArch,
osVersion,
hashCode,
false);
}
@Override
public Configuration resolveRequiresAndUses(ModuleFinder finder,
Collection<String> roots,
boolean check,
PrintStream traceOutput)
{
return Configuration.resolveRequiresAndUses(finder, roots, check, traceOutput);
}
});
}
}
< prev index next >