Comparable<ModuleDescriptor>
public class ModuleDescriptor extends Object implements Comparable<ModuleDescriptor>
A ModuleDescriptor
is typically created from the binary form
of a module declaration. The associated ModuleDescriptor.Builder
class can also be used to create a ModuleDescriptor
from its
components.
ModuleDescriptor
objects are immutable and safe for use by
multiple concurrent threads.
Module
Modifier and Type | Class | Description |
---|---|---|
static class |
ModuleDescriptor.Builder |
A builder used for building
ModuleDescriptor objects. |
static class |
ModuleDescriptor.Exports |
A module export, may be qualified or unqualified.
|
static class |
ModuleDescriptor.Provides |
A service that a module provides one or more implementations of.
|
static class |
ModuleDescriptor.Requires |
A dependence upon a module
|
static class |
ModuleDescriptor.Version |
A module's version string.
|
Modifier and Type | Method | Description |
---|---|---|
int |
compareTo(ModuleDescriptor that) |
Compares this module descriptor to another.
|
Set<String> |
conceals() |
Returns the names of the packages defined in, but not exported by, this
module.
|
boolean |
equals(Object ob) |
Tests this module descriptor for equality with the given object.
|
Set<ModuleDescriptor.Exports> |
exports() |
The module exports.
|
int |
hashCode() |
Computes a hash code for this module descriptor.
|
boolean |
isAutomatic() |
Returns
true if this is an automatic module. |
boolean |
isSynthetic() |
Returns
true if this module descriptor was not generated
from an explicit module declaration (module-info.java )
or an implicit module declaration (an automatic
module). |
Optional<String> |
mainClass() |
Returns the module's main class.
|
String |
name() |
The module name.
|
Optional<String> |
osArch() |
Returns the operating system architecture if this module is operating
system architecture specific.
|
Optional<String> |
osName() |
Returns the operating system name if this module is operating system
specific.
|
Optional<String> |
osVersion() |
Returns the operating system version if this module is operating
system version specific.
|
Set<String> |
packages() |
Returns the names of all the packages defined in this module, whether
exported or concealed.
|
Map<String,ModuleDescriptor.Provides> |
provides() |
The services that this module provides.
|
static ModuleDescriptor |
read(InputStream in) |
Reads the binary form of a module declaration from an input stream
as a module descriptor.
|
static ModuleDescriptor |
read(InputStream in,
Supplier<Set<String>> packageFinder) |
Reads the binary form of a module declaration from an input stream
as a module descriptor.
|
static ModuleDescriptor |
read(ByteBuffer bb) |
Reads the binary form of a module declaration from a byte buffer
as a module descriptor.
|
static ModuleDescriptor |
read(ByteBuffer bb,
Supplier<Set<String>> packageFinder) |
Reads the binary form of a module declaration from a byte buffer
as a module descriptor.
|
Set<ModuleDescriptor.Requires> |
requires() |
The dependences of this module.
|
String |
toNameAndVersion() |
Returns a string containing this module's name and, if present, its
version.
|
String |
toString() |
Returns a string describing this descriptor.
|
Set<String> |
uses() |
The service dependences of this module.
|
Optional<ModuleDescriptor.Version> |
version() |
Returns this module's version.
|
public String name()
The module name.
public boolean isAutomatic()
Returns true
if this is an automatic module.
An automatic module is defined implicitly rather than explicitly
and therefore does not have a module declaration. JAR files located on
the application module path, or by the ModuleFinder
returned by
ModuleFinder.of
, are
treated as automatic modules if they do have not have a module
declaration.
true
if this is an automatic modulepublic boolean isSynthetic()
Returns true
if this module descriptor was not generated
from an explicit module declaration (module-info.java
)
or an implicit module declaration (an automatic
module).
true
if this module descriptor was not generated by
an explicit or implicit module declarationSynthetic
Attributepublic Set<ModuleDescriptor.Requires> requires()
The dependences of this module.
ModuleDescriptor.Requires
objectspublic Set<String> uses()
The service dependences of this module.
public Map<String,ModuleDescriptor.Provides> provides()
The services that this module provides.
public Set<ModuleDescriptor.Exports> exports()
The module exports.
public Optional<ModuleDescriptor.Version> version()
public String toNameAndVersion()
public Optional<String> mainClass()
public Optional<String> osName()
Optional
if this module is not operating system specificpublic Optional<String> osArch()
Optional
if this module is not operating system architecture specificpublic Optional<String> osVersion()
Optional
if this module is not operating system version specificpublic Set<String> conceals()
public Set<String> packages()
public int compareTo(ModuleDescriptor that)
Two ModuleDescriptor
objects are compared by comparing their
module name lexicographically. Where the module names are equal then
the versions, if present, are compared.
compareTo
in interface Comparable<ModuleDescriptor>
that
- The object to which this module descriptor is to be comparedpublic boolean equals(Object ob)
If the given object is not a ModuleDescriptor
then this
method returns false
. Two module descriptors are equal if each
of their corresponding components is equal.
This method satisfies the general contract of the Object.equals
method.
equals
in class Object
ob
- the object to which this object is to be comparedtrue
if, and only if, the given object is a module
descriptor that is equal to this module descriptorObject.hashCode()
,
HashMap
public int hashCode()
The hash code is based upon the components of the module descriptor,
and satisfies the general contract of the Object.hashCode
method.
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public String toString()
public static ModuleDescriptor read(InputStream in, Supplier<Set<String>> packageFinder) throws IOException
If the descriptor encoded in the input stream does not indicate a
set of concealed packages then the packageFinder
will be
invoked. The packages it returns, except for those indicated as
exported in the encoded descriptor, will be considered to be concealed.
If the packageFinder
throws an UncheckedIOException
then
IOException
cause will be re-thrown.
If there are bytes following the module descriptor then it is
implementation specific as to whether those bytes are read, ignored,
or reported as an InvalidModuleDescriptorException
. If this
method fails with an InvalidModuleDescriptorException
or
IOException
then it may do so after some, but not all, bytes have
been read from the input stream. It is strongly recommended that the
stream be promptly closed and discarded if an exception occurs.
packageFinder
parameter is for use when reading
module descriptors from legacy module-artifact formats that do not
record the set of concealed packages in the descriptor itself.in
- The input streampackageFinder
- A supplier that can produce a set of package namesInvalidModuleDescriptorException
- If an invalid module descriptor is detectedIOException
- If an I/O error occurs reading from the input stream or
UncheckedIOException
is thrown by the package finderpublic static ModuleDescriptor read(InputStream in) throws IOException
in
- The input streamInvalidModuleDescriptorException
- If an invalid module descriptor is detectedIOException
- If an I/O error occurs reading from the input streampublic static ModuleDescriptor read(ByteBuffer bb, Supplier<Set<String>> packageFinder)
If the descriptor encoded in the byte buffer does not indicate a
set of concealed packages then the packageFinder
will be
invoked. The packages it returns, except for those indicated as
exported in the encoded descriptor, will be considered to be
concealed.
The module descriptor is read from the buffer stating at index
p
, where p
is the buffer's position
when this method is invoked. Upon return the buffer's position
will be equal to p + n
where n
is the number of bytes
read from the buffer.
If there are bytes following the module descriptor then it is
implementation specific as to whether those bytes are read, ignored,
or reported as an InvalidModuleDescriptorException
. If this
method fails with an InvalidModuleDescriptorException
then it
may do so after some, but not all, bytes have been read.
packageFinder
parameter is for use when reading
module descriptors from legacy module-artifact formats that do not
record the set of concealed packages in the descriptor itself.bb
- The byte bufferpackageFinder
- A supplier that can produce a set of package namesInvalidModuleDescriptorException
- If an invalid module descriptor is detectedpublic static ModuleDescriptor read(ByteBuffer bb)
bb
- The byte bufferInvalidModuleDescriptorException
- If an invalid module descriptor is detected Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2016, Oracle and/or its affiliates. All rights reserved.
DRAFT 9-internal+0-2016-10-04-161205.jjg.dev.8159855.tools-spi