jdtls-lsp: auto-build compiles into Maven's `target/classes`, so agents debug phantom classes

Author: mvysnyCreated Sep 30, 2026Updated Sep 30, 2026

Impact. With jdtls-lsp enabled, jdtls and Maven compile into the same folder. Agents run mvn compile, mvn test or mvn exec:java constantly, so on any Maven project the agent sooner or later runs a mix of classes from two compilers. It then spends turns and tokens working out who overwrote target/classes, and it can't know the answer is the LSP the harness itself started. This makes the plugin a net negative on Maven projects as it ships today.

Cause. The plugin starts jdtls with no initializationOptions, so auto-build is on. For a Maven project, m2e sets the JDT output folder to the pom's outputDirectory, which is target/classes. JDT and javac name some synthetic classes differently (anonymous classes, switch maps), so the folder ends up holding a mix of both compilers' output. We hit a stale ItemEntryPanel$3 that javac would not have produced.

Repro. Open a Maven project with an anonymous inner class in Claude Code with jdtls-lsp enabled. Wait for jdtls to import it and look at target/classes: jdtls has written A.class, A$1.class and so on before Maven has run at all.

Fix options, most invisible first. jdtls has no setting that moves a Maven project's output (java.project.outputPath doesn't apply to Maven or Gradle projects), so a simple settings change won't do it.

  1. Redirect the output with auto-build still on. jdtls loads extension bundles through initializationOptions.bundles; one that configures m2e to compile into target/ide/classes would keep every feature and never touch Maven's output. This is the fix we'd hope for; we haven't verified that m2e accepts it.
  2. Turn auto-build off by default: initializationOptions: {"settings": {"java": {"autobuild": {"enabled": false}}}}. We measured it against jdtls on a test project. No .class files are ever written, and definition, references, hover and implementation return the same results as with auto-build on. The cost: after an edit, errors in other files (callers of a renamed method, even ones already open) are no longer reported until that file is opened.
  3. A userConfig knob for auto-build, or for free-form jdtls settings, whichever default is chosen.
  4. Document the pom-side fix in the README for users who keep auto-build on. m2e sets m2e.version and a command-line build never does, so this profile moves only the IDE's output (tested: jdtls then writes to target/ide/classes):
    xml
    <profile>
        <!-- Active only inside Eclipse / jdtls (m2e sets m2e.version); the command-line build never sees it. -->
        <id>ide-output</id>
        <activation><property><name>m2e.version</name></property></activation>
        <build><directory>${project.basedir}/target/ide</directory></build>
    </profile>

Related: #461 (metadata files in the project root), #1861 (missing initializationOptions).

Source: anthropics/claude-plugins-official