{"record":{"id":"c97b00fa8f0c7938","repo":"windmill-labs/windmill","slug":"error-setting-java-as-language-e","errorCode":null,"errorMessage":"Error setting Java as language: {e}","messagePattern":"Error setting Java as language: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"backend/parsers/windmill-parser-java/src/lib.rs","lineNumber":27,"sourceCode":"use tree_sitter::Node;\nuse windmill_parser::Arg;\nuse windmill_parser::MainArgSignature;\nuse windmill_parser::{ObjectType, Typ};\n\n#[derive(Debug)]\npub struct JavaMainSigMeta {\n    pub is_public: bool,\n    pub returns_void: bool,\n    pub class_name: Option<String>,\n    pub main_sig: MainArgSignature,\n}\n\npub fn parse_java_sig_meta(code: &str) -> anyhow::Result<JavaMainSigMeta> {\n    let mut parser = tree_sitter::Parser::new();\n    let language = tree_sitter_java::LANGUAGE;\n    parser\n        .set_language(&language.into())\n        .map_err(|e| anyhow!(\"Error setting Java as language: {e}\"))?;\n\n    // Parse code\n    let tree = parser\n        .parse(code, None)\n        .ok_or(anyhow!(\"Failed to parse code\"))?;\n    let root_node = tree.root_node();\n\n    // Traverse the AST to find the Main method signature\n    let main_sig = find_main_signature(root_node, code);\n    let auto_kind = if main_sig.is_none() {\n        Some(\"lib\".to_string())\n    } else {\n        None\n    };\n    let mut is_public = false;\n    let mut returns_void = false;\n    let mut class_name = None;\n","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-java/src/lib.rs#L9-L45","documentation":"parse_java_sig_meta loads the tree-sitter Java grammar via parser.set_language(); if the grammar cannot be attached to the Parser it wraps the LanguageError with this message. As with the C# equivalent, it points to a tree-sitter runtime/grammar version incompatibility rather than anything wrong with the user's Java code — it fails before parsing begins.","triggerScenarios":"Calling parse_java_sig_meta (directly or via parse_java_signature) when tree_sitter and tree_sitter_java are ABI-incompatible — one crate was upgraded without the other, or stale build artifacts mix object files from different versions.","commonSituations":"Cargo.lock updates bumping tree_sitter but not tree-sitter-java; switching toolchains or target triples (native vs wasm) with mixed cached artifacts; workspace feature changes forcing partial recompiles.","solutions":["Align versions: cargo update -p tree-sitter-java and cargo update -p tree-sitter together, then rebuild","cargo clean the two crates (or the whole target dir) to purge stale artifacts and recompile","Verify the grammar's LANGUAGE_VERSION fits within the runtime's MIN/MAX LANGUAGE_VERSION constants and pin a compatible pair","If on wasm, ensure tree-sitter-java is built with the matching tree-sitter wasm configuration"],"exampleFix":"// before (Cargo.toml)\ntree-sitter = \"0.20\"\ntree-sitter-java = \"0.21\"\n// after (aligned)\ntree-sitter = \"0.21\"\ntree-sitter-java = \"0.21\"","handlingStrategy":"try-catch","validationCode":"// No input-side pre-check: failure is environmental. CI guard:\n// cargo test -p windmill-parser-java","typeGuard":null,"tryCatchPattern":"match parse_java_sig_meta(code) {\n    Ok(meta) => meta,\n    Err(e) if e.to_string().contains(\"Error setting Java as language\") => {\n        bail!(\"tree-sitter Java grammar failed to load (ABI/version mismatch): {e}\")\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep tree-sitter and tree-sitter-java versions aligned in Cargo.lock","Run windmill-parser-java unit tests in CI on dependency bumps","cargo clean after upgrading any tree-sitter family crate","Avoid mixing native/wasm artifact caches between builds"],"tags":["java","tree-sitter","dependency-mismatch"],"backgroundTag":"tree-sitter-language-abi-mismatch","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}