-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
8, 9
-
generic
-
windows_7
FULL PRODUCT VERSION :
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) Client VM (build 25.102-b14, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
EXTRA RELEVANT SYSTEM CONFIGURATION :
32 bit
A DESCRIPTION OF THE PROBLEM :
If you use java.nio.file.Files.isHidden(hiddenDirectory) on a hidden folder on windows (I used windows 7 - 32bit) it reports it as not hidden. Instead you had to use java.nio.file.Files.readAttributes(hiddenDirectory, DosFileAttributes.class).isHidden()
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
create a hidden folder on windows
execute Files.isHidden() on that folder
see that it returns false
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Files.isHidden(hiddenDirectory) should return true!
ACTUAL -
Files.isHidden(hiddenDirectory) returns false
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.DosFileAttributes;
public class FilesDotIsHiddenForWindowsFolder {
public static void main(String[] args) throws IOException {
Path hiddenDirectory = Paths.get("someHiddenDir");
if(!Files.exists(hiddenDirectory)){
Files.createDirectory(hiddenDirectory);
assert Files.exists(hiddenDirectory) == true : "Something went wrong creating the test folder";
}
Files.setAttribute(hiddenDirectory, "dos:hidden", Boolean.TRUE);
assert Files.readAttributes(hiddenDirectory, DosFileAttributes.class).isHidden() == true : "Something went wrong setting folder to be hidden";
if(Files.isHidden(hiddenDirectory)){
System.err.println("is hidden");
}
else{
System.err.println("Folder is hidden, but Files.isHidden() returned false. Files.isHidden() should return true!");
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
use Files.readAttributes(hiddenDirectory, DosFileAttributes.class).isHidden()
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) Client VM (build 25.102-b14, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
EXTRA RELEVANT SYSTEM CONFIGURATION :
32 bit
A DESCRIPTION OF THE PROBLEM :
If you use java.nio.file.Files.isHidden(hiddenDirectory) on a hidden folder on windows (I used windows 7 - 32bit) it reports it as not hidden. Instead you had to use java.nio.file.Files.readAttributes(hiddenDirectory, DosFileAttributes.class).isHidden()
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
create a hidden folder on windows
execute Files.isHidden() on that folder
see that it returns false
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Files.isHidden(hiddenDirectory) should return true!
ACTUAL -
Files.isHidden(hiddenDirectory) returns false
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.DosFileAttributes;
public class FilesDotIsHiddenForWindowsFolder {
public static void main(String[] args) throws IOException {
Path hiddenDirectory = Paths.get("someHiddenDir");
if(!Files.exists(hiddenDirectory)){
Files.createDirectory(hiddenDirectory);
assert Files.exists(hiddenDirectory) == true : "Something went wrong creating the test folder";
}
Files.setAttribute(hiddenDirectory, "dos:hidden", Boolean.TRUE);
assert Files.readAttributes(hiddenDirectory, DosFileAttributes.class).isHidden() == true : "Something went wrong setting folder to be hidden";
if(Files.isHidden(hiddenDirectory)){
System.err.println("is hidden");
}
else{
System.err.println("Folder is hidden, but Files.isHidden() returned false. Files.isHidden() should return true!");
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
use Files.readAttributes(hiddenDirectory, DosFileAttributes.class).isHidden()
- relates to
-
JDK-8215467 Files.isHidden should return true for hidden directories on Windows
- Resolved