Skip to content

fix: upgrade jandex to 3.2.3 to handle modern class files - #2661

Merged
maxandersen merged 2 commits into
jbangdev:mainfrom
maxandersen:jandex3-java25-classes
Sep 22, 2026
Merged

maxandersen merged 2 commits into
jbangdev:mainfrom
maxandersen:jandex3-java25-classes

Conversation

@maxandersen

Copy link
Copy Markdown
Collaborator

What

Running a jar built with a recent JDK, e.g. jbang com.netflix:com.netflix.tools.jfmt:0.8.2, crashed with:

[jbang] [ERROR] Index 0 out of bounds for length 0
java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
	at org.jboss.jandex.Indexer.updateTypeTarget(Indexer.java:903)

Why

The jar has no Main-Class manifest, so jbang scans its classes with jandex to find main() methods. The bundled org.jboss:jandex:2.2.3.Final (2021) cannot parse Java 25 class files (major 69) and throws. Only IOException was caught, so the crash surfaced as the cryptic error above.

Fix

  • Switch org.jboss:jandex:2.2.3.Final → io.smallrye:jandex:3.2.3 (same org.jboss.jandex package, targets Java 8 bytecode so no compatibility impact; no code changes needed)
  • JarCmdGenerator: skip module-info.class and catch per-entry exceptions so one unparseable class cannot break main class detection (details logged with --verbose)
  • Regression test: jar with corrupt class entries now yields the friendly "No main class deduced…" error instead of AIOOBE

Verified jbang com.netflix:com.netflix.tools.jfmt:0.8.2 now runs.

Jars built with recent JDKs (e.g. Java 25 class files) crashed main
class detection with ArrayIndexOutOfBoundsException because bundled
jandex 2.2.3.Final (2021) cannot parse them.

- switch org.jboss:jandex:2.2.3.Final to io.smallrye:jandex:3.2.3
  (same org.jboss.jandex package, runs on Java 8)
- skip module-info.class and catch per-entry exceptions during jar
  scanning so one unparseable class cannot break main detection

Fixes running e.g. com.netflix:com.netflix.tools.jfmt:0.8.2
@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • ai-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: d18aeca8-5c2b-42c3-ba85-06e718924d9a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

jandex 3 reflectively instantiates AnnotationInstance[] and ClassInfo[]
arrays (Utils.unfold), which fails under --exact-reachability-metadata
with MissingReflectionRegistrationError, breaking all native ITs that
build or scan jars.
@maxandersen
maxandersen merged commit a7a9ee9 into jbangdev:main Sep 22, 2026
30 checks passed
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.

1 participant