Skip to content

Honor a system/global JDK instead of downloading Temurin per analysis cache #237

Description

@rahlk

PROBLEM

JCodeanalyzer's ensure_jdk downloads a Temurin JDK into each analysis cache dir — per project, potentially per service — so a machine analyzing ten projects fetches ten JDKs. This defeats pre-baking a JDK into a container image and costs a network fetch per analyzed project. Surfaced by COCOA's Docker packaging (codellm-devkit/cocoa#1).

SCOPE BOUNDARY

JDK discovery only. Not the analyzer distribution — sourcing codeanalyzer-java from PyPI was tried and reverted over GraalVM issues (#161, #162, closed won't-do), so the bundled jar stays and this must be solved on its own terms. Not JDK version policy, and not the pinned JDK_RELEASE itself.

GOALS

  • Probe for a usable JDK before downloading: JAVA_HOME, then a CLDK_JDK env or global cache path.
  • Verify the found JDK is version-compatible, not merely present.
  • Fall back to the current Adoptium download when no compatible JDK is found.
  • Log which JDK was selected and why, at DEBUG.
  • Document the precedence order.

CAVEATS AND KNOWN RISKS

  • Presence is not compatibility. JAVA_HOME on a dev machine is frequently stale or points at a different major. Accepting it unverified moves the failure from "slow download" to "analyzer crashes with an obscure JVM error" — strictly worse.
  • Silent fallback hides misconfiguration: a user who sets JAVA_HOME expecting it to be used, and is quietly ignored, has no signal. Hence the log line is part of the contract, not polish.
  • The per-project cache dir is also what makes analyses independent; a shared global JDK path is shared mutable state across concurrent runs.

DEFINITION OF DONE

  • With a compatible JAVA_HOME set, analysis completes and no download occurs — asserted in a test, not observed by eye.
  • With an incompatible JDK on JAVA_HOME, the run falls back to download and logs the reason.
  • A container image with a pre-baked JDK analyzes a project with no network access to Adoptium.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions