Class TypePool.Default.WithLazyResolution

All Implemented Interfaces:
TypePool
Enclosing class:
TypePool.Default

@Enhance public static class TypePool.Default.WithLazyResolution extends TypePool.Default

A variant of TypePool.Default that resolves type descriptions lazily. A lazy resolution respects this type pool's TypePool.CacheProvider but requeries this cache pool for every access of a property of a TypeDescription.

TypePool.Resolutions of this type pool are only fully resolved if a property that is not the type's name is required.

  • Field Details

  • Constructor Details

    • WithLazyResolution

      public WithLazyResolution(TypePool.CacheProvider cacheProvider, ClassFileLocator classFileLocator, TypePool.Default.ReaderMode readerMode)
      Creates a new default type pool with lazy resolution and without a parent pool.
      Parameters:
      cacheProvider - The cache provider to be used.
      classFileLocator - The class file locator to be used.
      readerMode - The reader mode to apply by this default type pool.
    • WithLazyResolution

      public WithLazyResolution(TypePool.CacheProvider cacheProvider, ClassFileLocator classFileLocator, TypePool.Default.ReaderMode readerMode, TypePool parentPool)
      Creates a new default type pool with lazy resolution.
      Parameters:
      cacheProvider - The cache provider to be used.
      classFileLocator - The class file locator to be used.
      readerMode - The reader mode to apply by this default type pool.
      parentPool - The parent type pool.
    • WithLazyResolution

      public WithLazyResolution(TypePool.CacheProvider cacheProvider, ClassFileLocator classFileLocator, TypePool.Default.ReaderMode readerMode, AsmClassReader.Factory classReaderFactory)
      Creates a new default type pool that uses an explicit class reader factory with lazy resolution.
      Parameters:
      cacheProvider - The cache provider to be used.
      classFileLocator - The class file locator to be used.
      readerMode - The reader mode to apply by this default type pool.
      classReaderFactory - The class reader factory to use.
    • WithLazyResolution

      public WithLazyResolution(TypePool.CacheProvider cacheProvider, ClassFileLocator classFileLocator, TypePool.Default.ReaderMode readerMode, AsmClassReader.Factory classReaderFactory, TypePool parentPool)
      Creates a new default type pool that uses an explicit class reader factory with lazy resolution.
      Parameters:
      cacheProvider - The cache provider to be used.
      classFileLocator - The class file locator to be used.
      readerMode - The reader mode to apply by this default type pool.
      classReaderFactory - The class reader factory to use.
      parentPool - The parent type pool.
    • WithLazyResolution

      public WithLazyResolution(TypePool.CacheProvider cacheProvider, ClassFileLocator classFileLocator, TypePool.Default.ReaderMode readerMode, TypePool.Default.WithLazyResolution.LazinessMode lazinessMode)
      Creates a new default type pool with lazy resolution and without a parent pool.
      Parameters:
      cacheProvider - The cache provider to be used.
      classFileLocator - The class file locator to be used.
      readerMode - The reader mode to apply by this default type pool.
      lazinessMode - The mode of lazy resolution.
    • WithLazyResolution

      public WithLazyResolution(TypePool.CacheProvider cacheProvider, ClassFileLocator classFileLocator, TypePool.Default.ReaderMode readerMode, TypePool parentPool, TypePool.Default.WithLazyResolution.LazinessMode lazinessMode)
      Creates a new default type pool with lazy resolution.
      Parameters:
      cacheProvider - The cache provider to be used.
      classFileLocator - The class file locator to be used.
      readerMode - The reader mode to apply by this default type pool.
      parentPool - The parent type pool.
      lazinessMode - The mode of lazy resolution.
    • WithLazyResolution

      public WithLazyResolution(TypePool.CacheProvider cacheProvider, ClassFileLocator classFileLocator, TypePool.Default.ReaderMode readerMode, AsmClassReader.Factory classReaderFactory, TypePool.Default.WithLazyResolution.LazinessMode lazinessMode)
      Creates a new default type pool that uses an explicit class reader factory with lazy resolution.
      Parameters:
      cacheProvider - The cache provider to be used.
      classFileLocator - The class file locator to be used.
      readerMode - The reader mode to apply by this default type pool.
      classReaderFactory - The class reader factory to use.
      lazinessMode - The mode of lazy resolution.
    • WithLazyResolution

      public WithLazyResolution(TypePool.CacheProvider cacheProvider, ClassFileLocator classFileLocator, TypePool.Default.ReaderMode readerMode, AsmClassReader.Factory classReaderFactory, TypePool parentPool, TypePool.Default.WithLazyResolution.LazinessMode lazinessMode)
      Creates a new default type pool that uses an explicit class reader factory with lazy resolution.
      Parameters:
      cacheProvider - The cache provider to be used.
      classFileLocator - The class file locator to be used.
      readerMode - The reader mode to apply by this default type pool.
      classReaderFactory - The class reader factory to use.
      parentPool - The parent type pool.
      lazinessMode - The mode of lazy resolution.
  • Method Details

    • ofSystemLoader

      public static TypePool ofSystemLoader()
      Creates a default TypePool with lazy resolution that looks up data by querying the system class loader. The returned instance is configured to use a fast reading mode and a simple cache.
      Returns:
      A type pool that reads its data from the system class loader.
    • ofPlatformLoader

      public static TypePool ofPlatformLoader()
      Creates a default TypePool with lazy resolution that looks up data by querying the platform class loader. The returned instance is configured to use a fast reading mode and a simple cache. If the current VM is Java 8 or older, the type pool represents the extension class loader.
      Returns:
      A type pool that reads its data from the boot class loader.
    • ofBootLoader

      public static TypePool ofBootLoader()
      Creates a default TypePool with lazy resolution that looks up data by querying the boot class loader. The returned instance is configured to use a fast reading mode and a simple cache.
      Returns:
      A type pool that reads its data from the boot class loader.
    • of

      public static TypePool of(@MaybeNull ClassLoader classLoader)
      Returns a default TypePool with lazy resolution for the provided class loader.
      Parameters:
      classLoader - The class loader for which this class pool is representing types.
      Returns:
      An appropriate type pool.
    • of

      public static TypePool of(ClassFileLocator classFileLocator)
      Creates a default TypePool with lazy resolution that looks up data by querying the supplied class file locator. The returned instance is configured to use a fast reading mode and a simple cache.
      Parameters:
      classFileLocator - The class file locator to use.
      Returns:
      A type pool that reads its data from the system class path.
    • doDescribe

      protected TypePool.Resolution doDescribe(String name)
      Description copied from class: TypePool.AbstractBase
      Determines a resolution to a non-primitive, non-array type.
      Overrides:
      doDescribe in class TypePool.Default
      Parameters:
      name - The name of the type to describe.
      Returns:
      A resolution to the type to describe.
    • doParse

      protected TypeDescription doParse(AsmClassReader classReader)
      Description copied from class: TypePool.Default
      Parses the supplied binary representation and returns a corresponding type description.
      Overrides:
      doParse in class TypePool.Default
      Parameters:
      classReader - The ASM class reader to process.
      Returns:
      An appropriate type description.
    • doCache

      protected TypePool.Resolution doCache(String name, TypePool.Resolution resolution)
      Description copied from class: TypePool.AbstractBase
      Writes the resolution to the cache. This method should be overridden if the directly resolved instance should not be added to the cache.
      Overrides:
      doCache in class TypePool.AbstractBase
      Parameters:
      name - The name of the type.
      resolution - The resolution for this type.
      Returns:
      The actual resolution for the type of this name that is stored in the cache.
    • doResolve

      protected TypePool.Resolution doResolve(String name)
      Non-lazily resolves a type name.
      Parameters:
      name - The name of the type to resolve.
      Returns:
      The resolution for the type of this name.