build_java8_legacy_dex.sh does not set JAVA_RUNFILES for the d8/r8 launchers

Open Beginner friendly
#599 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 6 days

@TrapsterDK is already working on this.

Since Nov 18, 2026.

  • #600 by @TrapsterDK — open

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
bash, java, shell
Domain
build-system

Research direction

Start by reading build_java8_legacy_dex.sh and comparing it with d8_desugar.sh, which already exports JAVA_RUNFILES="$0.runfiles". The fix is to add the same export before the d8, r8 and tracereferences launchers are invoked. To verify, build //tools/android:java8_legacy_dex with --spawn_strategy=local while JAVA_RUNFILES points at another runfiles tree; done means the launchers resolve jars from the script's own runfiles and the build succeeds.

Written by the indexing model from the issue text.

Description

build_java8_legacy_dex.sh runs the d8, r8 and tracereferences Java launchers, but it does not set JAVA_RUNFILES. d8_desugar.sh already does (export JAVA_RUNFILES="$0.runfiles").

A Bazel Java launcher uses JAVA_RUNFILES from the environment when it is set. When the java8_legacy_dex genrule runs unsandboxed, the variable can point at another target's runfiles tree, so the launchers look for their jars in the wrong place and the build fails.

How to reproduce: build //tools/android:java8_legacy_dex unsandboxed (--spawn_strategy=local) from an environment where JAVA_RUNFILES points to a different runfiles tree.

Fix: export JAVA_RUNFILES="$0.runfiles" in build_java8_legacy_dex.sh, the same as d8_desugar.sh. I will send a PR with a test that checks the launchers see the script's own runfiles.

Assisted by Claude.

Dominant language
Java
Stars
205
Forks
113
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bazelbuild/rules_android

All issues in bazelbuild/rules_android

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.