Re: Suggestion: Should ImagePlus implement

Posted by Michael P Ellis on
URL: http://imagej.273.s1.nabble.com/Notification-of-File-Save-tp5024300p5024327.html

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!

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