JDK-8155591 : Misleading warning when not overriding close method in interface extending AutoCloseable
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 9
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2016-04-28
  • Updated: 2017-11-28
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.
Other
tbd_minorUnresolved
Related Reports
Relates :  
Relates :  
Description
For the following code:

interface Foo extends AutoCloseable {
}

javac will, when compiling with -Xlint, emit a slightly misleading/confusing warning:

$ javac -Xlint Foo.java
Foo.java:1: warning: [try] auto-closeable resource Foo has a member method close() that could throw InterruptedException
public interface Foo extends AutoCloseable {
       ^
1 warning

Given that Foo doesn't even mention close() explicitly the warning is not as helpful as it could/should be.
Comments
See bug JDK-7027157.
29-04-2016

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).
28-04-2016