try-with-resources and null resource (original) (raw)
Florian Weimer fweimer at bfk.de
Wed Jan 26 01:16:06 PST 2011
- Previous message: try-with-resources and null resource
- Next message: try-with-resources and null resource
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
- Tim Peierls:
This is a misleading analogy. The thing that a resource declaration most resembles is not try, switch, for, or synchronized, but an ordinary variable declaration with initializer.
This code doesn't throw NPE when initializing r with null: R r = get(); try { maybeUse(r); } finally { r.close(); }
But if R is a primitive type, it can throw during initialization. 8-)
-- Florian Weimer <fweimer at bfk.de> BFK edv-consulting GmbH http://www.bfk.de/ Kriegsstraße 100 tel: +49-721-96201-1 D-76133 Karlsruhe fax: +49-721-96201-99
- Previous message: try-with-resources and null resource
- Next message: try-with-resources and null resource
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]