Static method access dilemma and proposal: @NotInherited
Zhong Yu
zhong.j.yu at gmail.com
Thu Jun 27 17:26:24 PDT 2013
I see, the short name of the method must be prefixed with another word
(the class name) to make sense, so inheritance could be very
misleading.
But if inheritance is considered bad across the board for several
different reasons, we shouldn't need explicit flags to disable
individual methods; I agree with using javac warning and IDE error to
effectively/practically disable this language feature outright. The
burden is on those who want to suppress the warning.
On Thu, Jun 27, 2013 at 5:42 PM, Stephen Colebourne
<scolebourne at joda.org> wrote:
> On 27 June 2013 22:17, Zhong Yu <zhong.j.yu at gmail.com> wrote:
>> Stephen, would it be more accurate to say that what you want is
>> actually non-"overridable". It's not a problem that B inherits foo()
>> from A. It is a problem that B may introduce its own foo(), therefore
>> the meaning of `B.foo()` is a little uncertain.
>
> No, its specifically that anyone reading B.foo() instead of A.foo()
> would/could misunderstand what the code meant.
>
> I actually made the mistake myself, ie.with my own API. My call wasn't
> type checked because it was being directly passed to an
> assertEquals(Object,Object) in a test case.
>
> Stephen
>
More information about the lambda-dev
mailing list