JVM internals for Kotlin and Android developers · check

Know From source to a live object already?

One question for each of the 4 puzzles in this module. A right answer marks that puzzle as passed, so you can jump ahead. A wrong one tells you which puzzle to start with. Nothing is sent anywhere: it's saved in this browser.

Puzzle 0: Which program did you actually run?

You edit the source and run the existing class. What does its first line show?

Right. The compiler writes instructions into a class file. Running an existing class reads that earlier output.

Not quite. The launch command loads the class that already exists. Learn it in puzzle 0 →

Puzzle 1: What does a method receive?

After the addition and before the return, what is on the helper stack?

Right. Each method invocation has its own frame with locals and an operand stack.

Not quite. Addition consumes both of its inputs. Learn it in puzzle 1 →

Puzzle 2: Why do both names read eight?

Reassign the parameter before writing eight. Which value does first see?

Not quite. The caller still points at the original object. Learn it in puzzle 2 →

Right. A copied reference can still point to the same object. Reassigning one local changes only that local.

Puzzle 3: When can a counter be reclaimed?

What does the last printed eight demonstrate?

Not quite. A field read does not report collector activity. Learn it in puzzle 3 →

Right. Losing one reference leaves the object reachable while another live reference still leads to it.

Back to the overview →