I have already talked about the new features to support multi-catch in an earlier post. Now I will talk about Try-with-resources statement and Simplified Varargs Method Invocation.
The compiler detects unhandled exceptions thrown by automatic/implicit close() invocation on a resource.
With Mark Occurrences enabled, the closing '}' of a try-with-resources statement is marked as a method exit point if the implicit close() invocation throws an exception. The corresponding resource variable is also highlighted.
Future items: In 3.8 we plan to add warnings to indicate that a resource is not closed, see bug 349326. In Java 7 a resource is a subtype of java.lang.AutoCloseable and in the pre-Java 7 world a resource is a subtype of java.io.Closeable. Based on these warnings we will also provide quick fixes/assists and clean-ups to enclose a resource in a try-with-resources statement, see bug 349390.
A new quick fix Add @SafeVarargs is offered for potential heap pollution warnings on method declarations.
Add @SafeVarargs quick fix is also offered from call sites.
Remove @SafeVarargs quick fix is offered for incorrect usage of @SafeVarargs annotation.
Note: This is an implementation of an early-draft specification
developed under the Java Community Process (JCP) and is made available
for testing and evaluation purposes only. The code is not compatible
with any specification of the JCP.
No comments:
Post a Comment