{"record":{"id":"7925506f179de364","repo":"antlr/antlr4","slug":"fatal-error-occured-while-evaluating-the-names-of","errorCode":null,"errorMessage":"Fatal error occured while evaluating the names of the grammar files to analyze","messagePattern":"Fatal error occured while evaluating the names of the grammar files to analyze","errorType":"exception","errorClass":"MojoExecutionException","httpStatus":null,"severity":"error","filePath":"antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java","lineNumber":271,"sourceCode":"            outputDir.mkdirs();\n        }\n\n        GrammarDependencies dependencies = new GrammarDependencies(sourceDirectory, libDirectory, arguments, getDependenciesStatusFile(), getLog());\n\n\t\t// Now pick up all the files and process them with the Tool\n\t\t//\n\n\t\tList<List<String>> argumentSets;\n        Set<File> grammarFiles;\n        Set<File> importGrammarFiles;\n        try {\n\t\t\tList<String> args = getCommandArguments();\n            grammarFiles = getGrammarFiles(sourceDirectory);\n            importGrammarFiles = getImportFiles(sourceDirectory);\n            argumentSets = processGrammarFiles(args, grammarFiles, dependencies, sourceDirectory);\n        } catch (Exception e) {\n            log.error(e);\n            throw new MojoExecutionException(\"Fatal error occured while evaluating the names of the grammar files to analyze\", e);\n        }\n\n\t\tlog.debug(\"Output directory base will be \" + outputDirectory.getAbsolutePath());\n\t\tlog.info(\"ANTLR 4: Processing source directory \" + sourceDirectory.getAbsolutePath());\n\t\tfor (List<String> args : argumentSets) {\n\t\t\ttry {\n\t\t\t\t// Create an instance of the ANTLR 4 build tool\n\t\t\t\ttool = new CustomTool(args.toArray(new String[0]));\n\t\t\t} catch (Exception e) {\n\t\t\t\tlog.error(\"The attempt to create the ANTLR 4 build tool failed, see exception report for details\", e);\n\t\t\t\tthrow new MojoFailureException(\"Error creating an instanceof the ANTLR tool.\", e);\n\t\t\t}\n\n            try {\n                dependencies.analyze(grammarFiles, importGrammarFiles, tool);\n            } catch (Exception e) {\n                log.error(\"Dependency analysis failed, see exception report for details\",\n                    e);","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/antlr/antlr4/blob/7d5770395bb7b02eb56e7c62662cb1d7c08f42a3/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java#L253-L289","documentation":"matchImpl also requires a non-null patternTree — the compiled form of the pattern (tags resolved to TokenTagToken/RuleTagToken nodes). A null pattern tree means pattern compilation produced nothing, which indicates a bug in the compile path or bad arguments, and comparing against it is undefined; IllegalArgumentException fails fast.","triggerScenarios":"Subclass or reflection calls to matchImpl with a null patternTree; constructing a mismatched invocation where the compiled ParseTreePattern's pattern tree was never obtained (e.g. passing null instead of pattern.getPatternTree()).","commonSituations":"Extending ParseTreePatternMatcher and hand-calling matchImpl; tests exercising the matcher internals with placeholder nulls.","solutions":["Always pass pattern.getPatternTree() as patternTree — never build the call by hand with null.","Prefer the public matches(tree, pattern, ruleIndex) / matches(tree, ParseTreePattern) entry points which compile correctly.","Assert non-null pattern tree in test setup before invoking internals."],"exampleFix":"// before\nmismatch = matcher.matchImpl(tree, null, labels); // subclass experiment\n\n// after\nParseTreePattern p = matcher.compile(\"<ID>\", R.expr);\nmismatch = matcher.matchImpl(tree, p.getPatternTree(), labels);","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(pattern, \"compile the pattern first\");\nParseTree patternTree = pattern.getPatternTree();\nObjects.requireNonNull(patternTree, \"pattern tree missing\");\nmatcher.matchImpl(tree, patternTree, labels);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use public entry points matches(...) instead of matchImpl.","Always obtain patternTree from pattern.getPatternTree().","Keep test doubles away from matcher internals."],"tags":["antlr","java","parse-tree-pattern","null-argument","precondition"],"backgroundTag":null,"analyzedSha":"7d5770395bb7b02eb56e7c62662cb1d7c08f42a3","analyzedAt":"2026-08-14T14:47:56.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}