- All Known Implementing Classes:
ClassHierarchyImpl.CachedClassHierarchyResolver,ClassHierarchyImpl.ClassLoadingClassHierarchyResolver,ClassHierarchyImpl.ResourceParsingClassHierarchyResolver,ClassHierarchyImpl.StaticClassHierarchyResolver
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Provides class hierarchy information for generating correct stack maps
during code building.
- Since:
- 22
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceInformation about a resolved class. -
Method Summary
Modifier and TypeMethodDescriptiondefault ClassHierarchyResolvercached()Returns a ClassHierarchyResolver that caches class hierarchy information from this resolver.default ClassHierarchyResolvercached(Supplier<Map<ClassDesc, ClassHierarchyResolver.ClassHierarchyInfo>> cacheFactory) Returns a ClassHierarchyResolver that caches class hierarchy information from this resolver.static ClassHierarchyResolverReturns the default instance of ClassHierarchyResolver that getsClassHierarchyResolver.ClassHierarchyInfofrom system class loader with reflection.getClassInfo(ClassDesc classDesc) Returns theClassHierarchyResolver.ClassHierarchyInfofor a given class name, or null if the name is unknown to the resolver.static ClassHierarchyResolverReturns a ClassHierarchyResolver that extracts class hierarchy information from collections of class hierarchy metadatastatic ClassHierarchyResolverofClassLoading(ClassLoader loader) Returns a ClassHierarchyResolver that extracts class hierarchy information via the Reflection API with a ClassLoader.static ClassHierarchyResolverofClassLoading(MethodHandles.Lookup lookup) Returns a ClassHierarchyResolver that extracts class hierarchy information via the Reflection API with a Lookup.static ClassHierarchyResolverofResourceParsing(ClassLoader loader) Returns a ClassHierarchyResolver that extracts class hierarchy information from classfiles located by a class loader.static ClassHierarchyResolverofResourceParsing(Function<ClassDesc, InputStream> classStreamResolver) Returns a ClassHierarchyResolver that extracts class hierarchy information from classfiles located by a mapping function.default ClassHierarchyResolverorElse(ClassHierarchyResolver other) Chains this ClassHierarchyResolver with another to be consulted if this resolver does not know about the specified class.
-
Method Details
-
defaultResolver
Returns the default instance of ClassHierarchyResolver that getsClassHierarchyResolver.ClassHierarchyInfofrom system class loader with reflection.- Returns:
- the default instance of ClassHierarchyResolver that
gets
ClassHierarchyResolver.ClassHierarchyInfofrom system class loader with reflection
-
getClassInfo
Returns theClassHierarchyResolver.ClassHierarchyInfofor a given class name, or null if the name is unknown to the resolver.- Parameters:
classDesc- descriptor of the class- Returns:
- the
ClassHierarchyResolver.ClassHierarchyInfofor 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.- Parameters:
other- the other resolver- Returns:
- the chained resolver
- ImplSpec:
- The default implementation returns resolver implemented to ask
other resolver in cases where this resolver returns
null.
-
cached
default ClassHierarchyResolver cached(Supplier<Map<ClassDesc, ClassHierarchyResolver.ClassHierarchyInfo>> cacheFactory) 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 thecacheFactory.- Parameters:
cacheFactory- the factory for the cache- Returns:
- the ClassHierarchyResolver with caching
- ImplSpec:
- 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 refusenullkeys and values.
-
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();- Returns:
- the ClassHierarchyResolver
- ImplSpec:
- The default implementation calls
cached(Supplier)withHashMapsupplier ascacheFactory.
-
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
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 interfacesclassToSuperClass- a map from classes to their super classes- Returns:
- the ClassHierarchyResolver
-
ofClassLoading
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
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 throwsIllegalArgumentExceptioninstead of returningnull.- Parameters:
lookup- the lookup, must be able to access classes to resolve- Returns:
- the class hierarchy resolver
-