Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Wiki Markup
            Programs must not catch {{java.lang.NullPointerException}}. A {{NullPointerException}} exception thrown at runtime indicates the existence of an underlying {{null}} pointer dereference that must be fixed in the application code (see [EXP11-J. Never dereference null pointers|EXP08EXP01-J. Never dereference null pointers]). Handling the underlying null pointer dereference by catching the {{NullPointerException}} rather than fixing the underlying problem is inappropriate for several reasons. First, _avoiding_ the exception by catching {{NullPointerException}} adds significantly more performance overhead than simply adding the necessary checks \[[Bloch 2008|AA. Bibliography#Bloch 08]\]. Second, when there are multiple expressions in a {{try}} block that are capable of throwing a {{NullPointerException}}, it is difficult or impossible to determine which expression is responsible for the exception because the {{NullPointerException}} {{catch}} block handles any {{NullPointerException}} thrown from any location in the {{try}} block. Third, programs rarely remain in an expected and usable state after a {{NullPointerException}} has been thrown. Attempts to continue execution after first catching and logging (or worse, suppressing) the exception rarely succeed.

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="6d29811f7d74a944-c6cfb2d6-41c84da7-b4f1aaa9-bddab6455c5522f39d9867d6"><ac:plain-text-body><![CDATA[

[[Cunningham 1995

AA. Bibliography#Cunningham 95]]

 

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="52f90dcc5489c06b-e14f460e-4fe046f8-9eb0987d-7bbe2394db1cfd1b85d8e0e6"><ac:plain-text-body><![CDATA[

[[Doshi 2003

AA. Bibliography#Doshi 03]]

 

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="5d8a75fcce41070e-d4e5206a-41c9407d-a64d836a-c28a3bcca60d72eab8eb6b0a"><ac:plain-text-body><![CDATA[

[[Grand 2002

AA. Bibliography#Grand 02]]

Chapter 8, Behavioral patterns, the Null Object

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="395a353d342093d3-f0f72341-44cd4c47-9c7c9699-8f3935617b08b61ee745b84d"><ac:plain-text-body><![CDATA[

[[Henney 2003

AA. Bibliography#Henney 03]]

 

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="748c038761109151-fdc93f79-45684b16-99349ae0-45dff7d7dc89bc3e4a4d1411"><ac:plain-text-body><![CDATA[

[[JLS 2005

AA. Bibliography#JLS 05]]

[Chapter 11, Exceptions

http://java.sun.com/docs/books/jls/third_edition/html/exceptions.html]

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="28f87d34a0c59775-106242b5-41984314-8fdcacd9-d2141c6b3236bbe24fd7ad92"><ac:plain-text-body><![CDATA[

[[J2SE 2011

AA. Bibliography#J2SE 11]]

Catching Multiple Exception Types and Rethrowing Exceptions with Improved Type Checking

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="fca08cb9f9ede7d7-6c9c51cf-4ce5411d-a224917d-b23ba2668821c539ca881264"><ac:plain-text-body><![CDATA[

[[Müller 2002

AA. Bibliography#Müller 02]]

 

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="b6c1472604b390e2-f96446f2-436d4d04-8443811a-cc256dc2c35af4b238012da6"><ac:plain-text-body><![CDATA[

[[Schweisguth 2003

AA. Bibliography#Schweisguth 03]]

 

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="1fc0790ab988b60b-d64dad30-457a44d0-b291b86f-2f36bd1a7377ad884cdd1924"><ac:plain-text-body><![CDATA[

[[Tutorials 2008

AA. Bibliography#Tutorials 08]]

[Exceptions

http://java.sun.com/docs/books/tutorial/essential/exceptions/index.html]

]]></ac:plain-text-body></ac:structured-macro>

...