On Thu, 6 Jul 2023 20:42:34 GMT, Roger Riggs <[email protected]> wrote:
> Can you add an example showing the recommended pattern of use?
One pattern is for example when reading from a stream and closing it is highly
unlikely to generate an exception, then instead of the try block in
InputStream in = ...;
while(someCondition) {
int b = in.read();
// process b
}
try {
in.close();
} catch (IOException ignored) {
}
one could simply write
in.closeUnchecked();
and avoid the boilerplate imposed by the checked exception. This sort of code
can be found in many places in the tests in `<OpenJDK>/test/jdk`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14789#discussion_r1254910730