Top Description Fields Constructors Methods
jdk.internal.module

public Class Modules

extends Object
Class Inheritance
Imports
java.io.PrintStream, java.lang.module.Configuration, .ModuleDescriptor, .ModuleFinder, .ModuleReference, .ResolvedModule, java.net.URI, java.security.AccessController, .PrivilegedAction, java.util.Collection, .List, .Map, .Optional, .Set, java.util.function.Function, java.util.stream.Collectors, jdk.internal.access.JavaLangModuleAccess, .JavaLangAccess, .SharedSecrets, jdk.internal.loader.BootLoader, .BuiltinClassLoader, .ClassLoaders

A helper class for creating and updating modules. This class is intended to support command-line options, tests, and the instrumentation API. It is also used by the VM to load modules or add read edges when agents are instrumenting code that need to link to supporting classes. The parameters that are package names in this API are the fully-qualified names of the packages as defined in section 6.5.3 of The Java Language Specification , for example, "java.lang".

Field Summary

Modifier and TypeField and Description
private static final JavaLangAccess
private static final JavaLangModuleAccess
private static volatile ModuleLayer

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static void
addEnableNativeAccessToAllUnnamed()

Adds native access to all unnamed modules.

public static void
addExports(Module m1, String pn, Module m2)

Updates module m1 to export a package to module m2.

public static void
addExports(Module m, String pn)

Updates module m to export a package unconditionally.

public static void
addExportsToAllUnnamed(Module m, String pn)

Updates module m to export a package to all unnamed modules.

public static void
addOpens(Module m1, String pn, Module m2)

Updates module m1 to open a package to module m2.

public static void
addOpensToAllUnnamed(Module m, String pn)

Updates module m to open a package to all unnamed modules.

public static void
addProvides(Module m, Class<?> service, Class<?> impl)

Updates module m to provide a service

public static void
addReads(Module m1, Module m2)

Updates m1 to read m2.

public static void
addReadsAllUnnamed(Module m)

Update module m to read all unnamed modules.

public static void
addUses(Module m, Class<?> service)

Updates module m to use a service.

public static Module
defineModule(ClassLoader loader, ModuleDescriptor descriptor, URI uri)

Creates a new Module.

public static Optional<Module>
findLoadedModule(String name)

Finds the module with the given name in the boot layer or any child layers created to load the "java.instrument" or "jdk.management.agent" modules into a running VM.

public static synchronized Module
loadModule(String name)

Called by the VM to load a system module, typically "java.instrument" or "jdk.management.agent".

public static Configuration
newBootLayerConfiguration(ModuleFinder finder, Collection<String> roots, PrintStream traceOutput)

Resolves a collection of root modules, with service binding and the empty Configuration as the parent to create a Configuration for the boot layer.

public static void
transformedByAgent(Module m)

Called by the VM when code in the given Module has been transformed by an agent and so may have been instrumented to call into supporting classes on the boot class path or application class path.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

JLAback to summary
private static final JavaLangAccess JLA
JLMAback to summary
private static final JavaLangModuleAccess JLMA
topLayerback to summary
private static volatile ModuleLayer topLayer

Constructor Detail

Modulesback to summary
private Modules()

Method Detail

addEnableNativeAccessToAllUnnamedback to summary
public static void addEnableNativeAccessToAllUnnamed()

Adds native access to all unnamed modules.

addExportsback to summary
public static void addExports(Module m1, String pn, Module m2)

Updates module m1 to export a package to module m2. Same as m1.addExports(pn, m2) but without a caller check

addExportsback to summary
public static void addExports(Module m, String pn)

Updates module m to export a package unconditionally.

addExportsToAllUnnamedback to summary
public static void addExportsToAllUnnamed(Module m, String pn)

Updates module m to export a package to all unnamed modules.

addOpensback to summary
public static void addOpens(Module m1, String pn, Module m2)

Updates module m1 to open a package to module m2. Same as m1.addOpens(pn, m2) but without a caller check.

addOpensToAllUnnamedback to summary
public static void addOpensToAllUnnamed(Module m, String pn)

Updates module m to open a package to all unnamed modules.

addProvidesback to summary
public static void addProvides(Module m, Class<?> service, Class<?> impl)

Updates module m to provide a service

addReadsback to summary
public static void addReads(Module m1, Module m2)

Updates m1 to read m2. Same as m1.addReads(m2) but without a caller check.

addReadsAllUnnamedback to summary
public static void addReadsAllUnnamed(Module m)

Update module m to read all unnamed modules.

addUsesback to summary
public static void addUses(Module m, Class<?> service)

Updates module m to use a service. Same as m2.addUses(service) but without a caller check.

defineModuleback to summary
public static Module defineModule(ClassLoader loader, ModuleDescriptor descriptor, URI uri)

Creates a new Module. The module has the given ModuleDescriptor and is defined to the given class loader. The resulting Module is in a larval state in that it does not read any other module and does not have any exports. The URI is for information purposes only.

findLoadedModuleback to summary
public static Optional<Module> findLoadedModule(String name)

Finds the module with the given name in the boot layer or any child layers created to load the "java.instrument" or "jdk.management.agent" modules into a running VM.

loadModuleback to summary
public static synchronized Module loadModule(String name)

Called by the VM to load a system module, typically "java.instrument" or "jdk.management.agent". If the module is not loaded then it is resolved and loaded (along with any dependences that weren't previously loaded) into a child layer.

newBootLayerConfigurationback to summary
public static Configuration newBootLayerConfiguration(ModuleFinder finder, Collection<String> roots, PrintStream traceOutput)

Resolves a collection of root modules, with service binding and the empty Configuration as the parent to create a Configuration for the boot layer. This method is intended to be used to create the Configuration for the boot layer during startup or at a link-time.

transformedByAgentback to summary
public static void transformedByAgent(Module m)

Called by the VM when code in the given Module has been transformed by an agent and so may have been instrumented to call into supporting classes on the boot class path or application class path.