I've wondered about, will Java EE 7's core interfaces extends AutoCloseable
or not. (By core interfaces I primarily mean EntityManager
and the likes, however I don't know for sure if there are other interfaces or classes that could potentially be closed automatically.)
I think they should and here is the basis of my assumption.
Java 6's Connection
doesn't even extend Closeable
, however Java 7's Connection
extends AutoCloseable
(just like several other interfaces in the java.sql package).
Can interfaces like EntityManager
extend AutoCloseable
in way that it would serve us well, given Java 7's try-with-resources
statement? Or closing an EntityManager
auto-magically is far too complicated?
Is this particular feature considered to be a part of JSR-342?