Repository navigation
Description
Summary
During rapid multi-edit sessions (Claude Code with ENABLE_LSP_TOOL, edits applied programmatically rather than by a human typing), the Java compile diagnostics — the ones with "source": "Java" that jdtls produces (X cannot be resolved to a type, The constructor/method is undefined, not applicable for the arguments) — lag behind the current file state by one or two edits. They reflect the file as it was one or two edits ago, then clear only after a later unrelated edit or a full recompile.
The custom "source": "java-functional-lsp" rules (tree-sitter based) update in lockstep with edits and are not affected. Only the jdtls-sourced compile diagnostics lag.
Net effect: the compile diagnostics are eventually-consistent but noticeably stale mid-session, so they can't be trusted right after an edit.
Component
Stale diagnostics come from Eclipse jdtls (the compile-error/import-resolution engine), surfaced through this wrapper. Versions in the affected setup:
java-functional-lsp0.12.0 (installed via Homebrew tap)jdtls1.61.0- JDK 21 runtime for jdtls; Java 17 source level
- OS: macOS (Apple Silicon)
- Editor/host: Claude Code with
ENABLE_LSP_TOOL=1, server registered vialspServers(.java→java)
Filed here because the stale-compose logic lives in this wrapper's server.py, so the wrapper can likely mitigate it even though jdtls's async builder is the upstream latency source.
Steps to reproduce
Using generic placeholder code (real names redacted):
- Open
MyClass.java, which referencesBarwithout importing it. jdtls reportsBar cannot be resolved to a type. Correct. - Add
import com.example.Bar;as the fix. - Make one or two further edits elsewhere in the file (or in a caller).
- Observe: the LSP still reports
Bar cannot be resolved to a typefor the next one or two edits, even though the import is present and a real compile of the same file succeeds. - The stale error clears only after a further unrelated edit or a full external recompile.
Signature-change variant:
Foohas a 2-arg constructor; a call sitenew Foo(a, b)is clean.- Add a third parameter to
Foo's constructor and update the call site tonew Foo(a, b, c)in the same session. - The LSP keeps reporting the OLD arity at the already-updated call site (
The constructor Foo(...) is undefined/not applicable for the arguments) for one or two subsequent edits.
In both cases an actual command-line compile of the same files succeeds, confirming the diagnostics are stale/false, not real.
Hypothesis / code pointers
Not asserting a root cause — just where I think the relevant logic sits, for the maintainer to judge:
- On
didChange, the edit is forwarded to jdtls and a re-analysis is scheduled. When that re-analysis runs, it merges freshly computed custom diagnostics with the last cached jdtls diagnostics (JdtlsProxy.get_cached_diagnostics(uri)inproxy.py, consumed by_run_analysisinserver.py). jdtls recomputes compile diagnostics asynchronously via the Eclipse JDT incremental builder, which lands well after the edit-triggered re-analysis — so the edit-triggered publish carries current custom diagnostics but a previous build's jdtls compile diagnostics. - jdtls's own async publish is wired back (
_on_jdtls_diagnostics→_analyze_and_publish), so it should self-heal when jdtls finishes. But for an agent host that reads diagnostics right after each tool operation (rather than reacting to server pushes), the observed set is whatever was last published at edit time — the stale one — until the next edit triggers a fresh publish, which is exactly the "clears only on a later edit" symptom. - jdtls
publishDiagnosticsnotifications don't carry thetextDocumentversion, so there's no obvious signal in the proxy to tell "this cached jdtls set is older than the current document" and withhold or invalidate it.
Possible mitigation directions (for discussion): tag/track document versions and drop cached jdtls diagnostics known to be older than the current edit; or don't re-emit cached jdtls compile diagnostics from an edit-triggered analysis, and rely solely on jdtls's own async publish; or invalidate the per-URI jdtls cache on didChange until the next fresh jdtls publish arrives.
Log evidence
Logs were found at the wrapper's stderr log (/tmp/java-functional-lsp.log, rotating). They confirm the two diagnostic sources on the same file — "source": "Java" (jdtls compile) alongside "source": "java-functional-lsp" (custom rules) — in a single publishDiagnostics. The raw excerpt contains private project paths and code, so here is a synthetic, structurally faithful line instead:
{"method": "textDocument/publishDiagnostics", "params": {
"uri": "file:///path/to/project/src/main/java/com/example/MyClass.java",
"diagnostics": [
{"range": {"start": {"line": 12, "character": 4}, "end": {"line": 12, "character": 7}},
"message": "Bar cannot be resolved to a type", "severity": 1, "source": "Java"},
{"range": {"start": {"line": 20, "character": 24}, "end": {"line": 20, "character": 28}},
"message": "Avoid passing null as argument. Use Option.none() ...",
"severity": 2, "code": "null-literal-arg", "source": "java-functional-lsp"}
]}}The "source": "Java" entry is the one that goes stale; the "source": "java-functional-lsp" entry tracks edits correctly.
Environment
- java-functional-lsp: 0.12.0
- jdtls: 1.61.0
- OS: macOS (Apple Silicon)
- Editor: Claude Code (
ENABLE_LSP_TOOL=1), programmatic edits - Java: source level 17, jdtls runtime JDK 21
Activity
test: tighten #109 hold tests after second review round
fix: address /review-ensemble findings on the #109 hold
fix: address /review-ensemble findings on #109 part B
fix: hold edit-triggered publishes until jdtls re-validates (#109) (#111
feat: fresh jdtls diagnostics in Claude Code's own tool result (#109 …
aviadshiber commentedon Sep 29, 2026
Fixed in v0.13.0.
JAVA_FUNCTIONAL_LSP_HOOK_WAIT, 0 disables), so the edit's jdtls errors land in that edit's tool result instead of one tool call later.Verified with headless Claude Code (2.1.282, jdtls 1.61.0): type error from an Edit attached ~0.9s after the edit, before the agent's reply, 4/4 runs; without the hook, 0/4.
Upgrade:
brew upgrade java-functional-lsp(or restart Claude Code with the plugin, which upgrades daily).The non-project / cross-module false errors are a different bug, tracked in #110.
fix: import missing in-repo Maven modules so cross-group symbols reso…
fix: import missing in-repo Maven modules so cross-group symbols reso…
fix: import missing in-repo Maven modules so cross-group symbols reso…