Top Description Fields Constructors Methods
io.github.classgraph

public Class ModuleRef

extends Object
implements Comparable<ModuleRef>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable
Imports
java.io.File, .IOException, java.net.URI, java.util.ArrayList, .List, .Set, nonapi.io.github.classgraph.reflection.ReflectionUtils, nonapi.io.github.classgraph.utils.CollectionUtils

A ModuleReference proxy, written using reflection to preserve backwards compatibility with JDK 7 and 8.

Field Summary

Modifier and TypeField and Description
private final ClassLoader
classLoader

The ClassLoader that loads classes in the module.

private final Object
descriptor

The ModuleDescriptor for the module.

private final Object
layer

The ModuleLayer for the module.

private final URI
location

The location URI for the module (may be null).

private File
locationFile

A file formed from the location URI.

private String
locationStr

The location URI for the module, as a cached string (may be null).

private final String
name

The name of the module.

private final List<String>
packages

The packages in the module.

private String
rawVersion

The raw module version, or null if none.

private final Object
reference

The ModuleReference for the module.

pack-priv ReflectionUtils

Constructor Summary

AccessConstructor and Description
public
ModuleRef(final Object
The module reference, of JPMS type ModuleReference.
moduleReference
,
final Object
The module layer, of JPMS type ModuleLayer
moduleLayer
,
final ReflectionUtils
The ReflectionUtils instance.
reflectionUtils
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public int
compareTo(final ModuleRef
the object to be compared.
o
)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.

public boolean
equals(final Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public ClassLoader

Returns:

The classloader for the module, i.e. moduleLayer.findLoader(getReference().descriptor().name()).
getClassLoader
()

Get the class loader for the module.

public Object

Returns:

The module descriptor, i.e. getReference().descriptor() (of JPMS type ModuleDescriptor).
getDescriptor
()

Get the module descriptor, i.e. getReference().descriptor() (of JPMS type ModuleDescriptor).

public Object

Returns:

The module layer (of JPMS type ModuleLayer).
getLayer
()

Get the module layer (of JPMS type ModuleLayer).

public URI

Returns:

The module location, i.e. getReference().location(). Returns null for modules that do not have a location.
getLocation
()

Get the module location, i.e. getReference().location().

public File

Returns:

The module location as a File, i.e. new File(getReference().location()). Returns null for modules that do not have a location, or for modules whole location is a "jrt:" URI.
getLocationFile
()

Get the module location as a File, i.e. new File(getReference().location()).

public String

Returns:

The module location as a string, i.e. getReference().location().toString(). Returns null for modules that do not have a location.
getLocationStr
()

Get the module location as a string, i.e. getReference().location().toString().

public String

Returns:

The module name, i.e. getReference().descriptor().name(). Potentially null or empty.
getName
()

Get the module name, i.e. getReference().descriptor().name().

public List<String>

Returns:

The list of packages in the module. (Does not include non-package directories.)
getPackages
()

Get a list of packages in the module.

public String

Returns:

The raw version of the module, obtained by ModuleReference#rawVersion().orElse(null).
getRawVersion
()

Get the raw version string of the module, or null if the module did not provide one.

public Object

Returns:

The module reference (of JPMS type ModuleReference).
getReference
()

Get the module reference (of JPMS type ModuleReference).

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean

Returns:

true if this module is a system module.
isSystemModule
()

Checks if this module is a system module.

public ModuleReaderProxy

Returns:

A ModuleReaderProxy for the module.
open
()

Open the module, returning a ModuleReaderProxy.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

classLoaderback to summary
private final ClassLoader classLoader

The ClassLoader that loads classes in the module. May be null, to represent the bootstrap classloader.

descriptorback to summary
private final Object descriptor

The ModuleDescriptor for the module.

layerback to summary
private final Object layer

The ModuleLayer for the module.

locationback to summary
private final URI location

The location URI for the module (may be null).

locationFileback to summary
private File locationFile

A file formed from the location URI. The file will not exist if the location URI is a "jrt:" URI.

locationStrback to summary
private String locationStr

The location URI for the module, as a cached string (may be null).

nameback to summary
private final String name

The name of the module.

packagesback to summary
private final List<String> packages

The packages in the module.

rawVersionback to summary
private String rawVersion

The raw module version, or null if none.

referenceback to summary
private final Object reference

The ModuleReference for the module.

reflectionUtilsback to summary
pack-priv ReflectionUtils reflectionUtils

Constructor Detail

ModuleRefback to summary
public ModuleRef(final Object moduleReference, final Object moduleLayer, final ReflectionUtils reflectionUtils)

Constructor.

Parameters
moduleReference:Object

The module reference, of JPMS type ModuleReference.

moduleLayer:Object

The module layer, of JPMS type ModuleLayer

reflectionUtils:ReflectionUtils

The ReflectionUtils instance.

Method Detail

compareToback to summary
public int compareTo(final ModuleRef o)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Parameters
o:ModuleRef

the object to be compared.

Returns:int

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Annotations
@Override
equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getClassLoaderback to summary
public ClassLoader getClassLoader()

Get the class loader for the module.

Returns:ClassLoader

The classloader for the module, i.e. moduleLayer.findLoader(getReference().descriptor().name()).

getDescriptorback to summary
public Object getDescriptor()

Get the module descriptor, i.e. getReference().descriptor() (of JPMS type ModuleDescriptor).

Returns:Object

The module descriptor, i.e. getReference().descriptor() (of JPMS type ModuleDescriptor).

getLayerback to summary
public Object getLayer()

Get the module layer (of JPMS type ModuleLayer).

Returns:Object

The module layer (of JPMS type ModuleLayer).

getLocationback to summary
public URI getLocation()

Get the module location, i.e. getReference().location(). Returns null for modules that do not have a location.

Returns:URI

The module location, i.e. getReference().location(). Returns null for modules that do not have a location.

getLocationFileback to summary
public File getLocationFile()

Get the module location as a File, i.e. new File(getReference().location()). Returns null for modules that do not have a location, or for system (or jlinked) modules, which have "jrt:" location URIs that include only the module name and not the module jar location.

Returns:File

The module location as a File, i.e. new File(getReference().location()). Returns null for modules that do not have a location, or for modules whole location is a "jrt:" URI.

getLocationStrback to summary
public String getLocationStr()

Get the module location as a string, i.e. getReference().location().toString(). Returns null for modules that do not have a location.

Returns:String

The module location as a string, i.e. getReference().location().toString(). Returns null for modules that do not have a location.

getNameback to summary
public String getName()

Get the module name, i.e. getReference().descriptor().name().

Returns:String

The module name, i.e. getReference().descriptor().name(). Potentially null or empty.

getPackagesback to summary
public List<String> getPackages()

Get a list of packages in the module. (Does not include non-package directories.)

Returns:List<String>

The list of packages in the module. (Does not include non-package directories.)

getRawVersionback to summary
public String getRawVersion()

Get the raw version string of the module, or null if the module did not provide one.

Returns:String

The raw version of the module, obtained by ModuleReference#rawVersion().orElse(null).

getReferenceback to summary
public Object getReference()

Get the module reference (of JPMS type ModuleReference).

Returns:Object

The module reference (of JPMS type ModuleReference).

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
isSystemModuleback to summary
public boolean isSystemModule()

Checks if this module is a system module.

Returns:boolean

true if this module is a system module.

openback to summary
public ModuleReaderProxy open() throws IOException

Open the module, returning a ModuleReaderProxy.

Returns:ModuleReaderProxy

A ModuleReaderProxy for the module.

Exceptions
IOException:
If the module cannot be opened.
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override