From 789f358c095a0dd26e6f4dd52ad9d63ca66d1151 Mon Sep 17 00:00:00 2001
From: Reinier Zwitserloot
Because @SneakyThrows
is an implementation detail and not part of your method signature, it is an error if you try to
declare a checked exception as sneakily thrown when you don't call any methods that throw this exception. (Doing so is perfectly legal
- for throws
statements to accomodate subclasses). Similarly, @SneakyThrows
does not inherit.
+ for throws
statements to accommodate subclasses). Similarly, @SneakyThrows
does not inherit.
For the nay-sayers in the crowd: Out of the box, Eclipse will offer a 'quick-fix' for uncaught exceptions that wraps the offending
statement in a try/catch block with just e.printStackTrace()
in the catch block. This is so spectacularly non-productive
compared to just sneakily throwing the exception onwards, that Roel and Reinier feel more than justified in claiming that the
checked exception system is far from perfect, and thus an opt-out mechanism is warranted.
-
- Currently usage of @SneakyThrows
requires you to have lombok.jar
in the classpath at runtime. However, in the future
- we will attempt to eliminate this requirement - when we figure out how we can do that. If anyone has a good idea on how to make that happen, let us know!