On 01/15/2020 03:47 PM, Jonathan Gibbons wrote:
As regards package-private and private intermediate supertypes, in the absence of any pre-existing comment to the contrary, your inclusion of isPrivate in isUndocumentedEnclosure is morally justifiable, even if it is a change in behavior in an absurdly weird corner case that (to the best of my knowledge) is undocumented.
As further justification for this change in behavior to be regarded as a bug fix, I note that javac allows access to public methods of private intermediate supertypes. This implies the behavior is required by JLS, and so is justification for javadoc documenting the available methods.
Toy files attached, for the record. -- Jon
package q; import p.Demo; public class Client { void m() { new Demo.A().mPrivate(); new Demo.B().mPackagePrivate(); } }
package p; public class Demo { public static class Base { } private static class Private extends Base { public void mPrivate() { } } public static class A extends Private { } static class PackagePrivate extends Base { public void mPackagePrivate() { } } public static class B extends PackagePrivate { } }