Various improvements to the javac implementation of the try-with-resources desugaring have been suggested:
1) Generate a per-class helper method to encapsulate the if-primary-exception not-null... logic of the synthesized finally block. (Unfortunately, such code cannot be shared in a common library method because the more precise exception information cannot be captured in the method's signature.)
2) From coin-dev ( http://mail.openjdk.java.net/pipermail/coin-dev/2011-February/003079.html ), omit the null-check on a resource if the resource is initialized with a constructor call since constructors cannot return null.
These should be considered in the future.