Skip to content

Conversation

@CRogers
Copy link
Contributor

@CRogers CRogers commented Jul 14, 2025

Before this PR

Internally, repos are being trying to take an upgrade of com.github.ben-manes.caffeine:caffeine to 3.2.2. This release of caffeine bumps the dependency of error_prone_annotations to 2.44.0.

Since we use gradle-consistent-versions and have a virtual platform for com.google.errorprone:*, this also bumps the version of error_prone_check_api used in the annotationProcessor configruation:

Screenshot 2025-07-14 at 13 27 05

The current latest baseline-error-prone that is running inside the build called the ASTHelpers.findSuperMethod which got deleted in error-prone 2.39.0 (PR). This causes this error:

java.lang.NoSuchMethodError: 'java.util.Optional com.google.errorprone.util.ASTHelpers.findSuperMethod(com.sun.tools.javac.code.Symbol$MethodSymbol, com.sun.tools.javac.code.Types)'
        at com.palantir.baseline.errorprone.ThrowSpecificity.matchMethod(ThrowSpecificity.java:68)

After this PR

==COMMIT_MSG==
Upgrade error-prone to 2.40.0 and stop errors of the form when error-prone >2.39.0 is used:

java.lang.NoSuchMethodError: 'java.util.Optional com.google.errorprone.util.ASTHelpers.findSuperMethod(com.sun.tools.javac.code.Symbol$MethodSymbol, com.sun.tools.javac.code.Types)'
        at com.palantir.baseline.errorprone.ThrowSpecificity.matchMethod(ThrowSpecificity.java:68)

==COMMIT_MSG==

Upgrading allows people to upgrade dependencies that use error-prone-annotations >2.39.0.

Possible downsides?

  • baseline-error-prone uses a previously published version of basline-error-prone for it's own compilation. When we upgrade error-prone in versions.props, we upgrade the error-prone used by the previous baseline-error-prone in compilation. I've worked around this using enforcedPlatform (which might even be a nice trick to stop this kind of error happening in consumer repos - but needs more though).

We need to verify that the new checks added are reasonable and if we want them to autofix:

$ git diff --name-only --diff-filter A v2.38.0..v2.40.0
core/src/main/java/com/google/errorprone/bugpatterns/BooleanLiteral.java
core/src/main/java/com/google/errorprone/bugpatterns/PreferInstanceofOverGetKind.java
core/src/main/java/com/google/errorprone/bugpatterns/UnnecessaryQualifier.java
core/src/main/java/com/google/errorprone/bugpatterns/formatstring/LenientFormatStringUtils.java
core/src/test/java/com/google/errorprone/bugpatterns/BooleanLiteralTest.java
core/src/test/java/com/google/errorprone/bugpatterns/PreferInstanceofOverGetKindTest.java
core/src/test/java/com/google/errorprone/bugpatterns/UnnecessaryQualifierTest.java
docs/bugpattern/ExpensiveLenientFormatString.md
docs/bugpattern/UnnecessaryQualifier.md
  • BooleanLiteral (Test)
    • This one seems fine and good, they even check for Boolean.TRUE::equals that we have a few instances of internally.
  • PreferInstanceofOverGetKind (Test)
    • This is also a good change which improves code by enabling destructuring to happen. Going from equal to instanceof to destructing requires compilation twice though, we'll need to keep an eye on if this breaks upgrades for error-prone sources.
  • UnnecessaryQualifier (Test)
    • Fixes something with Dagger injection. Willing to let it autopatch and see what happens. Lots of usages of @Qualifer internally.

We also need to check that suppressible-error-prone works with 2.40.0 - I tried it on this PR and the test suites passed on this build.

@changelog-app
Copy link

changelog-app bot commented Jul 14, 2025

Generate changelog in changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

Upgrade error-prone to 2.40.0 and stop errors of the form when error-prone >2.39.0 is used:

java.lang.NoSuchMethodError: 'java.util.Optional com.google.errorprone.util.ASTHelpers.findSuperMethod(com.sun.tools.javac.code.Symbol$MethodSymbol, com.sun.tools.javac.code.Types)'
        at com.palantir.baseline.errorprone.ThrowSpecificity.matchMethod(ThrowSpecificity.java:68)

Check the box to generate changelog(s)

  • Generate changelog entry

}
Types types = state.getTypes();
if (ASTHelpers.findSuperMethod(ASTHelpers.getSymbol(tree), types).isPresent()) {
if (!ASTHelpers.findSuperMethods(ASTHelpers.getSymbol(tree), types).isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why this flip?

Copy link
Contributor Author

@CRogers CRogers Jul 14, 2025

Choose a reason for hiding this comment

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

findSuperMethod got deleted, we have to use findSuperMethods that returns a Set instead of a single value from the set. So checking the set is non-empty should be the same as the old logic.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah - didn't see the change of the "s"

@bulldozer-bot bulldozer-bot bot merged commit c8b8483 into develop Jul 14, 2025
5 checks passed
@bulldozer-bot bulldozer-bot bot deleted the callumr/bump-errorprone branch July 14, 2025 15:44
@autorelease3
Copy link

autorelease3 bot commented Jul 14, 2025

Released 6.42.0

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.

4 participants