1
0
mirror of https://github.com/google/nomulus synced 2026-04-10 03:29:28 +00:00

Upgrade to Java 25 (#3000)

Error-prone introduced many more checks in Java 25. We fixed a few
and suppressed most. A follow-up bug is opened to clean this up.
An ai agent should be able to clean up most of it.

This PR is created with gemini-cli. Summary of experience:

* The good: AI caught most compatibility issues, and with permission,
  suppressed them through compiler flags and errorprone options.
  It also caught many versio references in scripts.

* Where it didn't shine:
  - It did not find and update the target version spec in the custome
    VKey annotation processor source file.
  - It did not flag eclipse-temurin:21 docker image for upgrade.
  - When running into failure, its first instinct is to disable checks
    e.g., -Werror instead of fixing them.
This commit is contained in:
Weimin Yu
2026-04-02 21:23:00 +00:00
committed by GitHub
parent 9f3dfec118
commit d2881b47dc
25 changed files with 253 additions and 258 deletions

View File

@@ -71,8 +71,7 @@ configurations {
}
dependencies {
// compatibility with Java 17
errorprone("com.google.errorprone:error_prone_core:2.23.0")
errorprone("com.google.errorprone:error_prone_core:2.48.0")
}
test {
@@ -113,14 +112,20 @@ tasks.withType(JavaCompile).configureEach {
// The -Werror flag causes Intellij to fail on deprecated api use.
// Allow IDE user to turn off this flag by specifying a Gradle VM
// option from inside the IDE.
if (System.getProperty('no_werror') != 'true') {
if (project.hasProperty('no_werror') && project.property('no_werror') == 'true') {
// skip -Werror
} else if (System.getProperty('no_werror') == 'true') {
// skip -Werror
} else {
options.compilerArgs << "-Werror"
}
if (name.equals('compileTestJava')) {
// Allow unused methods in tests.
options.errorprone.disable("UnusedMethod")
// Allow unused variables in tests.
options.errorprone.disable("UnusedVariable")
// TODO(b/498588847): uncomment below when the global suppression
// below is removed.
// options.errorprone.disable("UnusedVariable")
}
// Allow using non-constant strings in log.
options.errorprone.disable("FloggerLogString")
@@ -134,6 +139,32 @@ tasks.withType(JavaCompile).configureEach {
options.errorprone.disable("LongDoubleConversion")
// Allow import of commonly-used names such as "Type".
options.errorprone.disable("BadImport")
// TODO(b/498588847): Review suppressed checks below
// Disable new checks in 2.48.0 that break the build with -Werror
options.errorprone.disable("ExpensiveLenientFormatString")
options.errorprone.disable("EnumOrdinal")
// Triggered by JapaneseLanguageValidator
options.errorprone.disable("ClassInitializationDeadlock")
// Allow unused variables globally.
options.errorprone.disable("UnusedVariable")
options.errorprone.disable("AnnotateFormatMethod")
options.errorprone.disable("EffectivelyPrivate")
options.errorprone.disable("JdkObsolete")
options.errorprone.disable("ImpossibleNullComparison")
options.errorprone.disable("UnnecessaryAssignment")
options.errorprone.disable("PatternMatchingInstanceof")
options.errorprone.disable("IntLiteralCast")
options.errorprone.disable("SystemConsoleNull")
options.errorprone.disable("FormatStringShouldUsePlaceholders")
options.errorprone.disable("BooleanLiteral")
options.errorprone.disable("StatementSwitchToExpressionSwitch")
options.errorprone.disable("AssignmentExpression")
options.errorprone.disable("JavaDurationGetSecondsToToSeconds")
options.errorprone.disable("StringConcatToTextBlock")
options.errorprone.disable("TruthConstantAsserts")
options.errorprone.disable("NullArgumentForNonNullParameter")
options.errorprone.disableWarningsInGeneratedCode = true
options.errorprone.errorproneArgumentProviders.add([
asArguments: {