Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #28432
| From | Simon Lewis <simonlewis2001@gmail.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: @java.lang.DontOverride |
| Date | 2014-05-11 11:03 +0200 |
| Organization | Lewis |
| Message-ID | <87bnv47kmn.fsf@gmail.com> (permalink) |
| References | <override-20140511031054@ram.dialup.fu-berlin.de> |
ram@zedat.fu-berlin.de (Stefan Ram) writes:
> 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?
A rare requirement but you could just try and call the superclass method
and catch any exception that results and call your own one.
Back to comp.lang.java.programmer | Previous | Next | Find similar | Unroll thread
Re: @java.lang.DontOverride Simon Lewis <simonlewis2001@gmail.com> - 2014-05-11 11:03 +0200
csiph-web