JDK-7038105 : File.isHidden() should return true for pagefile.sys and hiberfil.sys
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 5.0u30
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2011-04-20
  • Updated: 2013-12-17
  • Resolved: 2013-05-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.
JDK 7 JDK 8
7u40Fixed 8 b93Fixed
Related Reports
Relates :  
Description
A CU reported that isHidden() does not return true for pagefile.sys and hiberfil.sys
and true must be returned in both cases.

CONFIGURATION:
JDK : 5u30/6u24/7(b137)
OS : WindowsXP(SP3, Japanese, 32bits)

REPRODUCE:
1. Compile the attached FileAttr.java
2. Invoke "java FileAttr c:\pagefile.sys c:\hiberfil.sys"

[EXPECTED]
F:\export2\licensees>java -showversion FileAttr c:\pagefile.sys c:\hiberfil.sys
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b137)
Java HotSpot(TM) Client VM (build 21.0-b07, mixed mode)

c:\pagefile.sys exists file hidden
c:\hiberfil.sys exists file hidden

[ACTUAL]
F:\export2\licensees>java -showversion FileAttr c:\pagefile.sys c:\hiberfil.sys
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b137)
Java HotSpot(TM) Client VM (build 21.0-b07, mixed mode)

c:\pagefile.sys exists file
c:\hiberfil.sys exists file

NOTE:
The attributes of both files are hidden file.

C:\>attrib pagefile.sys
A  SH      C:\pagefile.sys

C:\>attrib hiberfil.sys
A  SH      C:\hiberfil.sys

The CU sent more details and suggested fix, please see the comment section.

Comments
I have attached test case and suggested src diff. again.
08-05-2013

WORK AROUND For jdk7 the workaround is to use Files.isHidden as the Windows provider falls back to FindFirstFile when the attributes cannot be obtained due to a sharing violation.
20-04-2011

EVALUATION This is crud that should be removed from the java.io implementation. The submitter's suggestion to fallback to FindFirstFile is reasonable and is how the Windows provider for the new file system API works in jdk7.
20-04-2011