Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 350279 - [1.7] Compiler warning for overriding methods of AutoCloseable#close() that throw InterruptedException
Summary: [1.7] Compiler warning for overriding methods of AutoCloseable#close() that t...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P5 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2011-06-24 10:49 EDT by Markus Keller CLA
Modified: 2020-06-05 18:39 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2011-06-24 10:49:12 EDT
BETA_JAVA7

Add a compiler warning for methods that override AutoCloseable#close() and throw InterruptedException:

     * <p><em>Implementers of this interface are also strongly advised
     * to not have the {@code close} method throw {@link
     * InterruptedException}.</em>

I don't think this warning needs to be configurable or suppressible by a special @SuppressWarnings token (except for "all").


Example:

class ACloseable implements AutoCloseable {
	@Override
	public void close() throws IllegalArgumentException, InterruptedException { }
}
Comment 1 Srikanth Sankaran CLA 2011-06-24 22:13:43 EDT
Ayush, please follow up.
Comment 2 Srikanth Sankaran CLA 2011-07-05 04:48:51 EDT
Load balancing - Satyam, please take up this item. Thanks.
Comment 3 Markus Keller CLA 2011-07-05 08:23:50 EDT
low priority for me
Comment 4 Srikanth Sankaran CLA 2012-01-28 20:26:57 EST
(In reply to comment #3)
> low priority for me

Thanks for the input.  Moving it out to 3.9 time frame.
Comment 5 Stephan Herrmann CLA 2018-12-02 04:55:49 EST
See also https://bugs.openjdk.java.net/browse/JDK-7027157

I stumbled upon this when eclipse.jdt.core-run.javac-10 failed in ResourceLeakTests.testBug473317 saying:

testBug473317: unused excuse org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest$JavacTestOptions$Excuse@f04b315 for compiler org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest$JavacCompiler@606f0f70

--- javac err: ---
AutoCloseableEnhancedForTest.java:27: warning: [try] auto-closeable resource MyIterable<T> has a member method close() that could throw InterruptedException
   private static class MyIterable<T> implements Iterable<T>, AutoCloseable
                  ^
  where T is a type-variable:
    T extends Object declared in class MyIterable
1 warning

--------------

regarding @SW & configurability: javac supports @SuppressWarnings("try") - so should we.
Comment 6 Stephan Herrmann CLA 2018-12-02 04:58:08 EST
See also https://bugs.openjdk.java.net/browse/JDK-7148025

"javac should not warn about InterruptedException on the declaration of AutoCloseable itself"
Comment 7 Stephan Herrmann CLA 2018-12-02 04:59:57 EST
And: https://bugs.openjdk.java.net/browse/JDK-8155591

"Suggestion: only report a warning for an actual declaration of a 'close' method; potentially, only for a non-abstract declaration (because an abstract declaration is just repeating the inherited signature of AutoCloseable)."
Comment 8 Manoj N Palat CLA 2019-02-11 04:16:41 EST
Bulk move out of 4.11
Comment 9 Dani Megert CLA 2020-04-01 03:39:10 EDT
I've removed the 'plan' keyword because no target milestone was set. A plan bug must always have a target milestone.

If you consider to set the 'plan' keyword again, make sure that the target milestone must match the release where it was originally planned. If the work was not finished, a follow-up plan bug for the next release must be created and the old one left in the NEW state. Not doing so would destroy the initial plan. The plan must reflect what has been delivered and what not.

Also, please make sure that you only tag root/top-level bugs with 'plan'. Bug fixes or simple things must not get the 'plan keyword.