google / google/error-prone

`EffectivelyPrivate` false positives?

Open
#5,182 14 comments 2 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
7.2k
Forks
820
Avg merge
5h 9m
Merged PRs (30d)
50

Description

A couple of scenarios:

### `public` methods on inner `private` classes

```java
class Outside {

private class Inside {
public void doSomething() {
// ...
}
}
}
```

I'm prepared to be told that it's worthwhile warning on `doSomething()`, but at the moment it seems a bit like noise. It appears to me it's not just 'effectively private', it is private because it's defined in a private inner class?

It will also warn on `public` (and `protected`) constructors of private inner classes.

### `public` methods on `private` inner classes that are extended by `public` inner classes

```java
class Outside {

private abstract class InsideParent {
public void doSomething() {
// ...
}
}

public OutsideChild extends InsideParent {
// ... other stuff
}
}
```

`doSomething()` is supposed to be visible and accessible on `OutsideChild`. This is a fairly common pattern, isn't it?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.