受保护的成员是 public API 的一部分吗?

Are protected members part of the public API?

既然受保护的成员可以被子类访问,它们是publicAPI的一部分吗?因此,他们是否与明确的 public 成员共享相同的向后兼容性要求?

我想这个问题会随着 private[foo](来自 Scala)之类的东西变得更加复杂。请随意回答或不回答这个问题。

是的,是的:受保护的成员是导出的一部分 (public) API 并且具有相同的兼容性要求。

Java 将访问修饰符作为许多 JVM 和非 JVM 语言的先驱,这些语言紧随其后;并且有效Java对此事有权威的说法

来自项目 15:最小化 类 和成员

的可访问性

...both private and package-private members are part of a class’s implementation and do not normally impact its exported API.

For members of public classes, a huge increase in accessibility occurs when the access level goes from package-private to protected. A protected member is part of the class’s exported API and must be supported forever. Also, a protected member of an exported class represents a public commitment to an implementation detail. The need for protected members should be relatively rare.