Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #28431

Re: @java.lang.DontOverride

Date 2014-05-10 21:50 -0400
From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.java.programmer
Subject Re: @java.lang.DontOverride
References <override-20140511031054@ram.dialup.fu-berlin.de>
Message-ID <536ed74f$0$296$14726298@news.sunsite.dk> (permalink)
Organization SunSITE.dk - Supporting Open source

Show all headers | View raw


On 5/10/2014 9:16 PM, Stefan Ram wrote:
> class Example extends javax.swing.JComponent
> { public boolean isValid(){ return true; }}
>
>    I do not want to override any method of JComponent with my method.
>    I just want to add a new method. But now or in future versions of
>    Swing there might be an »isValid« method in JComponent. So I'd like
>    to have a @java.lang.DontOverride annotation with the following
>    meaning: »Aborts compilation if any base class has a non-private
>    method of the same name.« Why do we have @java.lang.Ovverride, but
>    not the opposite? Or have I missed something?

Lots of things can be done - far from all are done.

C# has the feature - if override keyword is missing then you will
get a compile error.

But that implementation could give a guess to how Java may do it in the
future - no DontOverride annotation but make Override required if
override (no Override => DontOverride).

But if that was the Java guys where thinking when they made the decision
I have no clue.

Arne


Back to comp.lang.java.programmer | Previous | Next | Find similar | Unroll thread


Thread

Re: @java.lang.DontOverride Arne Vajhøj <arne@vajhoej.dk> - 2014-05-10 21:50 -0400

csiph-web