Top Description Inners Fields Constructors Methods
java.lang

public final Class ModuleLayer

extends Object
Class Inheritance
Imports
java.lang.module.Configuration, .ModuleDescriptor, .ResolvedModule, java.util.ArrayDeque, .ArrayList, .Collections, .Deque, .HashMap, .HashSet, .List, .Map, .Objects, .Optional, .Set, java.util.concurrent.CopyOnWriteArrayList, java.util.function.Function, java.util.stream.Collectors, .Stream, jdk.internal.javac.Restricted, jdk.internal.loader.ClassLoaderValue, .Loader, .LoaderPool, jdk.internal.module.ServicesCatalog, jdk.internal.misc.CDS, jdk.internal.reflect.CallerSensitive, .Reflection, jdk.internal.vm.annotation.Stable

A layer of modules in the Java virtual machine.

A layer is created from a graph of modules in a Configuration and a function that maps each module to a ClassLoader. Creating a layer informs the Java virtual machine about the classes that may be loaded from the modules so that the Java virtual machine knows which module that each class is a member of.

Creating a layer creates a Module object for each ResolvedModule in the configuration. For each resolved module that is read, the Module reads the corresponding run-time Module, which may be in the same layer or a parent layer.

The defineModulesWithOneLoader and defineModulesWithManyLoaders methods provide convenient ways to create a module layer where all modules are mapped to a single class loader or where each module is mapped to its own class loader. The defineModules method is for more advanced cases where modules are mapped to custom class loaders by means of a function specified to the method. Each of these methods has an instance and static variant. The instance methods create a layer with the receiver as the parent layer. The static methods are for more advanced cases where there can be more than one parent layer or where a Controller is needed to control modules in the layer

A Java virtual machine has at least one non-empty layer, the boot layer, that is created when the Java virtual machine is started. The boot layer contains module java.base and is the only layer in the Java virtual machine with a module named "java.base". The modules in the boot layer are mapped to the bootstrap class loader and other class loaders that are built-in into the Java virtual machine. The boot layer will often be the parent when creating additional layers.

Each Module in a layer is created so that it exports and opens the packages described by its ModuleDescriptor. Qualified exports (where a package is exported to a set of target modules rather than all modules) are reified when creating the layer as follows:

Qualified opens are handled in same way as qualified exports.

As when creating a Configuration, automatic modules receive special treatment when creating a layer. An automatic module is created in the Java virtual machine as a Module that reads every unnamed Module in the Java virtual machine.

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

Example

This example creates a configuration by resolving a module named "myapp" with the configuration for the boot layer as the parent. It then creates a new layer with the modules in this configuration. All modules are defined to the same class loader.

ModuleFinder finder = ModuleFinder.of(dir1, dir2, dir3); ModuleLayer parent = ModuleLayer.boot(); Configuration cf = parent.configuration() .resolve(finder, ModuleFinder.of(), Set.of("myapp")); ClassLoader scl = ClassLoader.getSystemClassLoader(); ModuleLayer layer = parent.defineModulesWithOneLoader(cf, scl); Class<?> c = layer.findLoader("myapp").loadClass("app.Main");
ModuleFinder finder = ModuleFinder.of(dir1, dir2, dir3);
ModuleLayer parent = ModuleLayer.boot();
Configuration cf = parent.configuration()
                         .resolve(finder, ModuleFinder.of(), Set.of("myapp"));
ClassLoader scl = ClassLoader.getSystemClassLoader();
ModuleLayer layer = parent.defineModulesWithOneLoader(cf, scl);
Class<?> c = layer.findLoader("myapp").loadClass("app.Main");
Since
9
See Also
Module#getLayer()

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ModuleLayer.Controller

Controls a module layer.

Field Summary

Modifier and TypeField and Description
private volatile List<ModuleLayer>
private final Configuration
private static final ClassLoaderValue<List<ModuleLayer>>
private static ModuleLayer
private volatile Set<Module>
private final Map<String, Module>
private final List<ModuleLayer>
private volatile ServicesCatalog

Constructor Summary

AccessConstructor and Description
private
ModuleLayer(Configuration cf, List<ModuleLayer> parents, Function<String, ClassLoader> clf)

Creates a new module layer from the modules in the given configuration.

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean

Returns:

true iff the module is present in this layer, false otherwise
addEnableNativeAccess
(String
the name of the module for which the native access should be enabled
name
)

Updates the module with the given name in this layer to allow access to restricted methods.

pack-priv void
bindToLoader(ClassLoader loader)

Record that this layer has at least one module defined to the given class loader.

public static ModuleLayer

Returns:

The boot layer
boot
()

Returns the boot layer.

private static void
checkConfiguration(Configuration cf, List<ModuleLayer> parentLayers)

Checks that the parent configurations match the configuration of the parent layers.

private static void
checkForDuplicatePkgs(Configuration cf, Function<String, ClassLoader> clf)

Checks a configuration and the module-to-loader mapping to ensure that no two modules mapped to the same class loader have the same package.

public Configuration

Returns:

The configuration for this layer
configuration
()

Returns the configuration for this layer.

public ModuleLayer

Returns:

The newly created layer
defineModules
(Configuration
The configuration for the layer
cf
,
Function<String, ClassLoader>
The function to map a module name to a class loader
clf
)

Creates a new module layer, with this layer as its parent, by defining the modules in the given Configuration to the Java virtual machine.

public static ModuleLayer.Controller

Returns:

A controller that controls the newly created layer
defineModules
(Configuration
The configuration for the layer
cf
,
List<ModuleLayer>
The list of parent layers in search order
parentLayers
,
Function<String, ClassLoader>
The function to map a module name to a class loader
clf
)

Creates a new module layer by defining the modules in the given Configuration to the Java virtual machine.

public ModuleLayer

Returns:

The newly created layer
defineModulesWithManyLoaders
(Configuration
The configuration for the layer
cf
,
ClassLoader
The parent class loader for each of the class loaders created by this method; may be null for the bootstrap class loader
parentLoader
)

Creates a new module layer, with this layer as its parent, by defining the modules in the given Configuration to the Java virtual machine.

public static ModuleLayer.Controller

Returns:

A controller that controls the newly created layer
defineModulesWithManyLoaders
(Configuration
The configuration for the layer
cf
,
List<ModuleLayer>
The list of parent layers in search order
parentLayers
,
ClassLoader
The parent class loader for each of the class loaders created by this method; may be null for the bootstrap class loader
parentLoader
)

Creates a new module layer by defining the modules in the given Configuration to the Java virtual machine.

public ModuleLayer

Returns:

The newly created layer
defineModulesWithOneLoader
(Configuration
The configuration for the layer
cf
,
ClassLoader
The parent class loader for the class loader created by this method; may be null for the bootstrap class loader
parentLoader
)

Creates a new module layer, with this layer as its parent, by defining the modules in the given Configuration to the Java virtual machine.

public static ModuleLayer.Controller

Returns:

A controller that controls the newly created layer
defineModulesWithOneLoader
(Configuration
The configuration for the layer
cf
,
List<ModuleLayer>
The list of parent layers in search order
parentLayers
,
ClassLoader
The parent class loader for the class loader created by this method; may be null for the bootstrap class loader
parentLoader
)

Creates a new module layer by defining the modules in the given Configuration to the Java virtual machine.

public static ModuleLayer

Returns:

The empty layer
empty
()

Returns the empty layer.

private static LayerInstantiationException
fail(String fmt, Object... args)

Creates a LayerInstantiationException with the message formatted from the given format string and arguments.

public ClassLoader

Returns:

The ClassLoader that the module is defined to
findLoader
(String
The name of the module to find
name
)

Returns the ClassLoader for the module with the given name.

public Optional<Module>

Returns:

The module with the given name or an empty Optional if there isn't a module with this name in this layer or any parent layer
findModule
(String
The name of the module to find
name
)

Returns the module with the given name in this layer, or if not in this layer, the parent layers.

pack-priv ServicesCatalog
getServicesCatalog()

Returns the ServicesCatalog for this Layer, creating it if not already created.

pack-priv Stream<ModuleLayer>
layers()

Returns an ordered stream of layers.

pack-priv static Stream<ModuleLayer>
layers(ClassLoader loader)

Returns a stream of the layers that have at least one module defined to the given class loader.

public Set<Module>

Returns:

A possibly-empty unmodifiable set of the modules in this layer
modules
()

Returns an unmodifiable set of the modules in this layer.

public List<ModuleLayer>

Returns:

A possibly-empty unmodifiable list of this layer's parents
parents
()

Returns an unmodifiable list of this layer's parents, in search order.

public String

Returns:

A possibly empty string describing this module layer
toString
()

Overrides java.lang.Object.toString.

Returns a string describing this module layer.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

allLayersback to summary
private volatile List<ModuleLayer> allLayers
cfback to summary
private final Configuration cf
CLVback to summary
private static final ClassLoaderValue<List<ModuleLayer>> CLV
EMPTY_LAYERback to summary
private static ModuleLayer EMPTY_LAYER
Annotations
@Stable
modulesback to summary
private volatile Set<Module> modules
nameToModuleback to summary
private final Map<String, Module> nameToModule
parentsback to summary
private final List<ModuleLayer> parents
servicesCatalogback to summary
private volatile ServicesCatalog servicesCatalog

Constructor Detail

ModuleLayerback to summary
private ModuleLayer(Configuration cf, List<ModuleLayer> parents, Function<String, ClassLoader> clf)

Creates a new module layer from the modules in the given configuration.

Method Detail

addEnableNativeAccessback to summary
pack-priv boolean addEnableNativeAccess(String name)

Updates the module with the given name in this layer to allow access to restricted methods.

Parameters
name:String

the name of the module for which the native access should be enabled

Returns:boolean

true iff the module is present in this layer, false otherwise

bindToLoaderback to summary
pack-priv void bindToLoader(ClassLoader loader)

Record that this layer has at least one module defined to the given class loader.

bootback to summary
public static ModuleLayer boot()

Returns the boot layer. The boot layer contains at least one module, java.base. Its parent is the empty layer.

API Note

This method returns null during startup and before the boot layer is fully initialized.

Returns:ModuleLayer

The boot layer

checkConfigurationback to summary
private static void checkConfiguration(Configuration cf, List<ModuleLayer> parentLayers)

Checks that the parent configurations match the configuration of the parent layers.

checkForDuplicatePkgsback to summary
private static void checkForDuplicatePkgs(Configuration cf, Function<String, ClassLoader> clf)

Checks a configuration and the module-to-loader mapping to ensure that no two modules mapped to the same class loader have the same package. It also checks that no two automatic modules have the same package.

configurationback to summary
public Configuration configuration()

Returns the configuration for this layer.

Returns:Configuration

The configuration for this layer

defineModulesback to summary
public ModuleLayer defineModules(Configuration cf, Function<String, ClassLoader> clf)

Creates a new module layer, with this layer as its parent, by defining the modules in the given Configuration to the Java virtual machine. Each module is mapped, by name, to its class loader by means of the given function. This method works exactly as specified by the static defineModules method when invoked with this layer as the parent. In other words, if this layer is thisLayer then this method is equivalent to invoking:

 ModuleLayer.defineModules(cf, List.of(thisLayer), clf).layer();
Parameters
cf:Configuration

The configuration for the layer

clf:Function<String, ClassLoader>

The function to map a module name to a class loader

Returns:ModuleLayer

The newly created layer

Exceptions
IllegalArgumentException:
If the given configuration has more than one parent or the parent of the configuration is not the configuration for this layer
LayerInstantiationException:
If the layer cannot be created for any of the reasons specified by the static defineModules method
defineModulesback to summary
public static ModuleLayer.Controller defineModules(Configuration cf, List<ModuleLayer> parentLayers, Function<String, ClassLoader> clf)

Creates a new module layer by defining the modules in the given Configuration to the Java virtual machine. The given function maps each module in the configuration, by name, to a class loader. Creating the layer informs the Java virtual machine about the classes that may be loaded so that the Java virtual machine knows which module that each class is a member of.

The class loader delegation implemented by the class loaders must respect module readability. The class loaders should be parallel-capable so as to avoid deadlocks during class loading. In addition, the entity creating a new layer with this method should arrange that the class loaders be ready to load from these modules before there are any attempts to load classes or resources.

Creating a layer can fail for the following reasons:

  • Two or more modules with the same package are mapped to the same class loader.

  • A module is mapped to a class loader that already has a module of the same name defined to it.

  • A module is mapped to a class loader that has already defined types in any of the packages in the module.

In addition, a layer cannot be created if the configuration contains a module named "java.base", a configuration contains a module with a package named "java" or a package name starting with "java.", or the function to map a module name to a class loader returns null or the platform class loader.

If the function to map a module name to class loader throws an error or runtime exception then it is propagated to the caller of this method.

API Note

It is implementation specific as to whether creating a layer with this method is an atomic operation or not. Consequently it is possible for this method to fail with some modules, but not all, defined to the Java virtual machine.

Parameters
cf:Configuration

The configuration for the layer

parentLayers:List<ModuleLayer>

The list of parent layers in search order

clf:Function<String, ClassLoader>

The function to map a module name to a class loader

Returns:ModuleLayer.Controller

A controller that controls the newly created layer

Exceptions
IllegalArgumentException:
If the parent(s) of the given configuration do not match the configuration of the parent layers, including order
LayerInstantiationException:
If creating the layer fails for any of the reasons listed above
defineModulesWithManyLoadersback to summary
public ModuleLayer defineModulesWithManyLoaders(Configuration cf, ClassLoader parentLoader)

Creates a new module layer, with this layer as its parent, by defining the modules in the given Configuration to the Java virtual machine. Each module is defined to its own ClassLoader created by this method. The parent of each class loader is the given parent class loader. This method works exactly as specified by the static defineModulesWithManyLoaders method when invoked with this layer as the parent. In other words, if this layer is thisLayer then this method is equivalent to invoking:

 ModuleLayer.defineModulesWithManyLoaders(cf, List.of(thisLayer), parentLoader).layer();
Parameters
cf:Configuration

The configuration for the layer

parentLoader:ClassLoader

The parent class loader for each of the class loaders created by this method; may be null for the bootstrap class loader

Returns:ModuleLayer

The newly created layer

Exceptions
IllegalArgumentException:
If the given configuration has more than one parent or the parent of the configuration is not the configuration for this layer
LayerInstantiationException:
If the layer cannot be created for any of the reasons specified by the static defineModulesWithManyLoaders method
See Also
findLoader
defineModulesWithManyLoadersback to summary
public static ModuleLayer.Controller defineModulesWithManyLoaders(Configuration cf, List<ModuleLayer> parentLayers, ClassLoader parentLoader)

Creates a new module layer by defining the modules in the given Configuration to the Java virtual machine. Each module is defined to its own ClassLoader created by this method. The parent of each class loader is the given parent class loader.

The class loaders created by this method implement direct delegation when loading classes from modules. If the loadClass method is invoked to load a class then it uses the package name of the class to map it to a module. The package may be in the module defined to the class loader. The package may be exported by another module in this layer to the module defined to the class loader. It may be in a package exported by a module in a parent layer. The class loader delegates to the class loader of the module, throwing ClassNotFoundException if not found by that class loader. When loadClass is invoked to load a class that does not map to a module then it delegates to the parent class loader.

The class loaders created by this method locate resources (getResource, getResources, and other resource methods) in the module defined to the class loader before searching the parent class loader.

Parameters
cf:Configuration

The configuration for the layer

parentLayers:List<ModuleLayer>

The list of parent layers in search order

parentLoader:ClassLoader

The parent class loader for each of the class loaders created by this method; may be null for the bootstrap class loader

Returns:ModuleLayer.Controller

A controller that controls the newly created layer

Exceptions
IllegalArgumentException:
If the parent(s) of the given configuration do not match the configuration of the parent layers, including order
LayerInstantiationException:
If the layer cannot be created because the configuration contains a module named "java.base" or a module contains a package named "java" or a package with a name starting with "java."
See Also
findLoader
defineModulesWithOneLoaderback to summary
public ModuleLayer defineModulesWithOneLoader(Configuration cf, ClassLoader parentLoader)

Creates a new module layer, with this layer as its parent, by defining the modules in the given Configuration to the Java virtual machine. This method creates one class loader and defines all modules to that class loader. The parent of each class loader is the given parent class loader. This method works exactly as specified by the static defineModulesWithOneLoader method when invoked with this layer as the parent. In other words, if this layer is thisLayer then this method is equivalent to invoking:

 ModuleLayer.defineModulesWithOneLoader(cf, List.of(thisLayer), parentLoader).layer();
Parameters
cf:Configuration

The configuration for the layer

parentLoader:ClassLoader

The parent class loader for the class loader created by this method; may be null for the bootstrap class loader

Returns:ModuleLayer

The newly created layer

Exceptions
IllegalArgumentException:
If the given configuration has more than one parent or the parent of the configuration is not the configuration for this layer
LayerInstantiationException:
If the layer cannot be created for any of the reasons specified by the static defineModulesWithOneLoader method
See Also
findLoader
defineModulesWithOneLoaderback to summary
public static ModuleLayer.Controller defineModulesWithOneLoader(Configuration cf, List<ModuleLayer> parentLayers, ClassLoader parentLoader)

Creates a new module layer by defining the modules in the given Configuration to the Java virtual machine. This method creates one class loader and defines all modules to that class loader.

The class loader created by this method implements direct delegation when loading classes from modules. If the loadClass method is invoked to load a class then it uses the package name of the class to map it to a module. This may be a module in this layer and hence defined to the same class loader. It may be a package in a module in a parent layer that is exported to one or more of the modules in this layer. The class loader delegates to the class loader of the module, throwing ClassNotFoundException if not found by that class loader. When loadClass is invoked to load classes that do not map to a module then it delegates to the parent class loader.

The class loader created by this method locates resources (getResource, getResources, and other resource methods) in all modules in the layer before searching the parent class loader.

Attempting to create a layer with all modules defined to the same class loader can fail for the following reasons:

  • Overlapping packages: Two or more modules in the configuration have the same package.

  • Split delegation: The resulting class loader would need to delegate to more than one class loader in order to load classes in a specific package.

In addition, a layer cannot be created if the configuration contains a module named "java.base", or a module contains a package named "java" or a package with a name starting with "java.".

Parameters
cf:Configuration

The configuration for the layer

parentLayers:List<ModuleLayer>

The list of parent layers in search order

parentLoader:ClassLoader

The parent class loader for the class loader created by this method; may be null for the bootstrap class loader

Returns:ModuleLayer.Controller

A controller that controls the newly created layer

Exceptions
IllegalArgumentException:
If the parent(s) of the given configuration do not match the configuration of the parent layers, including order
LayerInstantiationException:
If all modules cannot be defined to the same class loader for any of the reasons listed above
See Also
findLoader
emptyback to summary
public static ModuleLayer empty()

Returns the empty layer. There are no modules in the empty layer. It has no parents.

Returns:ModuleLayer

The empty layer

failback to summary
private static LayerInstantiationException fail(String fmt, Object... args)

Creates a LayerInstantiationException with the message formatted from the given format string and arguments.

findLoaderback to summary
public ClassLoader findLoader(String name)

Returns the ClassLoader for the module with the given name. If a module of the given name is not in this layer then the parent layers are searched in the manner specified by findModule.

API Note

This method does not return an Optional<ClassLoader> because `null` must be used to represent the bootstrap class loader.

Parameters
name:String

The name of the module to find

Returns:ClassLoader

The ClassLoader that the module is defined to

Exceptions
IllegalArgumentException:
if a module of the given name is not defined in this layer or any parent of this layer
findModuleback to summary
public Optional<Module> findModule(String name)

Returns the module with the given name in this layer, or if not in this layer, the parent layers. Finding a module in parent layers is equivalent to invoking findModule on each parent, in search order, until the module is found or all parents have been searched. In a tree of layers then this is equivalent to a depth-first search.

Parameters
name:String

The name of the module to find

Returns:Optional<Module>

The module with the given name or an empty Optional if there isn't a module with this name in this layer or any parent layer

getServicesCatalogback to summary
pack-priv ServicesCatalog getServicesCatalog()

Returns the ServicesCatalog for this Layer, creating it if not already created.

layersback to summary
pack-priv Stream<ModuleLayer> layers()

Returns an ordered stream of layers. The first element is this layer, the remaining elements are the parent layers in DFS order.

Implementation Note

For now, the assumption is that the number of elements will be very low and so this method does not use a specialized spliterator.

layersback to summary
pack-priv static Stream<ModuleLayer> layers(ClassLoader loader)

Returns a stream of the layers that have at least one module defined to the given class loader.

modulesback to summary
public Set<Module> modules()

Returns an unmodifiable set of the modules in this layer.

Returns:Set<Module>

A possibly-empty unmodifiable set of the modules in this layer

parentsback to summary
public List<ModuleLayer> parents()

Returns an unmodifiable list of this layer's parents, in search order. If this is the empty layer then an empty list is returned.

Returns:List<ModuleLayer>

A possibly-empty unmodifiable list of this layer's parents

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string describing this module layer.

Returns:String

A possibly empty string describing this module layer

Annotations
@Override
java.lang back to summary

public final Class ModuleLayer.Controller

extends Object
Class Inheritance

Controls a module layer. The static methods defined by ModuleLayer to create module layers return a Controller that can be used to control modules in the layer.

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

API Note

Care should be taken with Controller objects, they should never be shared with untrusted code.

Since
9

Field Summary

Modifier and TypeField and Description
private final ModuleLayer

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public ModuleLayer.Controller

Returns:

This controller
addExports
(Module
The source module
source
,
String
The package name
pn
,
Module
The target module
target
)

Updates module source in the layer to export a package to module target.

public ModuleLayer.Controller

Returns:

This controller
addOpens
(Module
The source module
source
,
String
The package name
pn
,
Module
The target module
target
)

Updates module source in the layer to open a package to module target.

public ModuleLayer.Controller

Returns:

This controller
addReads
(Module
The source module
source
,
Module
The target module to read
target
)

Updates module source in the layer to read module target.

public ModuleLayer.Controller

Returns:

This controller
enableNativeAccess
(Module
The module to update
target
)

Enables native access for a module in the layer if the caller's module has native access.

private void
public ModuleLayer

Returns:

the module layer
layer
()

Returns the layer that this object controls.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

layerback to summary
private final ModuleLayer layer

Constructor Detail

Controllerback to summary
pack-priv Controller(ModuleLayer layer)

Method Detail

addExportsback to summary
public ModuleLayer.Controller addExports(Module source, String pn, Module target)

Updates module source in the layer to export a package to module target. This method is a no-op if source already exports the package to at least target.

Parameters
source:Module

The source module

pn:String

The package name

target:Module

The target module

Returns:ModuleLayer.Controller

This controller

Exceptions
IllegalArgumentException:
If source is not in the module layer or the package is not in the source module
See Also
Module#addExports
addOpensback to summary
public ModuleLayer.Controller addOpens(Module source, String pn, Module target)

Updates module source in the layer to open a package to module target. This method is a no-op if source already opens the package to at least target.

Parameters
source:Module

The source module

pn:String

The package name

target:Module

The target module

Returns:ModuleLayer.Controller

This controller

Exceptions
IllegalArgumentException:
If source is not in the module layer or the package is not in the source module
See Also
Module#addOpens
addReadsback to summary
public ModuleLayer.Controller addReads(Module source, Module target)

Updates module source in the layer to read module target. This method is a no-op if source already reads target.

Implementation Note

Read edges added by this method are weak and do not prevent target from being GC'ed when source is strongly reachable.

Parameters
source:Module

The source module

target:Module

The target module to read

Returns:ModuleLayer.Controller

This controller

Exceptions
IllegalArgumentException:
If source is not in the module layer
See Also
Module#addReads
enableNativeAccessback to summary
public ModuleLayer.Controller enableNativeAccess(Module target)

Enables native access for a module in the layer if the caller's module has native access.

Parameters
target:Module

The module to update

Returns:ModuleLayer.Controller

This controller

Annotations
@CallerSensitive
@Restricted
Exceptions
IllegalArgumentException:
If target is not in the module layer
IllegalCallerException:
If the caller is in a module that does not have native access enabled
Since
22
ensureInLayerback to summary
private void ensureInLayer(Module source)
layerback to summary
public ModuleLayer layer()

Returns the layer that this object controls.

Returns:ModuleLayer

the module layer