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
@Enhance public static class JavaModule.Dispatcher.Enabled extends java.lang.Object implements JavaModule.Dispatcher
A dispatcher for a VM that does support thejava.lang.ModuleAPI.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.bytebuddy.utility.JavaModule.Dispatcher
JavaModule.Dispatcher.CreationAction, JavaModule.Dispatcher.Disabled, JavaModule.Dispatcher.Enabled
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.reflect.MethodcanReadThejava.lang.Module#canRead(Module)method.private java.lang.reflect.MethodgetClassLoaderThejava.lang.Module#getClassLoader()method.private java.lang.reflect.MethodgetModuleThejava.lang.Class#getModule()method.private java.lang.reflect.MethodgetNameThejava.lang.Module#getName()method.private java.lang.reflect.MethodgetResourceAsStreamThejava.lang.Module#getResourceAsStream(String)method.private java.lang.reflect.MethodisExportedThejava.lang.Module#isExported(String,Module)method.private java.lang.reflect.MethodisModifiableModuleThejava.lang.instrument.Instrumentation#isModifiableModulemethod.private java.lang.reflect.MethodisNamedThejava.lang.Module#isNamed()method.private java.lang.reflect.MethodisOpenedThejava.lang.Module#isOpened(String,Module)method.private static java.lang.Object[]NO_ARGUMENTSAn empty array that can be used to indicate no arguments to avoid an allocation on a reflective call.private java.lang.reflect.MethodredefineModuleThejava.lang.instrument.Instrumentation#redefineModulemethod.
-
Constructor Summary
Constructors Modifier Constructor Description protectedEnabled(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 isExported, java.lang.reflect.Method isOpened, 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 booleancanRead(java.lang.Object source, java.lang.Object target)Checks if the source module can read the target module.java.lang.ClassLoadergetClassLoader(java.lang.Object module)Returns the module's class loader.java.lang.StringgetName(java.lang.Object module)Returns the module's name.java.io.InputStreamgetResourceAsStream(java.lang.Object module, java.lang.String name)Returns a resource stream for this module for a resource of the given name ornullif such a resource does not exist.booleanisAlive()Checks if this dispatcher is alive, i.e.booleanisExported(java.lang.Object source, java.lang.Object target, java.lang.String aPackage)Returnstrueif the source module exports the supplied package to the target module.booleanisNamed(java.lang.Object module)Returnstrueif the supplied module is named.booleanisOpened(java.lang.Object source, java.lang.Object target, java.lang.String aPackage)Returnstrueif the source module opens the supplied package to the target module.voidmodify(java.lang.instrument.Instrumentation instrumentation, java.lang.Object source, 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.JavaModulemoduleOf(java.lang.Class<?> type)Extracts the JavaModulefor the provided class or returnsnullif the current VM does not support modules.
-
-
-
Field Detail
-
NO_ARGUMENTS
private static final java.lang.Object[] NO_ARGUMENTS
An empty array that can be used to indicate no arguments to avoid an allocation on a reflective call.
-
getModule
private final java.lang.reflect.Method getModule
Thejava.lang.Class#getModule()method.
-
getClassLoader
private final java.lang.reflect.Method getClassLoader
Thejava.lang.Module#getClassLoader()method.
-
isNamed
private final java.lang.reflect.Method isNamed
Thejava.lang.Module#isNamed()method.
-
getName
private final java.lang.reflect.Method getName
Thejava.lang.Module#getName()method.
-
getResourceAsStream
private final java.lang.reflect.Method getResourceAsStream
Thejava.lang.Module#getResourceAsStream(String)method.
-
isExported
private final java.lang.reflect.Method isExported
Thejava.lang.Module#isExported(String,Module)method.
-
isOpened
private final java.lang.reflect.Method isOpened
Thejava.lang.Module#isOpened(String,Module)method.
-
canRead
private final java.lang.reflect.Method canRead
Thejava.lang.Module#canRead(Module)method.
-
isModifiableModule
private final java.lang.reflect.Method isModifiableModule
Thejava.lang.instrument.Instrumentation#isModifiableModulemethod.
-
redefineModule
private final java.lang.reflect.Method redefineModule
Thejava.lang.instrument.Instrumentation#redefineModulemethod.
-
-
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 isExported, java.lang.reflect.Method isOpened, 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.isExported- Thejava.lang.Module#isExported(String,Module)method.isOpened- Thejava.lang.Module#isOpened(String,Module)method.canRead- Thejava.lang.Module#canRead(Module)method.isModifiableModule- Thejava.lang.instrument.Instrumentation#isModifiableModulemethod.redefineModule- Thejava.lang.instrument.Instrumentation#redefineModulemethod.
-
-
Method Detail
-
isAlive
public boolean isAlive()
Checks if this dispatcher is alive, i.e. supports modules.- Specified by:
isAlivein interfaceJavaModule.Dispatcher- Returns:
trueif modules are supported on the current VM.
-
moduleOf
public JavaModule moduleOf(java.lang.Class<?> type)
Extracts the JavaModulefor the provided class or returnsnullif the current VM does not support modules.- Specified by:
moduleOfin interfaceJavaModule.Dispatcher- Parameters:
type- The type for which to extract the module.- Returns:
- The class's
Moduleornullif the current VM does not support modules.
-
getResourceAsStream
public 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 ornullif such a resource does not exist.- Specified by:
getResourceAsStreamin interfaceJavaModule.Dispatcher- Parameters:
module- Thejava.lang.Moduleinstance to apply this method upon.name- The name of the resource.- Returns:
- An input stream for the resource or
nullif it does not exist.
-
getClassLoader
public java.lang.ClassLoader getClassLoader(java.lang.Object module)
Returns the module's class loader.- Specified by:
getClassLoaderin interfaceJavaModule.Dispatcher- Parameters:
module- Thejava.lang.Module- Returns:
- The module's class loader.
-
isNamed
public boolean isNamed(java.lang.Object module)
Returnstrueif the supplied module is named.- Specified by:
isNamedin interfaceJavaModule.Dispatcher- Parameters:
module- Thejava.lang.Moduleto check for the existence of a name.- Returns:
trueif the supplied module is named.
-
getName
public java.lang.String getName(java.lang.Object module)
Returns the module's name.- Specified by:
getNamein interfaceJavaModule.Dispatcher- Parameters:
module- Thejava.lang.Moduleto check for its name.- Returns:
- The module's (implicit or explicit) name.
-
isExported
public boolean isExported(java.lang.Object source, java.lang.Object target, java.lang.String aPackage)Returnstrueif the source module exports the supplied package to the target module.- Specified by:
isExportedin interfaceJavaModule.Dispatcher- Parameters:
source- The source module.target- The target module.aPackage- The name of the package to check.- Returns:
trueif the source module exports the supplied package to the target module.
-
isOpened
public boolean isOpened(java.lang.Object source, java.lang.Object target, java.lang.String aPackage)Returnstrueif the source module opens the supplied package to the target module.- Specified by:
isOpenedin interfaceJavaModule.Dispatcher- Parameters:
source- The source module.target- The target module.aPackage- The name of the package to check.- Returns:
trueif the source module opens the supplied package to the target module.
-
canRead
public boolean canRead(java.lang.Object source, java.lang.Object target)Checks if the source module can read the target module.- Specified by:
canReadin interfaceJavaModule.Dispatcher- Parameters:
source- The source module.target- The target module.- Returns:
trueif the source module can read the target module.
-
modify
public void modify(java.lang.instrument.Instrumentation instrumentation, java.lang.Object source, 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.- Specified by:
modifyin interfaceJavaModule.Dispatcher- Parameters:
instrumentation- The instrumentation instace to use for applying the modification.source- 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.
-
-