Class JavaModule.Dispatcher.Enabled

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.reflect.Method canRead
      The java.lang.Module#canRead(Module) method.
      private java.lang.reflect.Method getClassLoader
      The java.lang.Module#getClassLoader() method.
      private java.lang.reflect.Method getModule
      The java.lang.Class#getModule() method.
      private java.lang.reflect.Method getName
      The java.lang.Module#getName() method.
      private java.lang.reflect.Method getResourceAsStream
      The java.lang.Module#getResourceAsStream(String) method.
      private java.lang.reflect.Method isExported
      The java.lang.Module#isExported(String,Module) method.
      private java.lang.reflect.Method isNamed
      The java.lang.Module#isNamed() method.
      private java.lang.reflect.Method isOpened
      The java.lang.Module#isOpened(String,Module) method.
      private static java.lang.Object[] NO_ARGUMENTS
      An empty array that can be used to indicate no arguments to avoid an allocation on a reflective call.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Enabled​(java.lang.reflect.Method getModule, java.lang.reflect.Method getClassLoader, java.lang.reflect.Method isNamed, java.lang.reflect.Method getName, java.lang.reflect.Method getResourceAsStream, java.lang.reflect.Method isExported, java.lang.reflect.Method isOpened, java.lang.reflect.Method canRead)
      Creates an enabled dispatcher.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canRead​(java.lang.Object source, java.lang.Object target)
      Checks if the source module can read the target module.
      java.lang.ClassLoader getClassLoader​(java.lang.Object module)
      Returns the module's class loader.
      java.lang.String getName​(java.lang.Object module)
      Returns the module's name.
      java.io.InputStream getResourceAsStream​(java.lang.Object module, java.lang.String name)
      Returns a resource stream for this module for a resource of the given name or null if such a resource does not exist.
      boolean isAlive()
      Checks if this dispatcher is alive, i.e.
      boolean isExported​(java.lang.Object source, java.lang.Object target, java.lang.String aPackage)
      Returns true if the source module exports the supplied package to the target module.
      boolean isNamed​(java.lang.Object module)
      Returns true if the supplied module is named.
      boolean isOpened​(java.lang.Object source, java.lang.Object target, java.lang.String aPackage)
      Returns true if the source module opens the supplied package to the target module.
      JavaModule moduleOf​(java.lang.Class<?> type)
      Extracts the Java Module for the provided class or returns null if the current VM does not support modules.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NO_ARGUMENTS

        private static final java.lang.Object[] NO_ARGUMENTS
        An empty array that can be used to indicate no arguments to avoid an allocation on a reflective call.
      • getModule

        private final java.lang.reflect.Method getModule
        The java.lang.Class#getModule() method.
      • getClassLoader

        private final java.lang.reflect.Method getClassLoader
        The java.lang.Module#getClassLoader() method.
      • isNamed

        private final java.lang.reflect.Method isNamed
        The java.lang.Module#isNamed() method.
      • getName

        private final java.lang.reflect.Method getName
        The java.lang.Module#getName() method.
      • getResourceAsStream

        private final java.lang.reflect.Method getResourceAsStream
        The java.lang.Module#getResourceAsStream(String) method.
      • isExported

        private final java.lang.reflect.Method isExported
        The java.lang.Module#isExported(String,Module) method.
      • isOpened

        private final java.lang.reflect.Method isOpened
        The java.lang.Module#isOpened(String,Module) method.
      • canRead

        private final java.lang.reflect.Method canRead
        The java.lang.Module#canRead(Module) method.
    • Constructor Detail

      • Enabled

        protected Enabled​(java.lang.reflect.Method getModule,
                          java.lang.reflect.Method getClassLoader,
                          java.lang.reflect.Method isNamed,
                          java.lang.reflect.Method getName,
                          java.lang.reflect.Method getResourceAsStream,
                          java.lang.reflect.Method isExported,
                          java.lang.reflect.Method isOpened,
                          java.lang.reflect.Method canRead)
        Creates an enabled dispatcher.
        Parameters:
        getModule - The java.lang.Class#getModule() method.
        getClassLoader - The java.lang.Module#getClassLoader() method.
        isNamed - The java.lang.Module#isNamed() method.
        getName - The java.lang.Module#getName() method.
        getResourceAsStream - The java.lang.Module#getResourceAsStream(String) method.
        isExported - The java.lang.Module#isExported(String,Module) method.
        isOpened - The java.lang.Module#isOpened(String,Module) method.
        canRead - The java.lang.Module#canRead(Module) method.
    • Method Detail

      • isAlive

        public boolean isAlive()
        Checks if this dispatcher is alive, i.e. supports modules.
        Specified by:
        isAlive in interface JavaModule.Dispatcher
        Returns:
        true if modules are supported on the current VM.
      • moduleOf

        public JavaModule moduleOf​(java.lang.Class<?> type)
        Extracts the Java Module for the provided class or returns null if the current VM does not support modules.
        Specified by:
        moduleOf in interface JavaModule.Dispatcher
        Parameters:
        type - The type for which to extract the module.
        Returns:
        The class's Module or null if the current VM does not support modules.
      • getResourceAsStream

        public java.io.InputStream getResourceAsStream​(java.lang.Object module,
                                                       java.lang.String name)
        Returns a resource stream for this module for a resource of the given name or null if such a resource does not exist.
        Specified by:
        getResourceAsStream in interface JavaModule.Dispatcher
        Parameters:
        module - The java.lang.Module instance to apply this method upon.
        name - The name of the resource.
        Returns:
        An input stream for the resource or null if it does not exist.
      • getClassLoader

        public java.lang.ClassLoader getClassLoader​(java.lang.Object module)
        Returns the module's class loader.
        Specified by:
        getClassLoader in interface JavaModule.Dispatcher
        Parameters:
        module - The java.lang.Module
        Returns:
        The module's class loader.
      • isNamed

        public boolean isNamed​(java.lang.Object module)
        Returns true if the supplied module is named.
        Specified by:
        isNamed in interface JavaModule.Dispatcher
        Parameters:
        module - The java.lang.Module to check for the existence of a name.
        Returns:
        true if the supplied module is named.
      • getName

        public java.lang.String getName​(java.lang.Object module)
        Returns the module's name.
        Specified by:
        getName in interface JavaModule.Dispatcher
        Parameters:
        module - The java.lang.Module to check for its name.
        Returns:
        The module's (implicit or explicit) name.
      • isExported

        public boolean isExported​(java.lang.Object source,
                                  java.lang.Object target,
                                  java.lang.String aPackage)
        Returns true if the source module exports the supplied package to the target module.
        Specified by:
        isExported in interface JavaModule.Dispatcher
        Parameters:
        source - The source module.
        target - The target module.
        aPackage - The name of the package to check.
        Returns:
        true if the source module exports the supplied package to the target module.
      • isOpened

        public boolean isOpened​(java.lang.Object source,
                                java.lang.Object target,
                                java.lang.String aPackage)
        Returns true if the source module opens the supplied package to the target module.
        Specified by:
        isOpened in interface JavaModule.Dispatcher
        Parameters:
        source - The source module.
        target - The target module.
        aPackage - The name of the package to check.
        Returns:
        true if the source module opens the supplied package to the target module.
      • canRead

        public boolean canRead​(java.lang.Object source,
                               java.lang.Object target)
        Checks if the source module can read the target module.
        Specified by:
        canRead in interface JavaModule.Dispatcher
        Parameters:
        source - The source module.
        target - The target module.
        Returns:
        true if the source module can read the target module.