Posted by
Wayne Rasband-2 on
Dec 30, 2020; 6:32pm
URL: http://imagej.273.s1.nabble.com/Notification-of-File-Save-tp5024300p5024328.html
> On Dec 30, 2020, at 10:58 AM, Michael Ellis <
[hidden email]> wrote:
>
> Wayne, Thanks as always for your very prompt reply!
>
> AIUI despite the AutoCloseable interface declaring close() as throwing Exception, instantiations may specify a close() method that does not declare this Exception, even if the method has the @Override annotation!
The ImagePlus class in the ImageJ 1.53h19 daily build implements AutoCloseable, and the close() method is not declared as throwing an Exception, avoiding a lot of backward compatibility problems.
-wayne
> This seems to be corroborated in this StackOverflow posting here:
https://stackoverflow.com/a/49515309/1389877>
> It is also in my personal experience, although I am running with java 14 and so cannot be 100% this is the case with Java 8
> (though I would be surprised if it were different in Java8)
>
> If this is the case, then the try with resources pattern is an attractive and easy way to protect against memory leaks due to unclosed ImagePlus's especially when you are writing a plugin that processes lots of images.
>
> This is not high on my list of desirable Christmas presents, there are easy ways around it, but if what I write above does not have holes in it, then perhaps it would help ImageJ developers write more robust code.
>
> With best regards and thanks as always -- Michael Ellis
>
> P.S. I had to log into the web interface at
https://list.nih.gov/ as the email interface to this list appears to have stopped working.
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html