Skip to content

AvoidCommonTypeNames false positives when using --release #5957

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

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