RFR: 8274881: Update jdk.compiler classes to use try-with-resources

Joe Darcy darcy at openjdk.java.net
Fri Oct 15 22:32:53 UTC 2021


On Tue, 12 Oct 2021 08:12:13 GMT, Andrey Turbanov <duke at openjdk.java.net> wrote:

>> src/jdk.compiler/share/classes/com/sun/tools/javac/util/ByteBuffer.java line 172:
>> 
>>> 170:                  * should be reported.
>>> 171:                  */
>>> 172:             }
>> 
>> The exception behavior seems like it could differ, which may or may not be an issue.
>
> Yes. Behavior is changed for the case, when we read InputStream up the end _without_ any exception and then get Exception during _close_ call.
> But I think it still worth changing:
> 1. Code is shorter and cleaner
> 2. Such case is very rare, when only `InputStream.close` throw exception, but `InputStream.read` did not
> 3. Swallowing exceptions, even during `close()` call, is a bad code smell.

Someone more familiar with the consequences of changing the exception behavior than I am will need to comment here.

-------------

PR: https://git.openjdk.java.net/jdk/pull/5816


More information about the compiler-dev mailing list