From 28f0c4c4b042a47fc2ee3323d3b8d90329991426 Mon Sep 17 00:00:00 2001
From: Reinier Zwitserloot new String(someByteArray, "UTF-8");
declares that it can throw an UnsupportedEncodingException
but according to the JVM specification, UTF-8 must always be available. An UnsupportedEncodingException
here is about as likely as a ClassNotFoundError
when you use a String object, and you don't catch those either!
+
+ Being constrained by needlessly strict interfaces is particularly common when using lambda syntax (arg -> action
); however, lambdas cannot be annotated, which means it is not so easy to use @SneakyThrows
in combination with lambdas.
Be aware that it is impossible to catch sneakily thrown checked types directly, as javac will not let you write a catch block for an exception type that no method call in the try body declares as thrown. This problem is not relevant in either of the use cases listed above, so let this serve as a warning that you should not use the @SneakyThrows
mechanism without some deliberation!
-- cgit