Class 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.
    • Constructor Detail

      • ModuleRef

        public ModuleRef​(Object moduleReference,
                         Object moduleLayer)
        Parameters:
        moduleReference - The module reference, of JPMS type ModuleReference.
        moduleLayer - The module layer, of JPMS type ModuleLayer
    • 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.
      • 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()
        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()).
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object