Object Slots Enum
The ObjectSlotsEnum is an interface that helps ensure that object representations and access are consistent and correct. In particular, some operations in AvailObject (such as AvailObject.slot) are expected to operate on enumerations defined as inner classes within the Descriptor class for which the slot layout is specified.
Additionally, AvailObject is implemented with both object slots and integer slots in such a way that the two should not be confused; i.e., their ordinals are used as indices into either an array of AvailObject or a LongArray. A related interface IntegerSlotsEnum helps to keep these uses disjoint.
Author
Mark van Gulik
Inheritors
Properties
In Java it was possible to define this interface in such a way that the name method was abstract and implemented by each specific Enum, but Kotlin breaks this mechanism. BUT – we're able to cast this to Enum to get to that field. I believe this code gets copied down into each specific Enum subclass, so the dynamic type check for the cast is trivially eliminated in each case. And worst case, Hotspot will be able to inline calls to this from sites that are known to be Enums.
In Java it was possible to define this interface in such a way that the ordinal() method was abstract and implemented by each specific Enum, but Kotlin breaks this mechanism. BUT – we're able to cast this to Enum to get to that field. I believe this code gets copied down into each specific Enum subclass, so the dynamic type check for the cast is trivially eliminated in each case. And worst case, Hotspot will be able to inline calls to this from sites that are known to be Enums.