The comment was about adding an extra bit for color in the pointer itself—not in the object.
It's not a question about type safety, Java simply has no mechanism to make this possible (a decision which was influenced by type safety concerns).
It's not a question about type safety, Java simply has no mechanism to make this possible (a decision which was influenced by type safety concerns).
OCaml uses the low bits to encode some basic type information for the GC. Pointers have both low bits 0, integers have the lowest bit set, and sum types have the lowest bit unset and the second bit set. This means integers are 31/63 bits long and using native-sized integers carries a significant performance penalty.