JDK-6970833 : Try-with-resource implementation throws an NPE during Flow analysis
Type:Bug
Component:tools
Sub-Component:javac
Affected Version:7
Priority:P2
Status:Closed
Resolution:Fixed
OS:generic
CPU:unknown
Submitted:2010-07-21
Updated:2011-03-07
Resolved:2011-03-07
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.
The following program crashes javac:
class Test {
public void test() {
try(Resource r = null) { }
}
interface Resource extends AutoCloseable {}
}
Comments
SUGGESTED FIX
A webrev of this fix is available at the following URL:
http://hg.openjdk.java.net/jdk7/tl/langtools/rev/62f3f07002ea
29-07-2010
EVALUATION
The problem is caused by the fact that the resource type is an interface; as such, the lookup strategy used to lookup the close() method fails; flow analysis should be updated in order to use a more robust lookup strategy (possibly the same used during method resolution).