{"record":{"id":"b26cf66e26f8b93f","repo":"oracle/graal","slug":"syntax-not-recognized","errorCode":null,"errorMessage":"Syntax '{}' not recognized","messagePattern":"Syntax '(.+?)' not recognized","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"espresso/src/com.oracle.truffle.espresso.io/src/sun/nio/fs/TruffleFileSystem.java","lineNumber":170,"sourceCode":"        if (pos <= 0 || pos == syntaxAndPattern.length()) {\n            throw new IllegalArgumentException();\n        }\n        String syntax = syntaxAndPattern.substring(0, pos);\n        String input = syntaxAndPattern.substring(pos + 1);\n\n        String expr;\n        if (syntax.equalsIgnoreCase(GLOB_SYNTAX)) {\n            String os = System.getProperty(\"os.name\").toLowerCase(Locale.ENGLISH);\n            if (os.contains(\"win\")) {\n                expr = sun.nio.fs.Globs.toWindowsRegexPattern(input);\n            } else {\n                expr = sun.nio.fs.Globs.toUnixRegexPattern(input);\n            }\n        } else {\n            if (syntax.equalsIgnoreCase(REGEX_SYNTAX)) {\n                expr = input;\n            } else {\n                throw new UnsupportedOperationException(\"Syntax '\" + syntax +\n                                \"' not recognized\");\n            }\n        }\n\n        // return matcher\n        final Pattern pattern = compilePathMatchPattern(expr);\n\n        return path -> pattern.matcher(path.toString()).matches();\n    }\n\n    @Override\n    public UserPrincipalLookupService getUserPrincipalLookupService() {\n        throw new UnsupportedOperationException();\n    }\n\n    /**\n     * We cannot just throw {@link UnsupportedOperationException} since we implement the Default\n     * filesystem.","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso/src/com.oracle.truffle.espresso.io/src/sun/nio/fs/TruffleFileSystem.java#L152-L188","documentation":"TruffleFileSystem.getPathMatcher(syntax, pattern) supports exactly 'glob' and 'regex' (case-insensitive); any other syntax string throws UnsupportedOperationException. This matches the FileSystem contract where unrecognized syntaxes are optional, and matches the behavior of the default provider.","triggerScenarios":"Calling FileSystems.getFileSystem(...).getPathMatcher(\"foo:*\") or DirectoryStream filter builders with a custom syntax prefix; also case variations are fine, but e.g. 'GLOB :' with a space or unknown syntax names throw.","commonSituations":"User-configurable pattern syntax options in tools (allowing 'ant', 'wildcard', etc.); code ported from libraries that registered custom PathMatcher syntaxes on the default provider.","solutions":["Use only 'glob:...' or 'regex:...' prefixed patterns.","Translate custom patterns to regex before calling getPathMatcher.","Validate and normalize the syntax prefix from user input before use."],"exampleFix":"// before\nPathMatcher m = fs.getPathMatcher(\"wildcard:*.txt\"); // throws\n\n// after\nPathMatcher m = fs.getPathMatcher(\"glob:*.txt\");","handlingStrategy":"validation","validationCode":"static boolean supportedSyntax(String s) {\n    String syntax = s.substring(0, s.indexOf(':')).toLowerCase(Locale.ROOT);\n    return syntax.equals(\"glob\") || syntax.equals(\"regex\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    matcher = fs.getPathMatcher(syntaxAndPattern);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage().contains(\"not recognized\")) { /* default to glob: */ }\n}","preventionTips":["Restrict user-selectable syntax options to glob and regex.","Translate other pattern flavors to regex before use."],"tags":["espresso","nio","path-matcher","glob","regex"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}