Skip to content

Pass KYTHE_JAVA_RUNTIME_OPTIONS via Gradle forkOptions#3030

Open
sharma1210 wants to merge 9 commits intogoogle:masterfrom
sharma1210:fix-kythe-gradle-env
Open

Pass KYTHE_JAVA_RUNTIME_OPTIONS via Gradle forkOptions#3030
sharma1210 wants to merge 9 commits intogoogle:masterfrom
sharma1210:fix-kythe-gradle-env

Conversation

@sharma1210
Copy link
Copy Markdown
Collaborator

@sharma1210 sharma1210 commented Apr 30, 2026

This PR fixes the Kythe extraction failure caused by Error Prone access to JDK internals.

Problem

The build was failing during the :util:compileJava task because the Error Prone static analysis plugin was trying to access internal compiler APIs (com.sun.tools.javac.comp.Resolve.findIdent) that are strictly encapsulated in newer Java versions. Previous attempts to pass --add-opens via compiler arguments or specific environment variables failed or were ignored by the wrapper scripts.

Fix

Used the standard JAVA_TOOL_OPTIONS environment variable in cloudbuild-kythe.yaml to pass the required --add-opens flags to all JVMs started during the build (including the Gradle daemon and forked compiler workers). This ensures that Error Prone has the necessary access to jdk.compiler modules.

This has been tested manually in Cloud Build and successfully generated and uploaded the kzip file.

BUG=496522435


This change is Reviewable

@sharma1210 sharma1210 requested a review from weiminyu April 30, 2026 09:57
@weiminyu
Copy link
Copy Markdown
Collaborator

release/cloudbuild-kythe.yaml line 6 at r1 (raw file):

# To manually trigger a build on GCB, run:
# gcloud builds submit --config cloudbuild-kythe.yaml --substitutions \
#   _KYTHE_VERSION=[kythe_version] ..

You can test this PR by running this command in the release/ directory.

_KYTHE_VERSION is v0.0.68

You'll need to specify the GCP project for the command. Try domain-registry-crash first. If it won't run, then use domain-registry-dev.

Code quote:

# gcloud builds submit --config cloudbuild-kythe.yaml --substitutions \
#   _KYTHE_VERSION=[kythe_version] ..

@weiminyu
Copy link
Copy Markdown
Collaborator

weiminyu commented May 1, 2026

release/cloudbuild-kythe.yaml line 32 at r2 (raw file):

    cp ./kythe/extractors/javac-wrapper.sh $${JAVA_HOME}/bin/javac
    chmod +x $${JAVA_HOME}/bin/javac
    sed -i 's/"$REAL_JAVAC" "$@"/ "$REAL_JAVAC" $REAL_JAVAC_JVM_OPTIONS "$@"/g' $${JAVA_HOME}/bin/javac

This is fragile. You may want to:

  • save platform javac as say, java.real.real
  • create your own javac wrapper as javac.real

Code quote:

    chmod +x $${JAVA_HOME}/bin/javac
    sed -i 's/"$REAL_JAVAC" "$@"/ "$REAL_JAVAC" $REAL_JAVAC_JVM_OPTIONS "$@"/g' $${JAVA_HOME}/bin/javac

@sharma1210
Copy link
Copy Markdown
Collaborator Author

release/cloudbuild-kythe.yaml line 6 at r1 (raw file):

# To manually trigger a build on GCB, run:
# gcloud builds submit --config cloudbuild-kythe.yaml --substitutions \
#   _KYTHE_VERSION=[kythe_version] ..

You can test this PR by running this command in the release/ directory.

_KYTHE_VERSION is v0.0.68

You'll need to specify the GCP project for the command. Try domain-registry-crash first. If it won't run, then use domain-registry-dev.

Code quote:

# gcloud builds submit --config cloudbuild-kythe.yaml --substitutions \
#   _KYTHE_VERSION=[kythe_version] ..

Thanks for your suggestion Weimin it worked now!

Copy link
Copy Markdown
Collaborator

@weiminyu weiminyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weiminyu reviewed 2 files and all commit messages, and resolved 1 discussion.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on sharma1210).

@weiminyu
Copy link
Copy Markdown
Collaborator

weiminyu commented May 4, 2026

:lgtm:

@weiminyu weiminyu self-requested a review May 4, 2026 14:35
Copy link
Copy Markdown
Collaborator

@weiminyu weiminyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weiminyu resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on sharma1210).

@sharma1210 sharma1210 added this pull request to the merge queue May 4, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 4, 2026
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