RFR: 8277585: Remove the terminally deprecated finalize() method from javax.imageio.stream APIs [v2]
Alisen Chung
achung at openjdk.org
Wed Aug 6 22:02:15 UTC 2025
On Wed, 6 Aug 2025 19:41:41 GMT, Phil Race <prr at openjdk.org> wrote:
>> This PR removes javax/imageio/stream/ImageInputStreamImpl.finalize()
>> As a result, sub-classes which over-ride it to be empty no longer need to do so.
>> Also it means that the 2 remaining classes which used it no longer can.
>> FileCacheImageOutputStream will have its cache cleaned up by a disposer.
>> The impact on applications is that they, or the ImageWriter may need to call flush() IF they relied on finalization.
>> However that should be extremely unlikely given that finalization will happen far too late in most cases, and is
>> really meant to clean up internal resources.
>> The JDK's GIF and TIFF image writers don't flush themselves, so applications which use these together with one of these caching streams would have learned this already.
>>
>> The principal outside risk is to 3rd party ImageIO stream subclasses which both allocate native resources and rely on finalization as a backstop clean up in case applications forget to call close. But it will be the applications that are affected if the resource is depleted.
>> The risks of this will be covered in the CSR.
>>
>> There's also a lengthy write up in the JBS issue.
>
> Phil Race has updated the pull request incrementally with one additional commit since the last revision:
>
> 8277585
src/java.desktop/share/classes/javax/imageio/stream/package-info.java line 60:
> 58: * {@snippet lang='java':
> 59: * try (FileOutputStream fos = new FileOutputStream("out.jpg");
> 60: * (ImageOutputStream ios = new FileCacheImageOutputStream(fos, null)) {
I think there is an extra left parenthesis here at the start of the line
src/java.desktop/share/classes/javax/imageio/stream/package-info.java line 66:
> 64: * }
> 65: * <p>
> 66: * Sub-classers of these Image I/O API stream types can to a limited extent protect
Commas missing here
`Sub-classers of these Image I/O API stream types can, to a limited extent, protect`
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26650#discussion_r2258402538
PR Review Comment: https://git.openjdk.org/jdk/pull/26650#discussion_r2258404716
More information about the client-libs-dev
mailing list