Package net.bytebuddy.dynamic
Class ClassFileLocator.AgentBased
- java.lang.Object
-
- net.bytebuddy.dynamic.ClassFileLocator.AgentBased
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,ClassFileLocator
- Enclosing interface:
- ClassFileLocator
public static class ClassFileLocator.AgentBased extends java.lang.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 Classes Modifier and Type Class Description static interfaceClassFileLocator.AgentBased.ClassLoadingDelegateA delegate that is queried for loading a class.protected static classClassFileLocator.AgentBased.ExtractionClassFileTransformerA non-operational class file transformer that remembers the binary format of a given class.-
Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.ClassFileLocator
ClassFileLocator.AgentBased, ClassFileLocator.Compound, ClassFileLocator.ForClassLoader, ClassFileLocator.ForFolder, ClassFileLocator.ForJarFile, ClassFileLocator.ForModule, ClassFileLocator.ForModuleFile, ClassFileLocator.NoOp, ClassFileLocator.PackageDiscriminating, ClassFileLocator.Resolution, ClassFileLocator.Simple
-
-
Field Summary
-
Fields inherited from interface net.bytebuddy.dynamic.ClassFileLocator
CLASS_FILE_EXTENSION
-
-
Constructor Summary
Constructors Constructor Description AgentBased(java.lang.instrument.Instrumentation instrumentation, java.lang.ClassLoader classLoader)Creates an agent-based class file locator.AgentBased(java.lang.instrument.Instrumentation instrumentation, ClassFileLocator.AgentBased.ClassLoadingDelegate classLoadingDelegate)Creates an agent-based class file locator.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()static ClassFileLocatorfromInstalledAgent(java.lang.ClassLoader classLoader)Returns an agent-based class file locator for the given class loader and an already installed Byte Buddy-agent.ClassFileLocator.Resolutionlocate(java.lang.String typeName)Locates the class file for a given type and returns the binary data of the class file.static ClassFileLocatorof(java.lang.instrument.Instrumentation instrumentation, java.lang.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 Detail
-
AgentBased
public AgentBased(java.lang.instrument.Instrumentation instrumentation, java.lang.ClassLoader classLoader)Creates an agent-based class file locator.- Parameters:
instrumentation- The instrumentation to be used.classLoader- The class loader to read a class from.
-
AgentBased
public AgentBased(java.lang.instrument.Instrumentation instrumentation, ClassFileLocator.AgentBased.ClassLoadingDelegate classLoadingDelegate)Creates an agent-based class file locator.- Parameters:
instrumentation- The instrumentation to be used.classLoadingDelegate- The delegate responsible for class loading.
-
-
Method Detail
-
fromInstalledAgent
public static ClassFileLocator fromInstalledAgent(java.lang.ClassLoader classLoader)
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
public static ClassFileLocator of(java.lang.instrument.Instrumentation instrumentation, java.lang.Class<?> type)
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
public ClassFileLocator.Resolution locate(java.lang.String typeName)
Description copied from interface:ClassFileLocatorLocates the class file for a given type and returns the binary data of the class file.- Specified by:
locatein interfaceClassFileLocator- Parameters:
typeName- 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() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
-