Class ResolutionCache


  • public class ResolutionCache
    extends Object
    Concurrent memoization cache for class, method, field, and assignability lookups.
    • Constructor Detail

      • ResolutionCache

        public ResolutionCache()
    • Method Detail

      • getClass

        public ClassFile getClass​(String name,
                                  Supplier<ClassFile> loader)
        Returns the cached class, loading and caching it on a miss.
        Parameters:
        name - cache key
        loader - supplier invoked on a miss
        Returns:
        the cached or newly loaded class file
      • getMethod

        public ResolvedMethod getMethod​(String key,
                                        Supplier<ResolvedMethod> resolver)
        Returns the cached method resolution, resolving and caching it on a miss.
        Parameters:
        key - cache key
        resolver - supplier invoked on a miss
        Returns:
        the cached or newly resolved method
      • getField

        public ResolvedField getField​(String key,
                                      Supplier<ResolvedField> resolver)
        Returns the cached field resolution, resolving and caching it on a miss.
        Parameters:
        key - cache key
        resolver - supplier invoked on a miss
        Returns:
        the cached or newly resolved field
      • getAssignability

        public Boolean getAssignability​(String key,
                                        Supplier<Boolean> computer)
        Returns the cached assignability verdict, computing and caching it on a miss.
        Parameters:
        key - cache key
        computer - supplier invoked on a miss
        Returns:
        the cached or newly computed verdict
      • clear

        public void clear()
        Empties all four caches.
      • size

        public int size()
        Returns:
        the total number of entries across all caches