Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7133476

(fs) Files.readAttributes throws NPE on MacOSX

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 7u4
    • 7u4
    • core-libs
    • b11
    • x86
    • os_x
    • Verified

      From http://java.net/jira/browse/MACOSX_PORT-133 --

      java.nio.file.Files .readAttributes throws NPE on MacOS

      Simple test case:
      import java.nio.file.attribute.DosFileAttributes;
      import java.nio.ByteBuffer;
      import java.nio.channels.SeekableByteChannel;
      import java.nio.file.Files;
      import java.nio.file.Path;
      import java.nio.file.Paths;
      import static java.nio.file.StandardOpenOption.*;

      public class Test {
      public static void main(String argv[]) {
      Path path = Paths.get("temp.txt");
      String data = "Hello world!";
      SeekableByteChannel sbc = null;

      try { ByteBuffer bb = ByteBuffer.wrap(data.getBytes()); sbc = Files.newByteChannel(path, CREATE, WRITE); sbc.write(bb); DosFileAttributes dfa = null; dfa = Files.readAttributes(path, DosFileAttributes.class); } catch (Exception e) { e.printStackTrace(); }
      }

      }

      Test output:

      Exception in thread "main" java.lang.NullPointerException
      at sun.nio.fs.BsdFileSystemProvider.readAttributes(BsdFileSystemProvider.java:78)
      at java.nio.file.Files.readAttributes(Files.java:1669)
      at TestCopy01.test01(TestCopy01.java:85)
      at TestCopy01.main(TestCopy01.java:37)

            alanb Alan Bateman
            juh Jason Uh (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: