Chapter 4. Object Lifecycle

“'Forty-two,' said Deep Thought, with infinite majesty and calm.”

Douglas Adams, The Hitchhiker's Guide to the Galaxy, 1979

This chapter discusses the lifecycle of objects and the reasons why state changes can be meaningful to the application developer.

Why are object lifecycles and state transitions important to know? Imagine what happens inside of a JVM whenever “new” is called by an application: A small portion of memory needs to be allocated and a reference is returned to the application, but the world is more complex behind the scenes. First, the JVM might load the byte code from some resource and then compile the byte code to native machine instructions. Then static initialization takes place, the base classes ...

Get Core Java™ Data Objects 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.