Skip to content

fix(kmono-git): add missing GraalVM reflect entry for DiffAlgorithm$SupportedAlgorithm - #48

Merged
julienvincent merged 1 commit into
kepler16:masterfrom
ovistoica:fix/jgit-diff-algorithm-reflect-config
May 20, 2026
Merged

julienvincent merged 1 commit into
kepler16:masterfrom
ovistoica:fix/jgit-diff-algorithm-reflect-config

Conversation

@ovistoica

@ovistoica ovistoica commented May 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Any kmono CLI command that triggers file-level change detection (--with-changes-since, --with-changes combined with --ignore-changes) crashes with:

java.lang.NoSuchMethodException:
  org.eclipse.jgit.diff.DiffAlgorithm$SupportedAlgorithm.values()

Reproducible with:

kmono query --with-changes-since origin/main --include-keys name -o json

Cause

DiffFormatter.setRepository() (called from k16.kmono.git.files/find-commit-changed-files at files.clj:62) internally calls Config.getEnum() which uses reflection to invoke DiffAlgorithm$SupportedAlgorithm.values(). This enum is not registered in the GraalVM native-image reflection config, so the values() method is stripped during compilation.

Call chain:

k16.kmono.git.files/find-commit-changed-files
  → DiffFormatter.setRepository()
    → DiffFormatter.setReader()
      → Config.getEnum("diff", null, "algorithm", SupportedAlgorithm.HISTOGRAM)
        → Config.allValuesOf(SupportedAlgorithm.class)
          → SupportedAlgorithm.class.getMethod("values")  ← NoSuchMethodException

Fix

Added org.eclipse.jgit.diff.DiffAlgorithm$SupportedAlgorithm to packages/kmono-git/resources/META-INF/native-image/org.eclipse.jgit/org.eclipse.jgit/reflect-config.json, following the same pattern as the 16 other JGit enums already registered (e.g. CoreConfig$AutoCRLF, CoreConfig$EOL, SHA1$Sha1Implementation, etc.).

Verification

Built native binary from this branch and confirmed --with-changes-since works:

$ kmono query --with-changes-since origin/main --filter-unchanged --include-keys name -o json

Note: This PR is AI generated but I build the native binary locally and it works as expected. I am currently using a fork fix until this is addressed in kmono directly: https://github.com/ovistoica/kmono/releases/tag/v4.12.1-fix1

…upportedAlgorithm

DiffFormatter.setRepository() internally calls Config.getEnum() which
uses reflection to invoke DiffAlgorithm$SupportedAlgorithm.values().
This fails in the native-image binary because the enum was not
registered in reflect-config.json.

The fix follows the same pattern as the other 16 JGit enums already
registered (CoreConfig$AutoCRLF, CoreConfig$EOL, etc.).

Without this fix, any kmono command that triggers file-level change
detection (--with-changes-since, --with-changes + ignore-changes)
crashes with:

  java.lang.NoSuchMethodException:
    org.eclipse.jgit.diff.DiffAlgorithm$SupportedAlgorithm.values()
@julienvincent

Copy link
Copy Markdown
Contributor

While the change makes sense, I'd just like to verify it on my side first as well. I cannot reproduce it with either of these:

kmono query --with-changes-since origin/main --include-keys name -o json
kmono query --with-changes-since origin/main --filter-unchanged --include-keys name -o json

I'm running version 4.12.1

Can you elaborate on what you are doing to trigger this issue?

@ovistoica

ovistoica commented May 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Tested with latest 4.12.1 and confirm crash:

curl -sL https://github.com/kepler16/kmono/releases/download/v4.12.1/kmono-linux-amd64.tar.gz | tar xz -C /tmp/ 2>/dev/null && /tmp/kmono --version 2>&1; echo \"---\"; # Now test the upstream binary against our repo
cd /home/path/to/repo && /tmp/kmono query --with-changes-since origin/main --include-keys name -o json 2>&1 | head -5"

Output: Exit code: 0
Stdout:
kmono - A cli for managing clojure (mono)repos

Usage:
  kmono [opts] <args>

Version:
  4.12.1

Commands:
  cp      Produce a classpath string from a clojure project
  repl    Start a clojure repl
  exec    Run a given command in workspace packages
  run     Run aliases in workspace packages
  clojure Run an augmented clojure command
  query   Query information about the package graph
  version Print the current version of kmono

Global Options
  -d, --dir      Run commands as if in this directory
  -p, --packages A glob string describing where to search for packages (default: 'packages/*')
  -v, --verbose  Enable verbose output
  -h, --help
---
#error {
 :cause org.eclipse.jgit.diff.DiffAlgorithm$SupportedAlgorithm.values()
 :via
 [{:type java.lang.IllegalArgumentException
   :message Enumerated values of type org.eclipse.jgit.diff.DiffAlgorithm$SupportedAlgorithm not available

Seems to be related to :ignore-changes . We have this set up:

:kmono/workspace {:ignore-changes [".*\\.md$" "^docs/" ".*\\.org$" "LICENSE"]}

When ignore-changes is set, resolve-package-changes-since calls commit-has-meaningful-changes? → find-commit-changed-files → DiffFormatter.setRepository() which triggers the enum reflection. Without ignore-changes, the DiffFormatter code path is never hit.

@julienvincent
julienvincent merged commit 399f589 into kepler16:master May 20, 2026
8 checks passed
@julienvincent

Copy link
Copy Markdown
Contributor

Confirmed, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants