Skip to content

Rename internal Gson classes containing $ #1744

@Marcono1234

Description

@Marcono1234

Please rename Gson classes whose name contains a $:

  • com.google.gson.internal.$Gson$Types
  • com.google.gson.internal.$Gson$Preconditions

JLS 14 §3.8 says:

The dollar sign should be used only in mechanically generated source code or, rarely, to access pre-existing names on legacy systems.

It appears these classes were renamed by 4efb133 to prevent IDE auto-importing. However, nowadays IDEs (at least Eclipse) have ways to prevent certain types or packages from appearing in import suggestions.
Additionally these classes are in the internal package and with the Java module system they won't be visible to users anymore.

For now maybe simply removing the $s and adding a documentation comment that these classes are internal might already solve the issue.

Currently when developing Gson having to deal with these classes is (at least under Eclipse but I assume IntelliJ has similar issues) pretty annoying:

  • Eclipse fails adding the imports
  • Eclipse suggests bogus types in the "Open Types" dialog
  • Using conditional breakpoints in these classes is not possible at all because Eclipse incorrectly assumes they are nested classes
  • ... likely more

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions