Varieties of Lookup
In CHAIN OF RESPONSIBILITY, an object model takes on the job of finding which object can satisfy a client's request. This approach goes beyond the two lookup mechanisms that are built into Java: exception handling and method lookup.
When an exception is thrown, the Java interpreter looks back up the call stack to find a method called from a block enclosed in a try/catch statement. If this try/catch statement does not catch an exception of the type thrown, the Java interpreter keeps looking. This can propagate up to the main() method. If the exception is not handled there, the Java interpreter prints out an error message and stack trace and then exits.
The more common case of lookup in Java is method lookup—the algorithm for ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access