Skip to content

AvoidCommonTypeNames false positives when using --release #5957

Open

Description

@jeffrey-easyesi

Using Error Prone 2.50 and compiling with the --release option, the AvoidCommonTypeNames checker is sometimes including java.lang.X.Y classes, when really there is no reason to warn about clashes with those since they are not imported automatically with their undotted name.

Example (using Java 25 with --release 25):

Info.java:1: warning: [AvoidCommonTypeNames] Info clashes with java.lang.ProcessHandle.Info
class Info {}
^
    (see https://errorprone.info/bugpattern/AvoidCommonTypeNames)

I think this was introduced by https://github.com/google/error-prone/commit/924cb63735c9e6e44b0362b8ed9fbcfdf1dc8d9d/. The getSymbols call sometimes includes inner classes that getSymbolsByName does not, varying on both the Java version and the --release version:

Java version --release version Classes
21 8 Character.UnicodeScript
25 8 Character.UnicodeScript
21 11 StackWalker.StackFrame
25 11 none
21 17 StackWalker.StackFrame, Thread.State, Character.UnicodeScript
25 17 System.LoggerFinder, Character.UnicodeScript
21 21 none
25 21 System.LoggerFinder, ProcessHandle.Info
25 25 ProcessHandle.Info

Activity

  1. cpovirk commented on Jul 18, 2026

    @cpovirk
    Member

    Interesting, thanks. I wonder if Symtab is not quite the right tool for this job, similar to how we found that it might not have been the right tool for the job in #5791. I think we've worried before that alternatives can be expensive, but—assuming that there is a proper alternative here, as seems especially likely for a Java 9+ (modular) compilation—I'd hope we don't have to worry about expense because of the caching of the result. Or we just hard-code the list of java.lang classes and write a test to nudge us to update it when new ones are added....

  2. AzazelSensei commented on Aug 13, 2026

    @AzazelSensei

    Opened #6023

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions