Package net.bytebuddy.agent.builder
Class AgentBuilder.PoolStrategy.WithTypePoolCache
- java.lang.Object
-
- net.bytebuddy.agent.builder.AgentBuilder.PoolStrategy.WithTypePoolCache
-
- All Implemented Interfaces:
AgentBuilder.PoolStrategy
- Direct Known Subclasses:
AgentBuilder.PoolStrategy.WithTypePoolCache.Simple
- Enclosing interface:
- AgentBuilder.PoolStrategy
@Enhance public abstract static class AgentBuilder.PoolStrategy.WithTypePoolCache extends java.lang.Object implements AgentBuilder.PoolStrategy
A type locator that uses type pools but allows for the configuration of a custom cache provider by class loader. Note that a
TypePoolcan grow in size and that a static reference is kept to this pool by Byte Buddy's registration of aClassFileTransformerwhat can cause a memory leak if the supplied caches are not cleared on a regular basis. Also note that a cache provider can be accessed concurrently by multipleClassLoaders.All types that are returned by the locator's type pool are resolved lazily.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAgentBuilder.PoolStrategy.WithTypePoolCache.SimpleAn implementation of a type locatorAgentBuilder.PoolStrategy.WithTypePoolCache(note documentation of the linked class) that is based on aConcurrentMap.-
Nested classes/interfaces inherited from interface net.bytebuddy.agent.builder.AgentBuilder.PoolStrategy
AgentBuilder.PoolStrategy.ClassLoading, AgentBuilder.PoolStrategy.Default, AgentBuilder.PoolStrategy.Eager, AgentBuilder.PoolStrategy.ExtraLazy, AgentBuilder.PoolStrategy.WithTypePoolCache
-
-
Field Summary
Fields Modifier and Type Field Description protected TypePool.Default.WithLazyResolution.LazinessModelazinessModeThe laziness mode to use for when to parse a class file.protected TypePool.Default.ReaderModereaderModeThe reader mode to use for parsing a class file.
-
Constructor Summary
Constructors Modifier Constructor Description protectedWithTypePoolCache(TypePool.Default.ReaderMode readerMode)Creates a new type locator that createsTypePools but provides a customTypePool.CacheProvider.protectedWithTypePoolCache(TypePool.Default.ReaderMode readerMode, TypePool.Default.WithLazyResolution.LazinessMode lazinessMode)Creates a new type locator that createsTypePools but provides a customTypePool.CacheProvider.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract TypePool.CacheProviderlocate(java.lang.ClassLoader classLoader)Locates a cache provider for a given class loader.TypePooltypePool(ClassFileLocator classFileLocator, java.lang.ClassLoader classLoader)Creates a type pool for a given class file locator.TypePooltypePool(ClassFileLocator classFileLocator, java.lang.ClassLoader classLoader, java.lang.String name)Creates a type pool for a given class file locator.
-
-
-
Field Detail
-
readerMode
protected final TypePool.Default.ReaderMode readerMode
The reader mode to use for parsing a class file.
-
lazinessMode
protected final TypePool.Default.WithLazyResolution.LazinessMode lazinessMode
The laziness mode to use for when to parse a class file.
-
-
Constructor Detail
-
WithTypePoolCache
protected WithTypePoolCache(TypePool.Default.ReaderMode readerMode)
Creates a new type locator that createsTypePools but provides a customTypePool.CacheProvider.- Parameters:
readerMode- The reader mode to use for parsing a class file.
-
WithTypePoolCache
protected WithTypePoolCache(TypePool.Default.ReaderMode readerMode, TypePool.Default.WithLazyResolution.LazinessMode lazinessMode)
Creates a new type locator that createsTypePools but provides a customTypePool.CacheProvider.- Parameters:
readerMode- The reader mode to use for parsing a class file.lazinessMode- The laziness mode to use for when to parse a class file.
-
-
Method Detail
-
typePool
public TypePool typePool(ClassFileLocator classFileLocator, @MaybeNull java.lang.ClassLoader classLoader)
Creates a type pool for a given class file locator.- Specified by:
typePoolin interfaceAgentBuilder.PoolStrategy- Parameters:
classFileLocator- The class file locator to use.classLoader- The class loader for which the class file locator was created ornullif the boot loader.- Returns:
- A type pool for the supplied class file locator.
-
typePool
public TypePool typePool(ClassFileLocator classFileLocator, @MaybeNull java.lang.ClassLoader classLoader, java.lang.String name)
Creates a type pool for a given class file locator. If a cache is used, the type that is currently instrumented is not used.- Specified by:
typePoolin interfaceAgentBuilder.PoolStrategy- Parameters:
classFileLocator- The class file locator to use.classLoader- The class loader for which the class file locator was created ornullif the boot loader.name- The name of the currently instrumented type.- Returns:
- A type pool for the supplied class file locator.
-
locate
protected abstract TypePool.CacheProvider locate(@MaybeNull java.lang.ClassLoader classLoader)
Locates a cache provider for a given class loader.- Parameters:
classLoader- The class loader for which to locate a cache. This class loader might benullto represent the bootstrap loader.- Returns:
- The cache provider to use.
-
-