Class AgentBuilder.PoolStrategy.WithTypePoolCache.Simple
java.lang.Object
net.bytebuddy.agent.builder.AgentBuilder.PoolStrategy.WithTypePoolCache
net.bytebuddy.agent.builder.AgentBuilder.PoolStrategy.WithTypePoolCache.Simple
- All Implemented Interfaces:
AgentBuilder.PoolStrategy
- Enclosing class:
AgentBuilder.PoolStrategy.WithTypePoolCache
@Enhance
public static class AgentBuilder.PoolStrategy.WithTypePoolCache.Simple
extends AgentBuilder.PoolStrategy.WithTypePoolCache
An implementation of a type locator
AgentBuilder.PoolStrategy.WithTypePoolCache (note documentation of the linked class) that is based on a
ConcurrentMap. It is the responsibility of the type locator's user to avoid the type locator from leaking memory.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enumAn action that creates a class loader to mark the bootstrap loader without usingnull.Nested classes/interfaces inherited from class AgentBuilder.PoolStrategy.WithTypePoolCache
AgentBuilder.PoolStrategy.WithTypePoolCache.SimpleNested classes/interfaces inherited from interface AgentBuilder.PoolStrategy
AgentBuilder.PoolStrategy.ClassLoading, AgentBuilder.PoolStrategy.Default, AgentBuilder.PoolStrategy.Eager, AgentBuilder.PoolStrategy.ExtraLazy, AgentBuilder.PoolStrategy.WithTypePoolCache -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ClassLoaderA default value for marking the boostrap class loader.private final ConcurrentMap<? super ClassLoader, TypePool.CacheProvider> The concurrent map that is used for storing a cache provider per class loader.Fields inherited from class AgentBuilder.PoolStrategy.WithTypePoolCache
lazinessMode, readerMode -
Constructor Summary
ConstructorsConstructorDescriptionSimple(ConcurrentMap<? super ClassLoader, TypePool.CacheProvider> cacheProviders) Creates a new type locator that caches a cache provider per class loader in a concurrent map.Simple(TypePool.Default.ReaderMode readerMode, ConcurrentMap<? super ClassLoader, TypePool.CacheProvider> cacheProviders) Creates a new type locator that caches a cache provider per class loader in a concurrent map.Simple(TypePool.Default.ReaderMode readerMode, TypePool.Default.WithLazyResolution.LazinessMode lazinessMode, ConcurrentMap<? super ClassLoader, TypePool.CacheProvider> cacheProviders) Creates a new type locator that caches a cache provider per class loader in a concurrent map. -
Method Summary
Modifier and TypeMethodDescriptionprivate static <T> TdoPrivileged(PrivilegedAction<T> action) A proxy forjava.security.AccessController#doPrivilegedthat is activated if available.protected ClassLoaderReturns the class loader to serve as a cache key if a cache provider for the bootstrap class loader is requested.protected TypePool.CacheProviderlocate(ClassLoader classLoader) Locates a cache provider for a given class loader.Methods inherited from class AgentBuilder.PoolStrategy.WithTypePoolCache
typePool, typePool
-
Field Details
-
BOOTSTRAP_MARKER
A default value for marking the boostrap class loader. -
cacheProviders
The concurrent map that is used for storing a cache provider per class loader.
-
-
Constructor Details
-
Simple
Creates a new type locator that caches a cache provider per class loader in a concurrent map. The type locator uses a fastTypePool.Default.ReaderMode.- Parameters:
cacheProviders- The concurrent map that is used for storing a cache provider per class loader.
-
Simple
public Simple(TypePool.Default.ReaderMode readerMode, ConcurrentMap<? super ClassLoader, TypePool.CacheProvider> cacheProviders) Creates a new type locator that caches a cache provider per class loader in a concurrent map.- Parameters:
readerMode- The reader mode to use for parsing a class file.cacheProviders- The concurrent map that is used for storing a cache provider per class loader.
-
Simple
public Simple(TypePool.Default.ReaderMode readerMode, TypePool.Default.WithLazyResolution.LazinessMode lazinessMode, ConcurrentMap<? super ClassLoader, TypePool.CacheProvider> cacheProviders) Creates a new type locator that caches a cache provider per class loader in a concurrent map.- 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.cacheProviders- The concurrent map that is used for storing a cache provider per class loader.
-
-
Method Details
-
doPrivileged
A proxy forjava.security.AccessController#doPrivilegedthat is activated if available.- Type Parameters:
T- The type of the action's resolved value.- Parameters:
action- The action to execute from a privileged context.- Returns:
- The action's resolved value.
-
locate
Description copied from class:AgentBuilder.PoolStrategy.WithTypePoolCacheLocates a cache provider for a given class loader.- Specified by:
locatein classAgentBuilder.PoolStrategy.WithTypePoolCache- 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.
-
getBootstrapMarkerLoader
Returns the class loader to serve as a cache key if a cache provider for the bootstrap class loader is requested. This class loader is represented by
nullin the JVM which is an invalid value for manyConcurrentMapimplementations.By default, a custom class loader is created to use as a marker.
- Returns:
- A class loader to represent the bootstrap class loader.
-