Package io.github.classgraph
Class ModuleRef
- java.lang.Object
-
- io.github.classgraph.ModuleRef
-
- All Implemented Interfaces:
Comparable<ModuleRef>
public class ModuleRef extends Object implements Comparable<ModuleRef>
A ModuleReference proxy, written using reflection to preserve backwards compatibility with JDK 7 and 8.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(ModuleRef o)
boolean
equals(Object obj)
ClassLoader
getClassLoader()
Get the class loader for the module.Object
getDescriptor()
Get the module descriptor, i.e.Object
getLayer()
Get the module layer (of JPMS type ModuleLayer).URI
getLocation()
Get the module location, i.e.File
getLocationFile()
Get the module location as a File, i.e.String
getLocationStr()
Get the module location as a string, i.e.String
getName()
Get the module name, i.e.List<String>
getPackages()
Get a list of packages in the module.String
getRawVersion()
Get the raw version string of the module, or null if the module did not provide one.Object
getReference()
Get the module reference (of JPMS type ModuleReference).int
hashCode()
boolean
isSystemModule()
Checks if this module is a system module.ModuleReaderProxy
open()
Open the module, returning aModuleReaderProxy
.String
toString()
-
-
-
Constructor Detail
-
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 Detail
-
getName
public String getName()
Get the module name, i.e.getReference().descriptor().name()
.- Returns:
- The module name, i.e.
getReference().descriptor().name()
. Potentially null or empty.
-
getReference
public Object getReference()
Get the module reference (of JPMS type ModuleReference).- Returns:
- The module reference (of JPMS type ModuleReference).
-
getLayer
public Object getLayer()
Get the module layer (of JPMS type ModuleLayer).- Returns:
- The module layer (of JPMS type ModuleLayer).
-
getDescriptor
public Object 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
public List<String> 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
public URI 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
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:
- The module location as a string, i.e.
getReference().location().toString()
. Returns null for modules that do not have a location.
-
getLocationFile
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:
- 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
public String 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
public ClassLoader getClassLoader()
Get the class loader for the module.- Returns:
- The classloader for the module, i.e.
moduleLayer.findLoader(getReference().descriptor().name())
.
-
compareTo
public int compareTo(ModuleRef o)
- Specified by:
compareTo
in interfaceComparable<ModuleRef>
-
open
public ModuleReaderProxy open() throws IOException
Open the module, returning aModuleReaderProxy
.- Returns:
- A
ModuleReaderProxy
for the module. - Throws:
IOException
- If the module cannot be opened.
-
-