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|EXP11EXP08-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="a37c5fe009b8b789-e51a0453-4d0b4311-97289cac-c262fbb98ac85c8d2ef2c5de"><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="8d569afcf8144464-0542ddcd-48f94223-aecbadc1-1743ac45148ce8a5ff156bfe"><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="4050839867028a92-87fe51d8-433740cb-9d8ba4d0-59458441b26d43cc2799d17a"><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="600f2a436ec47605-e4ee2500-4c1544eb-9a008fe9-dbace597d5388ad4a406691d"><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="ae196ba75957b213-68892c5f-40a84652-ae458790-2712eccd2b2941d97aa1e79f"><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="fa6bb76346276d35-7087b71f-42124976-9ecb87b5-9922fef00688b2e8a0efa42b"><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="e5c8139745f55d5a-2e1a51d3-428b434b-84dfb645-151dac937cfba016b801db15"><ac:plain-text-body><![CDATA[ | [[Muller 2002 | AA. Bibliography#Muller 02]] |
| ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="9f46fb3bbec8bf74-2883dbf4-47a64b90-af42ab15-80c12aad073e5d27ac33e5ce"><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="1132c2c7ff322c6e-a472bad3-4ff94f21-b0879c0e-3f8c66ee29418e3c19d18c6f"><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> |
...