Skip to content

Hash Code

Jeff Disher edited this page Aug 16, 2019 · 1 revision

As the identity hash code of an object instance is a point of nondeterminism within the standard JVM, this is something which needs to be redefined for the AVM.

In the AVM, the identity hash code of an object is an incrementing counter. It is a standard 4-byte signed Java int, meaning that it is does overflow and wrap back into negative after 2^31-1.

Life Cycle

Special Cases

Consequences

  • The first objects allocated by a contract are its constants, including Enum constants defined within their code. These are given identity hash codes which cannot overflow (as deployment energy limits cannot allocate 4 billion Objects, definitely not 4 billion Enum constants). As a consequence, these initial constants will have identity hash codes which cannot collide with each other.
Clone this wiki locally