Module java.base
Package java.lang

Class ModuleLayer.Controller

  • Enclosing class:
    ModuleLayer

    public static final classModuleLayer.ControllerextendsObject
    Controls a module layer. The static methods defined byModuleLayer to create module layers return aController that can be used to control modules in the layer.

    Unless otherwise specified, passing anull argument to a method in this class causes aNullPointerException to be thrown.

    API Note:
    Care should be taken withController objects, they should never be shared with untrusted code.
    Since:
    9
    • Method Detail

      • layer

        public ModuleLayer layer()
        Returns the layer that this object controls.
        Returns:
        the module layer
      • addReads

        public ModuleLayer.Controller addReads​(Module source,Module target)
        Updates modulesource in the layer to read moduletarget. This method is a no-op ifsource already readstarget.
        Implementation Note:
        Read edges added by this method areweak and do not preventtarget from being GC'ed whensource is strongly reachable.
        Parameters:
        source - The source module
        target - The target module to read
        Returns:
        This controller
        Throws:
        IllegalArgumentException - Ifsource is not in the module layer
        See Also:
        Module.addReads(java.lang.Module)