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.
  • Field Details

  • Constructor Details

    • Simple

      public Simple(ConcurrentMap<? super 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 fast TypePool.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.
  • Method Details

    • locate

      protected TypePool.CacheProvider locate(@MaybeNull ClassLoader classLoader)
      Description copied from class: AgentBuilder.PoolStrategy.WithTypePoolCache
      Locates a cache provider for a given class loader.
      Specified by:
      locate in class AgentBuilder.PoolStrategy.WithTypePoolCache
      Parameters:
      classLoader - The class loader for which to locate a cache. This class loader might be null to represent the bootstrap loader.
      Returns:
      The cache provider to use.
    • getBootstrapMarkerLoader

      protected 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 many ConcurrentMap implementations.

      By default, ClassLoader.getSystemClassLoader() is used as such a key as any resource location for the bootstrap class loader is performed via the system class loader within Byte Buddy as null cannot be queried for resources via method calls such that this does not make a difference.

      Returns:
      A class loader to represent the bootstrap class loader.