JDK-8029123 : Files.isHidden() Bug
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 7u45
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_7
  • Submitted: 2013-11-25
  • Updated: 2018-12-20
  • Resolved: 2013-11-25
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
build 1.7.0_45-b18

ADDITIONAL OS VERSION INFORMATION :
Windows 7 Enterprise
Service Pack 1
64-Bit

A DESCRIPTION OF THE PROBLEM :
The function "Files.isHidden(Path)" isn't working correctly.
If I sent a Path like 'C:\Temp\test.txt' which is hiden, die function return true.
When i sent ja directory 'C:\Temp2 which is hidden, die function return false.

so i think, there is a error with direcctoriers.

ADDITIONAL REGRESSION INFORMATION:
build 1.7.0_45-b18

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
I want to check if a Directory is hidden.


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
Path dir = Paths.get("C:\\APPL\\Test");
try {
DirectoryStream<Path> stream = Files.newDirectoryStream(dir);
for (Path path : stream) {
System.out.println(path);
System.out.println(Files.isHidden(path));
}
} catch (IOException e) {
e.printStackTrace();
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
path.toFile().isHidden()

SUPPORT :
YES
Comments
Just tried on Windows Server 2003: mkdir HiddenDir attrib +H HiddenDir dir /A:H HiddenDir The last command displays HiddenDir in the list as expected.
26-11-2013

It's not clear what is being reported here as Windows does not support the hidden attribute on directories.
25-11-2013

I think this is a duplicate/known limitation but couldn't find the right issue link to.
25-11-2013