2 ms·
Is there a way to do RAII in Java? First couple of hits for "Java RAII" on Google suggest "no," but I think the HN audience might be smarter than Google about
by jimbokun 18y ago
Is there a way to do RAII in Java?
First couple of hits for "Java RAII" on Google suggest "no," but I think the HN audience might be smarter than Google about this. I just recently introduced (then found and fixed) a bug where I forgot to release a resource, and if there is an idiom that doesn't make me manually match every resource allocation with its inverse, I'd like to know about it. Looks like Java might be last to the "automated freeing of non-memory resources" party.