Package net.bytebuddy.utility
Class JavaModule.Dispatcher.Enabled
- java.lang.Object
-
- net.bytebuddy.utility.JavaModule.Dispatcher.Enabled
-
- All Implemented Interfaces:
JavaModule.Dispatcher
- Enclosing interface:
- JavaModule.Dispatcher
public static class JavaModule.Dispatcher.Enabled extends java.lang.Object implements JavaModule.Dispatcher
A dispatcher for a VM that does support thejava.lang.Module
API.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.bytebuddy.utility.JavaModule.Dispatcher
JavaModule.Dispatcher.CreationAction, JavaModule.Dispatcher.Disabled, JavaModule.Dispatcher.Enabled
-
-
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 canRead, java.lang.reflect.Method isModifiableModule, java.lang.reflect.Method redefineModule)
Creates an enabled dispatcher.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addReads(java.lang.instrument.Instrumentation instrumentation, java.lang.Object source, java.lang.Object target)
Adds a read-edge from the source to the target module.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
isNamed(java.lang.Object module)
Returnstrue
if the supplied module is named.JavaModule
moduleOf(java.lang.Class<?> type)
Extracts the JavaModule
for the provided class or returnsnull
if the current VM does not support modules.
-
-
-
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 canRead, java.lang.reflect.Method isModifiableModule, java.lang.reflect.Method redefineModule)
Creates an enabled dispatcher.- Parameters:
getModule
- Thejava.lang.Class#getModule()
method.getClassLoader
- Thejava.lang.Module#getClassLoader()
method.isNamed
- Thejava.lang.Module#isNamed()
method.getName
- Thejava.lang.Module#getName()
method.getResourceAsStream
- Thejava.lang.Module#getResourceAsStream(String)
method.canRead
- Thejava.lang.Module#canRead(Module)
method.isModifiableModule
- Thejava.lang.instrument.Instrumentation#isModifiableModule
method.redefineModule
- Thejava.lang.instrument.Instrumentation#redefineModule
method.
-
-
Method Detail
-
isAlive
public boolean isAlive()
Description copied from interface:JavaModule.Dispatcher
Checks if this dispatcher is alive, i.e. supports modules.- Specified by:
isAlive
in interfaceJavaModule.Dispatcher
- Returns:
true
if modules are supported on the current VM.
-
moduleOf
public JavaModule moduleOf(java.lang.Class<?> type)
Description copied from interface:JavaModule.Dispatcher
Extracts the JavaModule
for the provided class or returnsnull
if the current VM does not support modules.- Specified by:
moduleOf
in interfaceJavaModule.Dispatcher
- Parameters:
type
- The type for which to extract the module.- Returns:
- The class's
Module
ornull
if the current VM does not support modules.
-
getResourceAsStream
public java.io.InputStream getResourceAsStream(java.lang.Object module, java.lang.String name)
Description copied from interface:JavaModule.Dispatcher
Returns a resource stream for this module for a resource of the given name ornull
if such a resource does not exist.- Specified by:
getResourceAsStream
in interfaceJavaModule.Dispatcher
- 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
public java.lang.ClassLoader getClassLoader(java.lang.Object module)
Description copied from interface:JavaModule.Dispatcher
Returns the module's class loader.- Specified by:
getClassLoader
in interfaceJavaModule.Dispatcher
- Parameters:
module
- Thejava.lang.Module
- Returns:
- The module's class loader.
-
isNamed
public boolean isNamed(java.lang.Object module)
Description copied from interface:JavaModule.Dispatcher
Returnstrue
if the supplied module is named.- Specified by:
isNamed
in interfaceJavaModule.Dispatcher
- Parameters:
module
- Thejava.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)
Description copied from interface:JavaModule.Dispatcher
Returns the module's name.- Specified by:
getName
in interfaceJavaModule.Dispatcher
- Parameters:
module
- Thejava.lang.Module
to check for its name.- Returns:
- The module's (implicit or explicit) name.
-
canRead
public boolean canRead(java.lang.Object source, java.lang.Object target)
Description copied from interface:JavaModule.Dispatcher
Checks if the source module can read the target module.- Specified by:
canRead
in interfaceJavaModule.Dispatcher
- Parameters:
source
- The source module.target
- The target module.- Returns:
true
if the source module can read the target module.
-
addReads
public void addReads(java.lang.instrument.Instrumentation instrumentation, java.lang.Object source, java.lang.Object target)
Description copied from interface:JavaModule.Dispatcher
Adds a read-edge from the source to the target module.- Specified by:
addReads
in interfaceJavaModule.Dispatcher
- Parameters:
instrumentation
- The instrumentation instance to use for adding the edge.source
- The source module.target
- The target module.
-
-