Package net.bytebuddy.agent.builder
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 locatorAgentBuilder.PoolStrategy.WithTypePoolCache
(note documentation of the linked class) that is based on aConcurrentMap
. It is the responsibility of the type locator's user to avoid the type locator from leaking memory.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AgentBuilder.PoolStrategy.WithTypePoolCache.Simple.BootstrapMarkerAction
An action that creates a class loader to mark the bootstrap loader without usingnull
.-
Nested classes/interfaces inherited from class net.bytebuddy.agent.builder.AgentBuilder.PoolStrategy.WithTypePoolCache
AgentBuilder.PoolStrategy.WithTypePoolCache.Simple
-
Nested classes/interfaces inherited from interface net.bytebuddy.agent.builder.AgentBuilder.PoolStrategy
AgentBuilder.PoolStrategy.ClassLoading, AgentBuilder.PoolStrategy.Default, AgentBuilder.PoolStrategy.Eager, AgentBuilder.PoolStrategy.WithTypePoolCache
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.ClassLoader
BOOTSTRAP_MARKER
A default value for marking the boostrap class loader.private java.util.concurrent.ConcurrentMap<? super java.lang.ClassLoader,TypePool.CacheProvider>
cacheProviders
The concurrent map that is used for storing a cache provider per class loader.-
Fields inherited from class net.bytebuddy.agent.builder.AgentBuilder.PoolStrategy.WithTypePoolCache
readerMode
-
-
Constructor Summary
Constructors Constructor Description Simple(java.util.concurrent.ConcurrentMap<? super java.lang.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, java.util.concurrent.ConcurrentMap<? super java.lang.ClassLoader,TypePool.CacheProvider> cacheProviders)
Creates a new type locator that caches a cache provider per class loader in a concurrent map.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static <T> T
doPrivileged(java.security.PrivilegedAction<T> action)
A proxy forjava.security.AccessController#doPrivileged
that is activated if available.protected java.lang.ClassLoader
getBootstrapMarkerLoader()
Returns the class loader to serve as a cache key if a cache provider for the bootstrap class loader is requested.protected TypePool.CacheProvider
locate(java.lang.ClassLoader classLoader)
Locates a cache provider for a given class loader.-
Methods inherited from class net.bytebuddy.agent.builder.AgentBuilder.PoolStrategy.WithTypePoolCache
typePool, typePool
-
-
-
-
Field Detail
-
BOOTSTRAP_MARKER
private static final java.lang.ClassLoader BOOTSTRAP_MARKER
A default value for marking the boostrap class loader.
-
cacheProviders
private final java.util.concurrent.ConcurrentMap<? super java.lang.ClassLoader,TypePool.CacheProvider> cacheProviders
The concurrent map that is used for storing a cache provider per class loader.
-
-
Constructor Detail
-
Simple
public Simple(java.util.concurrent.ConcurrentMap<? super java.lang.ClassLoader,TypePool.CacheProvider> cacheProviders)
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, java.util.concurrent.ConcurrentMap<? super java.lang.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.
-
-
Method Detail
-
doPrivileged
@Enhance private static <T> T doPrivileged(java.security.PrivilegedAction<T> action)
A proxy forjava.security.AccessController#doPrivileged
that 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
protected TypePool.CacheProvider locate(@MaybeNull java.lang.ClassLoader classLoader)
Description copied from class:AgentBuilder.PoolStrategy.WithTypePoolCache
Locates a cache provider for a given class loader.- Specified by:
locate
in classAgentBuilder.PoolStrategy.WithTypePoolCache
- Parameters:
classLoader
- The class loader for which to locate a cache. This class loader might benull
to represent the bootstrap loader.- Returns:
- The cache provider to use.
-
getBootstrapMarkerLoader
protected java.lang.ClassLoader 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
null
in the JVM which is an invalid value for manyConcurrentMap
implementations.By default, a custom class loader is created to use as a marker.
- Returns:
- A class loader to represent the bootstrap class loader.
-
-