There is a per-object flag (a bit in the object header) that if set prevents modification.
The bit is controlled by
Object>>#setIsReadOnlyObject:
with
Object>>#beReadOnlyObject
as a convenience.
Object>>#beReadOnlyObject
is the getter. By default the bit is off (new objects are mutable).
The Compiler modification sets the bit for method literals (literal strings, symbols, arrays, byte arrays and boxed floats). The facility may also be used for
- an object-to-database mapping system
- debugging
etc