...
This noncompliant code example throws undeclared checked exceptions. The undeclaredThrow()
method takes a Throwable
argument, and invokes a function that will throw the argument without declaring it. While undeclaredThrow()
catches any exceptions the function declares that it might throw, it nevertheless throws the argument it is given without regard to whether the argument is one of the declared exceptions. This noncompliant code example also violates rule ERR07-J. Do not throw RuntimeException, Exception, or Throwable. However, because of exception ERR08-EX0, it does not violate rule ERR08-J. Do not catch NullPointerException or any of its ancestors.
Any checked exception thrown by the default constructor of java.lang.Class.newInstance()
is propagated to the caller, even though Class.newInstance()
declares that it throws only InstantiationException
and IllegalAccessException
. This noncompliant code example demonstrates one way to use Class.newInstance()
to throw arbitrary checked and unchecked exceptions.
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="a2864196cc2df89c-67b3ec95-4d394f21-b1db8e3c-907c6626001842af327171fd"><ac:plain-text-body><![CDATA[ | [[Bloch 2008 | AA. References#Bloch 08]] | Item 2. Consider a builder when faced with many constructor parameters | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="1e4cb51984b0eac6-b3c09abb-434e4319-b6e19a6b-15d2ede4cc0125f1e114472a"><ac:plain-text-body><![CDATA[ | [[Goetz 2004b | AA. References#Goetz 04b]] |
| ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="03fca8b2a382c25c-15ef38e9-40c24fef-828bb71e-e3fb2f7508d61a1be1b6ad26"><ac:plain-text-body><![CDATA[ | [[JLS 2005 | AA. References#JLS 05]] | Chapter 11, Exceptions | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="52ce7e85f81b25c9-45b6cb5b-44d04857-9826afd6-d25119231e263fe82c2bcf89"><ac:plain-text-body><![CDATA[ | [[Roubtsov 2003 | AA. References#Roubtsov 03]] |
| ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="6ce5e7b2294acdc1-9edba446-40954778-8fdab0c1-3e472f37e082c5b68bf0f8ed"><ac:plain-text-body><![CDATA[ | [[Schwarz 2004 | AA. References#Schwarz 04]] |
| ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="8bfafba1d5f8cfdd-9fc71bb7-4a3a4118-a6d2a92c-18d6d7c54fb3fb8f3e64b8be"><ac:plain-text-body><![CDATA[ | [[Venners 2003 | AA. References#Venners 03]] | Scalability of Checked Exceptions | ]]></ac:plain-text-body></ac:structured-macro> |
...