Class TypeInterning
- java.lang.Object
-
- org.jboss.jandex.TypeInterning
-
class TypeInterning extends java.lang.Object
Certain Jandex classes have to implement special equality/hash code for the purpose of interning. Those classes have, in addition to the usualequals
/hashCode
methods, also methods calledinternEquals
/internHashCode
. This directly applies to theType
hierarchy. If the equality/hash code is structural, it is likely that types which use these special types should themselves also be special (if they are subject to the interning process, of course). This applies toMethodInternal
,FieldInternal
andRecordComponentInternal
.The reason why the
Type
hierarchy needs a different equality and hash code for interning is type variable references. To maintain structural equality/hash code for external users (that is, the commonequals
andhashCode
methods), type variable references equality/hash code must only consider the type variable name (and annotations). This is not suitable for the interning purpose, because two type variable references may have the same name and annotations, yet point to different type variables (e.g. because those type variables have different annotations).We could possibly implement a "deep" structural equality and hash code for type variable references that would take into account the type variable the reference points to, but that still wouldn't be enough. When interning, types must be interned "from the inside", which means that when a type variable reference is being interned, the "target" type variable is not interned yet (possibly even not yet set) and can change later. This is one of the reasons why type variable references are mutable, and that in turn requires that their equality and hash code for interning purposes are based on identity.
Note that type variable references are only mutated during indexing. After an
Index
is complete, type variable references must be considered "frozen".
-
-
Constructor Summary
Constructors Constructor Description TypeInterning()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static boolean
arrayEquals(Type[] a, Type[] b)
(package private) static int
arrayHashCode(Type[] array)
-