{"record":{"id":"cbf843158a2c53ff","repo":"oracle/graal","slug":"file-attributes-attrs","errorCode":null,"errorMessage":"file attributes: {attrs}","messagePattern":"file attributes: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"espresso/src/com.oracle.truffle.espresso.io/src/sun/nio/fs/FileAttributeParser.java","lineNumber":67,"sourceCode":"                    OTHERS_EXECUTE_VALUE;\n    static final int ALL_READWRITE = OWNER_READ_VALUE |\n                    OWNER_WRITE_VALUE |\n                    GROUP_READ_VALUE |\n                    GROUP_WRITE_VALUE |\n                    OTHERS_READ_VALUE |\n                    OTHERS_WRITE_VALUE;\n\n    static int parseWithDefault(int defaultAttrs, FileAttribute<?>... attrs) {\n        if (attrs == null || attrs.length == 0) {\n            return defaultAttrs;\n        }\n        for (FileAttribute<?> attr : attrs) {\n            if (attr.name().equals(\"posix:permissions\")) {\n                @SuppressWarnings(\"unchecked\")\n                Set<PosixFilePermission> perms = (Set<PosixFilePermission>) attr.value();\n                return getMaskfromPosix(perms);\n            } else {\n                throw new UnsupportedOperationException(\"file attributes: \" + Arrays.toString(attrs));\n            }\n        }\n        throw new IllegalStateException(\"should not reach here\");\n    }\n\n    private static int getMaskfromPosix(Set<PosixFilePermission> perms) {\n        int mask = 0;\n        for (PosixFilePermission perm : perms) {\n            switch (perm) {\n                case OWNER_READ:\n                    mask |= OWNER_READ_VALUE;\n                    break;\n                case OWNER_WRITE:\n                    mask |= OWNER_WRITE_VALUE;\n                    break;\n                case OWNER_EXECUTE:\n                    mask |= OWNER_EXECUTE_VALUE;\n                    break;","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso/src/com.oracle.truffle.espresso.io/src/sun/nio/fs/FileAttributeParser.java#L49-L85","documentation":"FileAttributeParser.parseWithDefault only understands the 'posix:permissions' FileAttribute; anything else (e.g. 'dos:readonly', 'basic:lastModifiedTime', or a custom attribute) throws UnsupportedOperationException listing the attributes. This backs file creation in the Truffle NIO provider where only POSIX permission masks can be translated.","triggerScenarios":"Guest code calling Files.createFile/createDirectory/createSymbolicLink with FileAttribute<?> other than posix:permissions, e.g. Windows DOS attributes or NFS/basic timestamps, on the Truffle filesystem provider.","commonSituations":"Cross-platform code that sets dos:* attributes on Windows-targeted logic but runs on Espresso's POSIX-style Truffle FS; libraries constructing files with metadata attributes unconditionally.","solutions":["Pass only PosixFilePermissions.asFileAttribute(...) style attributes.","Set other metadata after creation via Files.setAttribute/Files.setLastModifiedTime, which are separate code paths.","Branch on the provider/OS before attaching attributes."],"exampleFix":"// before\nFiles.createFile(p, DosFileAttributeView...\n// e.g. attribute \"dos:readonly\"\n\n// after\nSet<PosixFilePermission> perms = PosixFilePermissions.fromString(\"rw-r--r--\");\nFiles.createFile(p, PosixFilePermissions.asFileAttribute(perms));\nFiles.setLastModifiedTime(p, FileTime.from(millis, TimeUnit.MILLISECONDS)); // set times separately","handlingStrategy":"validation","validationCode":"static boolean isSupported(FileAttribute<?> a) {\n    return \"posix:permissions\".equals(a.name());\n}\n// filter attrs before Files.createFile","typeGuard":null,"tryCatchPattern":"try {\n    Files.createFile(p, attrs);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage().startsWith(\"file attributes\")) {\n        Files.createFile(p); // create bare, set metadata afterwards\n    }\n}","preventionTips":["Pass only PosixFilePermissions attributes to file creation.","Set other metadata post-creation with the typed Files APIs."],"tags":["espresso","nio","file-attributes","posix"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}