JDK-6524062 : api/java_io/FileInputStream/index.html#Finalize[Finalize0001] fails on JDK 7 since b06
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2007-02-12
  • Updated: 2012-03-22
  • 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.

To download the current JDK release, click here.
7 b10Fixed
Related Reports
Relates :  
JCK            : JCK6a b05
J2SE           : FAIL - JDK7 b06, PASS JDK6 b104, JDK6u1 b03
Platform[s]    : FAIL - seems to be all
switch/Mode    : FAIL - default

Test api/java_io/FileInputStream/index.html#Finalize[Finalize0001] fails against JDK 7 since b06. Test verifies that "protected void FileInputStream.finalize()  Ensures that the close method of this file input stream is called when there are no more references to it."
Tests opens file, calls finalize and then expects file to be closed. File is not closed since JDK 7 b06.

Steps to reproduce:
1 create empty file zeroleng.dat in the current directory.
2 compile and run the code from comment.

it will report:
C:\tests\finalize>Z:/Links/stt/jdk_promotions/JDK6u1/b03/binaries/windows-i586/jdk1.6.0_01/bin/java -showversion -cp . FinalizeTests
java version "1.6.0_01-ea"
Java(TM) SE Runtime Environment (build 1.6.0_01-ea-b03)
Java HotSpot(TM) Client VM (build 1.6.0_01-ea-b03, mixed mode)


C:\tests\finalize>Z:/Links/stt/jdk_promotions/JDK7.0/b06/binaries/windows-i586/jdk1.7.0/bin/java -showversion -cp . FinalizeTests
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b06)
Java HotSpot(TM) Client VM (build 1.7.0-ea-b06, mixed mode)

close() method is not called

EVALUATION As part of the work for 6322678 the finalizer was re-implemented to avoid closing the file desciptor when it is used by other streams. This has a side effect that is visible to code that extends FileInputStream and overrides the close method. Tricky to fix.