Package net.bytebuddy.dynamic.loading
Class ClassInjector.UsingReflection.Dispatcher.Indirect
- java.lang.Object
-
- net.bytebuddy.dynamic.loading.ClassInjector.UsingReflection.Dispatcher.Indirect
-
- All Implemented Interfaces:
ClassInjector.UsingReflection.Dispatcher
,ClassInjector.UsingReflection.Dispatcher.Initializable
- Enclosing interface:
- ClassInjector.UsingReflection.Dispatcher
public static class ClassInjector.UsingReflection.Dispatcher.Indirect extends java.lang.Object implements ClassInjector.UsingReflection.Dispatcher, ClassInjector.UsingReflection.Dispatcher.Initializable
An indirect dispatcher that uses a redirection accessor class that was injected into the bootstrap class loader.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.loading.ClassInjector.UsingReflection.Dispatcher
ClassInjector.UsingReflection.Dispatcher.CreationAction, ClassInjector.UsingReflection.Dispatcher.Direct, ClassInjector.UsingReflection.Dispatcher.Indirect, ClassInjector.UsingReflection.Dispatcher.Initializable, ClassInjector.UsingReflection.Dispatcher.Unavailable
-
-
Field Summary
-
Fields inherited from interface net.bytebuddy.dynamic.loading.ClassInjector.UsingReflection.Dispatcher
UNDEFINED
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Indirect(java.lang.Object accessor, java.lang.reflect.Method findLoadedClass, java.lang.reflect.Method defineClass, java.lang.reflect.Method getPackage, java.lang.reflect.Method definePackage, java.lang.reflect.Method getClassLoadingLock)
Creates a new indirect class loading injection dispatcher.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Class<?>
defineClass(java.lang.ClassLoader classLoader, java.lang.String name, byte[] binaryRepresentation, java.security.ProtectionDomain protectionDomain)
Defines a class for the given class loader.java.lang.Package
definePackage(java.lang.ClassLoader classLoader, java.lang.String name, java.lang.String specificationTitle, java.lang.String specificationVersion, java.lang.String specificationVendor, java.lang.String implementationTitle, java.lang.String implementationVersion, java.lang.String implementationVendor, java.net.URL sealBase)
Defines a package for the given class loader.java.lang.Class<?>
findClass(java.lang.ClassLoader classLoader, java.lang.String name)
Looks up a class from the given class loader.java.lang.Object
getClassLoadingLock(java.lang.ClassLoader classLoader, java.lang.String name)
Returns the lock for loading the specified class.java.lang.Package
getPackage(java.lang.ClassLoader classLoader, java.lang.String name)
Looks up a package from a class loader.ClassInjector.UsingReflection.Dispatcher
initialize()
Initializes this dispatcher.boolean
isAvailable()
Indicates if this dispatcher is available.static ClassInjector.UsingReflection.Dispatcher.Initializable
make()
Creates an indirect dispatcher.
-
-
-
Constructor Detail
-
Indirect
protected Indirect(java.lang.Object accessor, java.lang.reflect.Method findLoadedClass, java.lang.reflect.Method defineClass, java.lang.reflect.Method getPackage, java.lang.reflect.Method definePackage, java.lang.reflect.Method getClassLoadingLock)
Creates a new indirect class loading injection dispatcher.- Parameters:
accessor
- An instance of the accessor class that is required for using it's intentionally non-static methods.findLoadedClass
- An instance ofClassLoader.findLoadedClass(String)
.defineClass
- An instance ofClassLoader.defineClass(String, byte[], int, int, ProtectionDomain)
.getPackage
- An instance ofClassLoader.getPackage(String)
orClassLoader#getDefinedPackage(String)
.definePackage
- An instance ofClassLoader.definePackage(String, String, String, String, String, String, String, URL)
.getClassLoadingLock
- The accessor method for usingClassLoader#getClassLoadingLock(String)
or returning the suppliedClassLoader
if this method does not exist on the current VM.
-
-
Method Detail
-
isAvailable
public boolean isAvailable()
Description copied from interface:ClassInjector.UsingReflection.Dispatcher.Initializable
Indicates if this dispatcher is available.- Specified by:
isAvailable
in interfaceClassInjector.UsingReflection.Dispatcher.Initializable
- Returns:
true
if this dispatcher is available.
-
make
public static ClassInjector.UsingReflection.Dispatcher.Initializable make() throws java.lang.Exception
Creates an indirect dispatcher.- Returns:
- An indirect dispatcher for class creation.
- Throws:
java.lang.Exception
- If the dispatcher cannot be created.
-
initialize
public ClassInjector.UsingReflection.Dispatcher initialize()
Description copied from interface:ClassInjector.UsingReflection.Dispatcher.Initializable
Initializes this dispatcher.- Specified by:
initialize
in interfaceClassInjector.UsingReflection.Dispatcher.Initializable
- Returns:
- The initialized dispatcher.
-
getClassLoadingLock
public java.lang.Object getClassLoadingLock(java.lang.ClassLoader classLoader, java.lang.String name)
Description copied from interface:ClassInjector.UsingReflection.Dispatcher
Returns the lock for loading the specified class.- Specified by:
getClassLoadingLock
in interfaceClassInjector.UsingReflection.Dispatcher
- Parameters:
classLoader
- the class loader to inject the class into.name
- The name of the class.- Returns:
- The lock for loading this class.
-
findClass
public java.lang.Class<?> findClass(java.lang.ClassLoader classLoader, java.lang.String name)
Description copied from interface:ClassInjector.UsingReflection.Dispatcher
Looks up a class from the given class loader.- Specified by:
findClass
in interfaceClassInjector.UsingReflection.Dispatcher
- Parameters:
classLoader
- The class loader for which a class should be located.name
- The binary name of the class that should be located.- Returns:
- The class for the binary name or
null
if no such class is defined for the provided class loader.
-
defineClass
public java.lang.Class<?> defineClass(java.lang.ClassLoader classLoader, java.lang.String name, byte[] binaryRepresentation, java.security.ProtectionDomain protectionDomain)
Description copied from interface:ClassInjector.UsingReflection.Dispatcher
Defines a class for the given class loader.- Specified by:
defineClass
in interfaceClassInjector.UsingReflection.Dispatcher
- Parameters:
classLoader
- The class loader for which a new class should be defined.name
- The binary name of the class that should be defined.binaryRepresentation
- The binary representation of the class.protectionDomain
- The protection domain for the defined class.- Returns:
- The defined, loaded class.
-
getPackage
public java.lang.Package getPackage(java.lang.ClassLoader classLoader, java.lang.String name)
Description copied from interface:ClassInjector.UsingReflection.Dispatcher
Looks up a package from a class loader.- Specified by:
getPackage
in interfaceClassInjector.UsingReflection.Dispatcher
- Parameters:
classLoader
- The class loader to query.name
- The binary name of the package.- Returns:
- The package for the given name as defined by the provided class loader or
null
if no such package exists.
-
definePackage
public java.lang.Package definePackage(java.lang.ClassLoader classLoader, java.lang.String name, java.lang.String specificationTitle, java.lang.String specificationVersion, java.lang.String specificationVendor, java.lang.String implementationTitle, java.lang.String implementationVersion, java.lang.String implementationVendor, java.net.URL sealBase)
Description copied from interface:ClassInjector.UsingReflection.Dispatcher
Defines a package for the given class loader.- Specified by:
definePackage
in interfaceClassInjector.UsingReflection.Dispatcher
- Parameters:
classLoader
- The class loader for which a package is to be defined.name
- The binary name of the package.specificationTitle
- The specification title of the package ornull
if no specification title exists.specificationVersion
- The specification version of the package ornull
if no specification version exists.specificationVendor
- The specification vendor of the package ornull
if no specification vendor exists.implementationTitle
- The implementation title of the package ornull
if no implementation title exists.implementationVersion
- The implementation version of the package ornull
if no implementation version exists.implementationVendor
- The implementation vendor of the package ornull
if no implementation vendor exists.sealBase
- The seal base URL ornull
if the package should not be sealed.- Returns:
- The defined package.
-
-