Skip to content

gh-152785: Upgrade Java from 17 to 21 in GHA Android#152783

Open
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:android_upgrade_java
Open

gh-152785: Upgrade Java from 17 to 21 in GHA Android#152783
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:android_upgrade_java

Conversation

@vstinner

@vstinner vstinner commented Jul 1, 2026

Copy link
Copy Markdown
Member

@vstinner vstinner changed the title Upgrade Java from 17 to 21 in GHA Android gh-152785: Upgrade Java from 17 to 21 in GHA Android Jul 1, 2026
@vstinner vstinner marked this pull request as ready for review July 1, 2026 13:10
@vstinner

vstinner commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

@mhsmith: Would you mind reviewing this change?

I tried upgrading Java to Java 25, but Gradle 8 is not compatible with Java 25 and fails with a surprising error:

java.lang.IllegalArgumentException: 25.0.3
	at org.jetbrains.kotlin.com.intellij.util.lang.JavaVersion.parse(JavaVersion.java:307)
	at org.jetbrains.kotlin.com.intellij.util.lang.JavaVersion.current(JavaVersion.java:176)
	at org.jetbrains.kotlin.cli.jvm.modules.JavaVersionUtilsKt.isAtLeastJava9(javaVersionUtils.kt:11)

This change is not needed to upgrade Ubuntu 24.04 to 26.04. It's just that I think that it's a good idea to use newer Java version in our workflow :-)

Android/README.md only mentions a dependency to Java without specifying a version. Should I also update this document to mention that Java 25 and newer is not supported?

Another option would be to upgrade to Gradle and use Java 25. So far, I didn't understand where the Gradle version is specified :-)

@vstinner

vstinner commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

Another option would be to upgrade to Gradle and use Java 25. So far, I didn't understand where the Gradle version is specified :-)

Ah, it seems like the Gradle version comes from the distributionUrl URL of Android/testbed/gradle/wrapper/gradle-wrapper.properties. The latest update was Gradle 8.7 to 8.11.1: commit 2e1544f.

@vstinner

vstinner commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

cc @freakboy3742

persist-credentials: false
- name: Build and test
run: python3 Platforms/Android ci --fast-ci ${{ matrix.arch }}-linux-android
run: JAVA_HOME="${JAVA_HOME_21_X64:-$JAVA_HOME_21_arm64}" python3 Platforms/Android ci --fast-ci ${{ matrix.arch }}-linux-android

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In my tests, Gradle only needs JAVA_HOME.

But would it be more consistent/safer to also set the PATH env var?

Suggested change
run: JAVA_HOME="${JAVA_HOME_21_X64:-$JAVA_HOME_21_arm64}" python3 Platforms/Android ci --fast-ci ${{ matrix.arch }}-linux-android
run: JAVA_HOME="${JAVA_HOME_21_X64:-$JAVA_HOME_21_arm64}" PATH="$JAVA_HOME/bin:$PATH" python3 Platforms/Android ci --fast-ci ${{ matrix.arch }}-linux-android

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My understanding is that JAVA_HOME should be all that is needed (or, more strictly: either will work; both is redundant but won't break anything; setting JAVA_HOME is a little cleaner because it only affects the Java configuration).

@freakboy3742 freakboy3742 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My underlying question about this is the motivation for the change.

I'll defer to @mhsmith on the details here: but I'm not aware of any particular problems with running Gradle with an older (but still LTS-supported) Java; but as you've noted, there are some compatibility issues with using newer Java versions.

Java 21 passes CI, which is the most important criterion here; but it also requires explicitly defining a Java version in the configuration. On the one hand, being explicit about the Java version means we remove an ambiguity about the build environment; but it also means another version that we need to bump/coordinate at some point in the future, rather than accepting the "default java" that the GHA image provides (which skews to the conservative side AFAICT). I'm not sure which is the better option here.

persist-credentials: false
- name: Build and test
run: python3 Platforms/Android ci --fast-ci ${{ matrix.arch }}-linux-android
run: JAVA_HOME="${JAVA_HOME_21_X64:-$JAVA_HOME_21_arm64}" python3 Platforms/Android ci --fast-ci ${{ matrix.arch }}-linux-android

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My understanding is that JAVA_HOME should be all that is needed (or, more strictly: either will work; both is redundant but won't break anything; setting JAVA_HOME is a little cleaner because it only affects the Java configuration).

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants