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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbooleanGet 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).inthashCode()booleanChecks if this module is a system module.open()Open the module, returning aModuleReaderProxy.toString()
-
Constructor Details
-
ModuleRef
public ModuleRef(Object moduleReference, Object moduleLayer, nonapi.io.github.classgraph.reflection.ReflectionUtils reflectionUtils) 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
-
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
-
toString
-
compareTo
- Specified by:
compareToin interfaceComparable<ModuleRef>
-
open
Open the module, returning aModuleReaderProxy.- Returns:
- A
ModuleReaderProxyfor the module. - Throws:
IOException- If the module cannot be opened.
-