APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.internal.classfile.impl

public final Class ClassHierarchyImpl

extends Object
Class Inheritance
Imports
java.io.IOException, .InputStream, .UncheckedIOException, java.lang.classfile.ClassHierarchyResolver, java.lang.classfile.constantpool.ClassEntry, java.lang.constant.ClassDesc, java.util.Collection, .HashMap, .Map, java.util.function.Function

Class hierarchy resolution framework is answering questions about classes assignability, common classes ancestor and whether the class represents an interface. All the requests are handled without class loading nor full verification, optionally with incomplete dependencies and with focus on maximum performance.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static record
public static class
public static class
public static class

Field Summary

Modifier and TypeField and Description
public static final ClassHierarchyResolver
private final ClassHierarchyResolver

Constructor Summary

AccessConstructor and Description
public
ClassHierarchyImpl(ClassHierarchyResolver
ClassHierarchyInfoResolver instance
classHierarchyResolver
)

Public constructor of ClassHierarchyImpl accepting instances of ClassHierarchyInfoResolver to resolve individual class streams.

Method Summary

Modifier and TypeMethod and Description
public ClassDesc

Returns:

common ancestor class name or null if it could not be identified
commonAncestor
(ClassDesc
first class descriptor
symbol1
,
ClassDesc
second class descriptor
symbol2
)

Method resolving common ancestor of two classes

public boolean
isAssignableFrom(ClassDesc thisClass, ClassDesc fromClass)

public boolean

Returns:

true if the given class name represents an interface
isInterface
(ClassDesc
class path in form of <package>/<class_name>.class
classDesc
)

Method answering question whether given class is an interface, responding without the class stream resolution and parsing is preferred in case the interface status is known from previous activities.

private ClassHierarchyImpl.ClassHierarchyInfoImpl
resolve(ClassDesc classDesc)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_RESOLVERback to summary
public static final ClassHierarchyResolver DEFAULT_RESOLVER
resolverback to summary
private final ClassHierarchyResolver resolver

Constructor Detail

ClassHierarchyImplback to summary
public ClassHierarchyImpl(ClassHierarchyResolver classHierarchyResolver)

Public constructor of ClassHierarchyImpl accepting instances of ClassHierarchyInfoResolver to resolve individual class streams.

Parameters
classHierarchyResolver:ClassHierarchyResolver

ClassHierarchyInfoResolver instance

Method Detail

commonAncestorback to summary
public ClassDesc commonAncestor(ClassDesc symbol1, ClassDesc symbol2)

Method resolving common ancestor of two classes

Parameters
symbol1:ClassDesc

first class descriptor

symbol2:ClassDesc

second class descriptor

Returns:ClassDesc

common ancestor class name or null if it could not be identified

isAssignableFromback to summary
public boolean isAssignableFrom(ClassDesc thisClass, ClassDesc fromClass)
isInterfaceback to summary
public boolean isInterface(ClassDesc classDesc)

Method answering question whether given class is an interface, responding without the class stream resolution and parsing is preferred in case the interface status is known from previous activities.

Parameters
classDesc:ClassDesc

class path in form of <package>/<class_name>.class

Returns:boolean

true if the given class name represents an interface

resolveback to summary
private ClassHierarchyImpl.ClassHierarchyInfoImpl resolve(ClassDesc classDesc)
jdk.internal.classfile.impl back to summary

public final Class ClassHierarchyImpl.CachedClassHierarchyResolver

extends Object
implements ClassHierarchyResolver
Class Inheritance
  • java.lang.Object
  • jdk.internal.classfile.impl.ClassHierarchyImpl.CachedClassHierarchyResolver
All Implemented Interfaces
java.lang.classfile.ClassHierarchyResolver

Field Summary

Modifier and TypeField and Description
private final Function<ClassDesc, ClassHierarchyResolver.ClassHierarchyInfo>
private static final ClassHierarchyResolver.ClassHierarchyInfo
private final Map<ClassDesc, ClassHierarchyResolver.ClassHierarchyInfo>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ClassHierarchyResolver.ClassHierarchyInfo
getClassInfo(ClassDesc classDesc)

Implements java.lang.classfile.ClassHierarchyResolver.getClassInfo.

Returns the ClassHierarchyInfo for a given class name, or null if the name is unknown to the resolver.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateFunctionback to summary
private final Function<ClassDesc, ClassHierarchyResolver.ClassHierarchyInfo> delegateFunction
NOPEback to summary
private static final ClassHierarchyResolver.ClassHierarchyInfo NOPE
resolvedCacheback to summary
private final Map<ClassDesc, ClassHierarchyResolver.ClassHierarchyInfo> resolvedCache

Constructor Detail

CachedClassHierarchyResolverback to summary
public CachedClassHierarchyResolver(ClassHierarchyResolver delegate, Map<ClassDesc, ClassHierarchyResolver.ClassHierarchyInfo> resolvedCache)

Method Detail

getClassInfoback to summary
public ClassHierarchyResolver.ClassHierarchyInfo getClassInfo(ClassDesc classDesc)

Implements java.lang.classfile.ClassHierarchyResolver.getClassInfo.

Doc from java.lang.classfile.ClassHierarchyResolver.getClassInfo.

Returns the ClassHierarchyInfo for a given class name, or null if the name is unknown to the resolver.

This method is called by the Class-File API to obtain the hierarchy information of a class or interface; users should not call this method. The symbolic descriptor passed by the Class-File API always represents a class or interface.

Annotations
@Override
jdk.internal.classfile.impl back to summary

public final Record ClassHierarchyImpl.ClassHierarchyInfoImpl

extends Record
implements ClassHierarchyInfo
Class Inheritance
All Implemented Interfaces
java.lang.classfile.ClassHierarchyResolver.ClassHierarchyInfo
Record Components
superClass:ClassDesc 
isInterface:boolean 

Field Summary

Modifier and TypeField and Description
private final boolean
isInterface

Record Component accessed by isInterface().

pack-priv static final ClassHierarchyResolver.ClassHierarchyInfo
private final ClassDesc
superClass

Record Component accessed by superClass().

Constructor Summary

AccessConstructor and Description
public
ClassHierarchyInfoImpl(ClassDesc superClass, boolean isInterface)

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public boolean
isInterface()

Record Component getter of isInterface.

public ClassDesc
superClass()

Record Component getter of superClass.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

isInterfaceback to summary
private final boolean isInterface

Record Component accessed by isInterface().

OBJECT_INFOback to summary
pack-priv static final ClassHierarchyResolver.ClassHierarchyInfo OBJECT_INFO
superClassback to summary
private final ClassDesc superClass

Record Component accessed by superClass().

Constructor Detail

ClassHierarchyInfoImplback to summary
public ClassHierarchyInfoImpl(ClassDesc superClass, boolean isInterface)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

isInterfaceback to summary
public boolean isInterface()

Record Component getter of isInterface.

superClassback to summary
public ClassDesc superClass()

Record Component getter of superClass.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

jdk.internal.classfile.impl back to summary

public final Class ClassHierarchyImpl.ClassLoadingClassHierarchyResolver

extends Object
implements ClassHierarchyResolver
Class Inheritance
  • java.lang.Object
  • jdk.internal.classfile.impl.ClassHierarchyImpl.ClassLoadingClassHierarchyResolver
All Implemented Interfaces
java.lang.classfile.ClassHierarchyResolver

Field Summary

Modifier and TypeField and Description
private final Function<ClassDesc, Class<?>>
public static final Function<ClassDesc, Class<?>>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ClassHierarchyResolver.ClassHierarchyInfo
getClassInfo(ClassDesc cd)

Implements java.lang.classfile.ClassHierarchyResolver.getClassInfo.

Returns the ClassHierarchyInfo for a given class name, or null if the name is unknown to the resolver.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classProviderback to summary
private final Function<ClassDesc, Class<?>> classProvider
SYSTEM_CLASS_PROVIDERback to summary
public static final Function<ClassDesc, Class<?>> SYSTEM_CLASS_PROVIDER

Constructor Detail

ClassLoadingClassHierarchyResolverback to summary
public ClassLoadingClassHierarchyResolver(Function<ClassDesc, Class<?>> classProvider)

Method Detail

getClassInfoback to summary
public ClassHierarchyResolver.ClassHierarchyInfo getClassInfo(ClassDesc cd)

Implements java.lang.classfile.ClassHierarchyResolver.getClassInfo.

Doc from java.lang.classfile.ClassHierarchyResolver.getClassInfo.

Returns the ClassHierarchyInfo for a given class name, or null if the name is unknown to the resolver.

This method is called by the Class-File API to obtain the hierarchy information of a class or interface; users should not call this method. The symbolic descriptor passed by the Class-File API always represents a class or interface.

Annotations
@Override
jdk.internal.classfile.impl back to summary

public final Class ClassHierarchyImpl.ResourceParsingClassHierarchyResolver

extends Object
implements ClassHierarchyResolver
Class Inheritance
  • java.lang.Object
  • jdk.internal.classfile.impl.ClassHierarchyImpl.ResourceParsingClassHierarchyResolver
All Implemented Interfaces
java.lang.classfile.ClassHierarchyResolver

Field Summary

Modifier and TypeField and Description
private final Function<ClassDesc, InputStream>
public static final Function<ClassDesc, InputStream>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ClassHierarchyResolver.ClassHierarchyInfo
getClassInfo(ClassDesc classDesc)

Implements java.lang.classfile.ClassHierarchyResolver.getClassInfo.

Returns the ClassHierarchyInfo for a given class name, or null if the name is unknown to the resolver.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

streamProviderback to summary
private final Function<ClassDesc, InputStream> streamProvider
SYSTEM_STREAM_PROVIDERback to summary
public static final Function<ClassDesc, InputStream> SYSTEM_STREAM_PROVIDER

Constructor Detail

ResourceParsingClassHierarchyResolverback to summary
public ResourceParsingClassHierarchyResolver(Function<ClassDesc, InputStream> classStreamProvider)

Method Detail

getClassInfoback to summary
public ClassHierarchyResolver.ClassHierarchyInfo getClassInfo(ClassDesc classDesc)

Implements java.lang.classfile.ClassHierarchyResolver.getClassInfo.

Doc from java.lang.classfile.ClassHierarchyResolver.getClassInfo.

Returns the ClassHierarchyInfo for a given class name, or null if the name is unknown to the resolver.

This method is called by the Class-File API to obtain the hierarchy information of a class or interface; users should not call this method. The symbolic descriptor passed by the Class-File API always represents a class or interface.

Annotations
@Override
jdk.internal.classfile.impl back to summary

public final Class ClassHierarchyImpl.StaticClassHierarchyResolver

extends Object
implements ClassHierarchyResolver
Class Inheritance
  • java.lang.Object
  • jdk.internal.classfile.impl.ClassHierarchyImpl.StaticClassHierarchyResolver
All Implemented Interfaces
java.lang.classfile.ClassHierarchyResolver

Field Summary

Modifier and TypeField and Description
private final Map<ClassDesc, ClassHierarchyResolver.ClassHierarchyInfo>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ClassHierarchyResolver.ClassHierarchyInfo
getClassInfo(ClassDesc classDesc)

Implements java.lang.classfile.ClassHierarchyResolver.getClassInfo.

Returns the ClassHierarchyInfo for a given class name, or null if the name is unknown to the resolver.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mapback to summary
private final Map<ClassDesc, ClassHierarchyResolver.ClassHierarchyInfo> map

Constructor Detail

StaticClassHierarchyResolverback to summary
public StaticClassHierarchyResolver(Collection<ClassDesc> interfaceNames, Map<ClassDesc, ClassDesc> classToSuperClass)

Method Detail

getClassInfoback to summary
public ClassHierarchyResolver.ClassHierarchyInfo getClassInfo(ClassDesc classDesc)

Implements java.lang.classfile.ClassHierarchyResolver.getClassInfo.

Doc from java.lang.classfile.ClassHierarchyResolver.getClassInfo.

Returns the ClassHierarchyInfo for a given class name, or null if the name is unknown to the resolver.

This method is called by the Class-File API to obtain the hierarchy information of a class or interface; users should not call this method. The symbolic descriptor passed by the Class-File API always represents a class or interface.

Annotations
@Override