Skip to content

Annotations and checks for default visibility #1478

@wmdietl

Description

@wmdietl

The Error Prone EffectivelyPrivate https://errorprone.info/bugpattern/EffectivelyPrivate check ensures no misleading modifiers are present in code.

We follow the code style that we highlight default visibility (i.e. no explicit visibility in the source) with /*package-private*/.
This rule is not enforced, though, meaning that there might be inconsistent or no comments.

#1477 fixed the new EffectivelyPrivate errors by removing misleading modifiers.
However, it would help readability to have an explicit comment.

We could:

  • Create new SOURCE-visible annotation @PackagePrivate to replace the /*package-private*/ comments
  • Create a different annotation for EffectivelyPrivate uses of default visibility.
  • Have new checks that ensure these new annotations are used consistently (only if no explicit visibility modifier, no conflicts, etc.)

Maybe relatedly, ensure that no bridge methods are created inadvertently. (Does EP already have a check like this?)

As this new check doesn't need a type system, it might be better as an Error Prone check.

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