JDK-7027157 : Project Coin: javac warnings for AutoCloseable.close throwing InterruptedException
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2011-03-14
  • Updated: 2016-04-29
  • Resolved: 2011-05-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b138Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
The JSR 334 expert group has decided that it is probably a programming error is an AutoCloseable.close method throws InterruptedException since InterruptedException interacts with a thread's interrupted status.  A suppressed InterruptedException is likely to lead to misbehavior at runtime.

To catch such conceptual mistakes, it would be helpful is javac warned about structures like "public void close throws InterruptedException {...}"

Comments
SUGGESTED FIX A webrev of this fix is available at the following URL: http://hg.openjdk.java.net/jdk7/tl/langtools/rev/de1c65ecfec2
29-03-2011

EVALUATION We need Xlint:try warnings at both declaration site and use site. *) Declaration-site: class MyRes implements AutoCloseable { void close throws InterruptedException { ... } //warning here - close method throwing IE } *) Use-site try (MyRes mr = new MyRes()) { ... } //warning here - using a TWR resource whose close() throws IE
21-03-2011