Package io.github.classgraph
Class ModuleRef
java.lang.Object
io.github.classgraph.ModuleRef
- All Implemented Interfaces:
Comparable<ModuleRef>
A ModuleReference proxy, written using reflection to preserve backwards compatibility with JDK 7 and 8.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ClassLoader
The ClassLoader that loads classes in the module.private final Object
The ModuleDescriptor for the module.private final Object
The ModuleLayer for the module.private final URI
The location URI for the module (may be null).private File
A file formed from the location URI.private String
The location URI for the module, as a cached string (may be null).private final String
The name of the module.The packages in the module.private String
The raw module version, or null if none.private final Object
The ModuleReference for the module.(package private) ReflectionUtils
-
Constructor Summary
ConstructorsConstructorDescriptionModuleRef
(Object moduleReference, Object moduleLayer, ReflectionUtils reflectionUtils) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionint
boolean
Get the class loader for the module.Get the module descriptor, i.e.getLayer()
Get the module layer (of JPMS type ModuleLayer).Get the module location, i.e.Get the module location as a File, i.e.Get the module location as a string, i.e.getName()
Get the module name, i.e.Get a list of packages in the module.Get the raw version string of the module, or null if the module did not provide one.Get the module reference (of JPMS type ModuleReference).int
hashCode()
boolean
Checks if this module is a system module.open()
Open the module, returning aModuleReaderProxy
.toString()
-
Field Details
-
name
The name of the module. -
reference
The ModuleReference for the module. -
layer
The ModuleLayer for the module. -
descriptor
The ModuleDescriptor for the module. -
packages
The packages in the module. -
location
The location URI for the module (may be null). -
locationStr
The location URI for the module, as a cached string (may be null). -
locationFile
A file formed from the location URI. The file will not exist if the location URI is a "jrt:" URI. -
rawVersion
The raw module version, or null if none. -
classLoader
The ClassLoader that loads classes in the module. May be null, to represent the bootstrap classloader. -
reflectionUtils
ReflectionUtils reflectionUtils
-
-
Constructor Details
-
ModuleRef
Constructor.- Parameters:
moduleReference
- The module reference, of JPMS type ModuleReference.moduleLayer
- The module layer, of JPMS type ModuleLayerreflectionUtils
- The ReflectionUtils instance.
-
-
Method Details
-
getName
Get the module name, i.e.getReference().descriptor().name()
.- Returns:
- The module name, i.e.
getReference().descriptor().name()
. Potentially null or empty.
-
getReference
Get the module reference (of JPMS type ModuleReference).- Returns:
- The module reference (of JPMS type ModuleReference).
-
getLayer
Get the module layer (of JPMS type ModuleLayer).- Returns:
- The module layer (of JPMS type ModuleLayer).
-
getDescriptor
Get the module descriptor, i.e.getReference().descriptor()
(of JPMS type ModuleDescriptor).- Returns:
- The module descriptor, i.e.
getReference().descriptor()
(of JPMS type ModuleDescriptor).
-
getPackages
Get a list of packages in the module. (Does not include non-package directories.)- Returns:
- The list of packages in the module. (Does not include non-package directories.)
-
getLocation
Get the module location, i.e.getReference().location()
. Returns null for modules that do not have a location.- Returns:
- The module location, i.e.
getReference().location()
. Returns null for modules that do not have a location.
-
getLocationStr
Get the module location as a string, i.e.getReference().location().toString()
. Returns null for modules that do not have a location.- Returns:
- The module location as a string, i.e.
getReference().location().toString()
. Returns null for modules that do not have a location.
-
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:
- 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.
-
getRawVersion
Get the raw version string of the module, or null if the module did not provide one.- Returns:
- The raw version of the module, obtained by
ModuleReference#rawVersion().orElse(null)
.
-
isSystemModule
public boolean isSystemModule()Checks if this module is a system module.- Returns:
- true if this module is a system module.
-
getClassLoader
Get the class loader for the module.- Returns:
- The classloader for the module, i.e.
moduleLayer.findLoader(getReference().descriptor().name())
.
-
equals
-
hashCode
public int hashCode() -
toString
-
compareTo
- Specified by:
compareTo
in interfaceComparable<ModuleRef>
-
open
Open the module, returning aModuleReaderProxy
.- Returns:
- A
ModuleReaderProxy
for the module. - Throws:
IOException
- If the module cannot be opened.
-