Class TypeInterning
- java.lang.Object
-
- org.jboss.jandex.TypeInterning
-
class TypeInterning extends java.lang.ObjectCertain Jandex classes have to implement special equality/hash code for the purpose of interning. Those classes have, in addition to the usualequals/hashCodemethods, also methods calledinternEquals/internHashCode. This directly applies to theTypehierarchy. 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,FieldInternalandRecordComponentInternal.The reason why the
Typehierarchy 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 commonequalsandhashCodemethods), 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
Indexis 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 booleanarrayEquals(Type[] a, Type[] b)(package private) static intarrayHashCode(Type[] array)
-