Class ClassFileLocator.ForInstrumentation
java.lang.Object
net.bytebuddy.dynamic.ClassFileLocator.ForInstrumentation
- All Implemented Interfaces:
Closeable, AutoCloseable, ClassFileLocator
- Enclosing interface:
ClassFileLocator
@Enhance
public static class ClassFileLocator.ForInstrumentation
extends Object
implements ClassFileLocator
A Java agent that allows the location of class files by emulating a retransformation. Note that this class file
locator causes a class to be loaded in order to look up its class file. Also, this locator does deliberately not
support the look-up of classes that represent lambda expressions.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA delegate that is queried for loading a class.protected static interfaceA dispatcher to interact with theInstrumentationAPI.protected static classA non-operational class file transformer that remembers the binary format of a given class.Nested classes/interfaces inherited from interface ClassFileLocator
ClassFileLocator.Compound, ClassFileLocator.Filtering, ClassFileLocator.ForClassLoader, ClassFileLocator.ForFolder, ClassFileLocator.ForInstrumentation, ClassFileLocator.ForJarFile, ClassFileLocator.ForModule, ClassFileLocator.ForModuleFile, ClassFileLocator.ForUrl, ClassFileLocator.MultiReleaseAware, ClassFileLocator.NoOp, ClassFileLocator.PackageDiscriminating, ClassFileLocator.Resolution, ClassFileLocator.Simple -
Field Summary
Fields inherited from interface ClassFileLocator
CLASS_FILE_EXTENSION, META_INF_VERSIONS -
Constructor Summary
ConstructorsConstructorDescriptionForInstrumentation(Instrumentation instrumentation, ClassLoader classLoader) Creates an agent-based class file locator.ForInstrumentation(Instrumentation instrumentation, ClassFileLocator.ForInstrumentation.ClassLoadingDelegate classLoadingDelegate) Creates an agent-based class file locator. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static ClassFileLocatorfromInstalledAgent(ClassLoader classLoader) Returns an agent-based class file locator for the given class loader and an already installed Byte Buddy-agent.Locates the class file for a given type and returns the binary data of the class file.static ClassFileLocatorof(Instrumentation instrumentation, Class<?> type) Returns a class file locator that is capable of locating a class file for the given type using the given instrumentation instance.
-
Constructor Details
-
ForInstrumentation
Creates an agent-based class file locator.- Parameters:
instrumentation- The instrumentation to be used.classLoader- The class loader to read a class from ornullto use the boot loader.
-
ForInstrumentation
public ForInstrumentation(Instrumentation instrumentation, ClassFileLocator.ForInstrumentation.ClassLoadingDelegate classLoadingDelegate) Creates an agent-based class file locator.- Parameters:
instrumentation- The instrumentation to be used.classLoadingDelegate- The delegate responsible for class loading.
-
-
Method Details
-
fromInstalledAgent
Returns an agent-based class file locator for the given class loader and an already installed Byte Buddy-agent.- Parameters:
classLoader- The class loader that is expected to load the looked-up a class.- Returns:
- A class file locator for the given class loader based on a Byte Buddy agent.
-
of
Returns a class file locator that is capable of locating a class file for the given type using the given instrumentation instance.- Parameters:
instrumentation- The instrumentation instance to query for a retransformation.type- The locatable type which class loader is used as a fallback.- Returns:
- A class file locator for locating the class file of the given type.
-
locate
Locates the class file for a given type and returns the binary data of the class file.- Specified by:
locatein interfaceClassFileLocator- Parameters:
name- The name of the type to locate a class file representation for.- Returns:
- Any binary representation of the type which might be illegal.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-