Interface ClassHierarchyResolver

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ClassHierarchyResolver
Provides class hierarchy information for generating correct stack maps during code building.
Since:
24
  • Method Details

    • defaultResolver

      static ClassHierarchyResolver defaultResolver()
      Returns the default instance of ClassHierarchyResolver that gets ClassHierarchyResolver.ClassHierarchyInfo from system class loader with reflection.
      Returns:
      the default instance of ClassHierarchyResolver that gets ClassHierarchyResolver.ClassHierarchyInfo from system class loader with reflection
    • getClassInfo

      Returns the ClassHierarchyResolver.ClassHierarchyInfo for a given class name, or null if the name is unknown to the resolver.
      Parameters:
      classDesc - descriptor of the class
      Returns:
      the ClassHierarchyResolver.ClassHierarchyInfo for a given class name, or null if the name is unknown to the resolver
      Throws:
      IllegalArgumentException - if a class shouldn't be queried for hierarchy
    • orElse

      Chains this ClassHierarchyResolver with another to be consulted if this resolver does not know about the specified class.
      Implementation Requirements:
      The default implementation returns resolver implemented to ask other resolver in cases where this resolver returns null.
      Parameters:
      other - the other resolver
      Returns:
      the chained resolver
    • cached

      Returns a ClassHierarchyResolver that caches class hierarchy information from this resolver. The returned resolver will not update if delegate resolver returns differently. The thread safety of the returned resolver depends on the thread safety of the map returned by the cacheFactory.
      Implementation Requirements:
      The default implementation returns resolver holding an instance of the cache map provided by the cacheFactory. It asks the cache map always first and fills the cache map with all resolved and also unresolved class info. The cache map may refuse null keys and values.
      Parameters:
      cacheFactory - the factory for the cache
      Returns:
      the ClassHierarchyResolver with caching
    • cached

      default ClassHierarchyResolver cached()
      Returns a ClassHierarchyResolver that caches class hierarchy information from this resolver. The returned resolver will not update if delegate resolver returns differently. The returned resolver is not thread-safe.
      MethodHandles.Lookup lookup = ...;
      ClassHierarchyResolver resolver = ClassHierarchyResolver.ofClassLoading(lookup).cached();
      
      Implementation Requirements:
      The default implementation calls cached(Supplier) with HashMap supplier as cacheFactory.
      Returns:
      the ClassHierarchyResolver
    • ofResourceParsing

      static ClassHierarchyResolver ofResourceParsing(Function<ClassDesc, InputStream> classStreamResolver)
      Returns a ClassHierarchyResolver that extracts class hierarchy information from classfiles located by a mapping function. The mapping function should return null if it cannot provide a mapping for a classfile. Any IOException from the provided input stream is rethrown as an UncheckedIOException.
      Parameters:
      classStreamResolver - maps class descriptors to classfile input streams
      Returns:
      the ClassHierarchyResolver
    • ofResourceParsing

      static ClassHierarchyResolver ofResourceParsing(ClassLoader loader)
      Returns a ClassHierarchyResolver that extracts class hierarchy information from classfiles located by a class loader.
      Parameters:
      loader - the class loader, to find class files
      Returns:
      the ClassHierarchyResolver
    • of

      static ClassHierarchyResolver of(Collection<ClassDesc> interfaces, Map<ClassDesc, ClassDesc> classToSuperClass)
      Returns a ClassHierarchyResolver that extracts class hierarchy information from collections of class hierarchy metadata
      Parameters:
      interfaces - a collection of classes known to be interfaces
      classToSuperClass - a map from classes to their super classes
      Returns:
      the ClassHierarchyResolver
    • ofClassLoading

      static ClassHierarchyResolver ofClassLoading(ClassLoader loader)
      Returns a ClassHierarchyResolver that extracts class hierarchy information via the Reflection API with a ClassLoader.
      Parameters:
      loader - the class loader
      Returns:
      the class hierarchy resolver
    • ofClassLoading

      static ClassHierarchyResolver ofClassLoading(MethodHandles.Lookup lookup)
      Returns a ClassHierarchyResolver that extracts class hierarchy information via the Reflection API with a Lookup. If the class resolved is inaccessible to the given lookup, it throws IllegalArgumentException instead of returning null.
      Parameters:
      lookup - the lookup, must be able to access classes to resolve
      Returns:
      the class hierarchy resolver