1010 * a {@code @throws} declaration for implementers who might want to handle or declare it voluntarily.
1111 */
1212public final class UncheckedThrow {
13-
14- private UncheckedThrow () {
15- throw new AssertionError ("UncheckedThrow is a static utility class that cannot be instantiated" );
16- }
17-
18- /**
19- * This method throws the specified checked exception, using generic type erasure to enable client
20- * methods to propagate checked exceptions without being required to declare them.
21- *
22- * @param thrown exception to be thrown
23- * @return <b>nothing</b> this method always throws the specified exception
24- */
13+
14+ private UncheckedThrow () {
15+ throw new AssertionError ("UncheckedThrow is a static utility class that cannot be instantiated" );
16+ }
17+
18+ /**
19+ * This method throws the specified checked exception, using generic type erasure to enable client
20+ * methods to propagate checked exceptions without being required to declare them.
21+ *
22+ * @param thrown exception to be thrown
23+ * @return <b>nothing</b> this method always throws the specified exception
24+ */
2525 public static RuntimeException throwUnchecked (final Throwable thrown ) {
2626 UncheckedThrow .<RuntimeException >propagate (thrown );
2727 // suppress complaint about missing return value
@@ -36,9 +36,9 @@ public static RuntimeException throwUnchecked(final Throwable thrown) {
3636 * @throws T dummy declaration to satisfy the compiler
3737 */
3838 @ SuppressWarnings ("unchecked" )
39- private static <T extends Exception > void propagate (Throwable thrown ) throws T {
39+ private static <T extends Exception > void propagate (Throwable thrown ) throws T {
4040 // Due to generic type erasure, this cast only serves to satisfy the compiler
41- // that the requirement to declare the thrown exception has been met.
41+ // that the requirement to declare the thrown exception has been met.
4242 throw (T ) thrown ;
4343 }
4444}
0 commit comments