英文:
Java UserDefinedFileAttributeView null
问题
I'm attempting to use the Files.NIO's UserDefinedFileAttributeView to read & write custom attributes to files (a hash, and two string properties) for use in a media server.
I'm running macOS 10.15.4 with APFS, which definitely supports xattr (and I can read & write them from the command line), but I get a NPE when trying to access the properties from Java:
UserDefinedFileAttributeView view = Files.getFileAttributeView(path, UserDefinedFileAttributeView.class);
System.out.println(view.list()); // throws NPE. States that "view" is null
Trying to write gives the same error. What am I missing / what should I be doing different? Ideally, this code would be portable at least between macOS and Windows (Linux might need to specifically enable xattr, so not a big deal).
Thanks!
英文:
I'm attempting to use the Files.NIO's UserDefinedFileAttributeView to read & write custom attributes to files (a hash, and two string properties) for use in a media server.
I'm running macOS 10.15.4 with APFS, which definitely supports xattr (and I can read & write them from the command line), but I get a NPE when trying to access the properties from Java:
UserDefinedFileAttributeView view = Files
.getFileAttributeView(path, UserDefinedFileAttributeView.class);
System.out.println(view.list()); // throws NPE. States that "view" is null
Trying to write gives the same error. What am I missing / what should I be doing different? Ideally, this code would be portable at least between macOS and Windows (Linux might need to specifically enable xattr, so not a big deal).
Thanks!
答案1
得分: 1
Sure, here's the translation:
回答我自己的问题..
根据https://bugs.openjdk.java.net/browse/JDK-8040830,该错误已被提交但从未修复,并且该报告已关闭。因此,目前在 macOS 上不可能实现这一点。
英文:
Answering my own question..
According to https://bugs.openjdk.java.net/browse/JDK-8040830, the bug has been submitted but never fixed, and the report was closed. So for now, this is not possible on macOS
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论