Class ModuleRef
- java.lang.Object
-
- io.github.lukehutch.fastclasspathscanner.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 Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(ModuleRef o)
boolean
equals(Object obj)
static List<ModuleRef>
findModuleRefs(Class<?>[] callStack)
Get all visible ModuleReferences in all layers, given an array of stack frameClass<?>
references.ClassLoader
getClassLoader()
Returns the classloader for the module, i.e.Object
getDescriptor()
Returns the module descriptor, i.e.Object
getLayer()
Returns the module layer (of JPMS type ModuleLayer).URI
getLocation()
Returns the module location, i.e.File
getLocationFile()
Returns the module location as a File, i.e.String
getLocationStr()
Returns the module location as a string, i.e.String
getName()
Returns the module name, i.e.List<String>
getPackages()
Returns the list of packages in the module.Object
getReference()
Returns the module reference (of JPMS type ModuleReference).int
hashCode()
boolean
isSystemModule()
Returns true if this module's location is a non-"file:/" ("jrt:/") URI, or if it has no location URI, or if it uses the (null) bootstrap ClassLoader, or if the module name starts with a system prefix ("java.", "jre.", etc.).ModuleReaderProxy
open()
Open the module, returning aModuleReaderProxy
.String
toString()
-
-
-
Method Detail
-
getName
public String getName()
Returns the module name, i.e.getReference().descriptor().name()
.
-
getReference
public Object getReference()
Returns the module reference (of JPMS type ModuleReference).
-
getLayer
public Object getLayer()
Returns the module layer (of JPMS type ModuleLayer).
-
getDescriptor
public Object getDescriptor()
Returns the module descriptor, i.e.getReference().descriptor()
(of JPMS type ModuleDescriptor).
-
getPackages
public List<String> getPackages()
Returns the list of packages in the module. (Does not include non-package directories.)
-
getLocation
public URI getLocation()
Returns the module location, i.e.getReference().location()
. Returns null for modules that do not have a location.
-
getLocationStr
public String getLocationStr()
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()
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 system ("jrt:/") modules.
-
isSystemModule
public boolean isSystemModule()
Returns true if this module's location is a non-"file:/" ("jrt:/") URI, or if it has no location URI, or if it uses the (null) bootstrap ClassLoader, or if the module name starts with a system prefix ("java.", "jre.", etc.).
-
getClassLoader
public ClassLoader getClassLoader()
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
.- Throws:
IOException
-
-