Rules

The JVM has to enforce certain rules to keep the new types of memory from breaking the garbage collector's commitment not to leave bad pointers. The underlying rule is that a reference variable cannot contain a reference to an object that can be freed before the reference variable. This rule is enforced by the JVM. Table 13-1 summarizes the assignment rules.

Table 13-1. Assignment rules
 Reference to Heap Reference to Immortal Reference to Scoped
Heap Yes Yes No
Immortal Yes Yes No
Scoped Yes Yes “Available” scopes
Local variable Yes Yes “Available” scopes

If it must, the JVM can enforce the assignment rules when it executes the bytecode instructions that store object references, but since that enforcement slows execution of the JVM, a ...

Get Real-Time Java™ Platform Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.