Package net.bytebuddy.utility
Interface JavaModule.Dispatcher
-
- All Known Implementing Classes:
JavaModule.Dispatcher.Disabled
,JavaModule.Dispatcher.Enabled
,JavaModule.Dispatcher.Enabled.WithInstrumentationSupport
,JavaModule.Dispatcher.Enabled.WithoutInstrumentationSupport
- Enclosing class:
- JavaModule
protected static interface JavaModule.Dispatcher
A dispatcher for accessing thejava.lang.Module
API if it is available on the current VM.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
JavaModule.Dispatcher.CreationAction
A creation action for a dispatcher.static class
JavaModule.Dispatcher.Disabled
A disabled dispatcher for a VM that does not support thejava.lang.Module
API.static class
JavaModule.Dispatcher.Enabled
A dispatcher for a VM that does support thejava.lang.Module
API.
-
Method Summary
All Methods Instance Methods Abstract 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 ornull
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)
Returnstrue
if the source module exports the supplied package to the target module.boolean
isNamed(java.lang.Object module)
Returnstrue
if the supplied module is named.boolean
isOpened(java.lang.Object source, java.lang.Object target, java.lang.String aPackage)
Returnstrue
if the source module opens the supplied package to the target module.void
modify(java.lang.instrument.Instrumentation instrumentation, java.lang.Object module, java.util.Set<java.lang.Object> reads, java.util.Map<java.lang.String,java.util.Set<java.lang.Object>> exports, java.util.Map<java.lang.String,java.util.Set<java.lang.Object>> opens, java.util.Set<java.lang.Class<?>> uses, java.util.Map<java.lang.Class<?>,java.util.List<java.lang.Class<?>>> provides)
Modifies this module's properties.JavaModule
moduleOf(java.lang.Class<?> type)
Extracts the JavaModule
for the provided class or returnsnull
if the current VM does not support modules.
-
-
-
Method Detail
-
isAlive
boolean isAlive()
Checks if this dispatcher is alive, i.e. supports modules.- Returns:
true
if modules are supported on the current VM.
-
moduleOf
JavaModule moduleOf(java.lang.Class<?> type)
Extracts the JavaModule
for the provided class or returnsnull
if the current VM does not support modules.- Parameters:
type
- The type for which to extract the module.- Returns:
- The class's
Module
ornull
if the current VM does not support modules.
-
isNamed
boolean isNamed(java.lang.Object module)
Returnstrue
if the supplied module is named.- Parameters:
module
- Thejava.lang.Module
to check for the existence of a name.- Returns:
true
if the supplied module is named.
-
getName
java.lang.String getName(java.lang.Object module)
Returns the module's name.- Parameters:
module
- Thejava.lang.Module
to check for its name.- Returns:
- The module's (implicit or explicit) name.
-
getResourceAsStream
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 ornull
if such a resource does not exist.- Parameters:
module
- Thejava.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
java.lang.ClassLoader getClassLoader(java.lang.Object module)
Returns the module's class loader.- Parameters:
module
- Thejava.lang.Module
- Returns:
- The module's class loader.
-
isExported
boolean isExported(java.lang.Object source, java.lang.Object target, java.lang.String aPackage)
Returnstrue
if the source module exports the supplied package to the target module.- 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
boolean isOpened(java.lang.Object source, java.lang.Object target, java.lang.String aPackage)
Returnstrue
if the source module opens the supplied package to the target module.- 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
boolean canRead(java.lang.Object source, java.lang.Object target)
Checks if the source module can read the target module.- Parameters:
source
- The source module.target
- The target module.- Returns:
true
if the source module can read the target module.
-
modify
void modify(java.lang.instrument.Instrumentation instrumentation, java.lang.Object module, java.util.Set<java.lang.Object> reads, java.util.Map<java.lang.String,java.util.Set<java.lang.Object>> exports, java.util.Map<java.lang.String,java.util.Set<java.lang.Object>> opens, java.util.Set<java.lang.Class<?>> uses, java.util.Map<java.lang.Class<?>,java.util.List<java.lang.Class<?>>> provides)
Modifies this module's properties.- Parameters:
instrumentation
- The instrumentation instace to use for applying the modification.module
- The module to modify.reads
- A set of additional modules this module should read.exports
- A map of packages to export to a set of modules.opens
- A map of packages to open to a set of modules.uses
- A set of provider interfaces to use by this module.provides
- A map of provider interfaces to provide by this module mapped to the provider implementations.
-
-