windmill-labs/windmill · critical

Error setting Java as language: {e}

Error message

Error setting Java as language: {e}

What it means

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.

Source

Thrown at backend/parsers/windmill-parser-java/src/lib.rs:27

use tree_sitter::Node;
use windmill_parser::Arg;
use windmill_parser::MainArgSignature;
use windmill_parser::{ObjectType, Typ};

#[derive(Debug)]
pub struct JavaMainSigMeta {
    pub is_public: bool,
    pub returns_void: bool,
    pub class_name: Option<String>,
    pub main_sig: MainArgSignature,
}

pub fn parse_java_sig_meta(code: &str) -> anyhow::Result<JavaMainSigMeta> {
    let mut parser = tree_sitter::Parser::new();
    let language = tree_sitter_java::LANGUAGE;
    parser
        .set_language(&language.into())
        .map_err(|e| anyhow!("Error setting Java as language: {e}"))?;

    // Parse code
    let tree = parser
        .parse(code, None)
        .ok_or(anyhow!("Failed to parse code"))?;
    let root_node = tree.root_node();

    // Traverse the AST to find the Main method signature
    let main_sig = find_main_signature(root_node, code);
    let auto_kind = if main_sig.is_none() {
        Some("lib".to_string())
    } else {
        None
    };
    let mut is_public = false;
    let mut returns_void = false;
    let mut class_name = None;

View on GitHub (pinned to e474e8803c)

Solutions

  1. Align versions: cargo update -p tree-sitter-java and cargo update -p tree-sitter together, then rebuild
  2. cargo clean the two crates (or the whole target dir) to purge stale artifacts and recompile
  3. Verify the grammar's LANGUAGE_VERSION fits within the runtime's MIN/MAX LANGUAGE_VERSION constants and pin a compatible pair
  4. If on wasm, ensure tree-sitter-java is built with the matching tree-sitter wasm configuration

Example fix

// before (Cargo.toml)
tree-sitter = "0.20"
tree-sitter-java = "0.21"
// after (aligned)
tree-sitter = "0.21"
tree-sitter-java = "0.21"
Defensive patterns

Strategy: try-catch

Validate before calling

// No input-side pre-check: failure is environmental. CI guard:
// cargo test -p windmill-parser-java

Try / catch

match parse_java_sig_meta(code) {
    Ok(meta) => meta,
    Err(e) if e.to_string().contains("Error setting Java as language") => {
        bail!("tree-sitter Java grammar failed to load (ABI/version mismatch): {e}")
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/c97b00fa8f0c7938. Report an issue: GitHub.