Java用户自定义文件属性视图 null

huangapple go评论77阅读模式
英文:

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

huangapple
  • 本文由 发表于 2020年8月14日 18:55:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/63411426.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定